Skip to content
Snippets Groups Projects
Select Git revision
  • 7b7c5c22e6ca9b56d2ef1c87d9c213f973c1f97c
  • master default protected
  • feat/message-handling
  • feat/request-id
  • 1.13.2
  • 1.13.1
  • 1.13.0
  • 1.12.1
  • 1.12.0
  • 1.11.0
  • 1.11.0-beta2
  • 1.11.0-beta1
  • 1.10.2
  • 1.10.1
  • 1.10.0
  • 1.9.0
  • 1.8.0
  • 1.7.4
  • 1.7.3
  • 1.7.2
  • 1.7.1
  • 1.7.0
  • 1.6.2
  • 1.6.2-beta2
24 results

TestSensitiveDataProcessor.php

Blame
  • TestSensitiveDataProcessor.php 1.08 KiB
    <?php
    
    namespace unit\Processor;
    
    use WP_Mock;
    use WP_Mock\Tools\TestCase;
    use WPDesk\Logger\Processor\SensitiveDataProcessor;
    
    class TestSensitiveDataProcessor extends TestCase
    {
    
    	public function setUp(): void {
    		WP_Mock::setUp();
    	}
    
    	public function tearDown(): void {
    		WP_Mock::tearDown();
    	}
    
    	public function testShouldReplaceWhenMatched() {
    		$processor = new SensitiveDataProcessor( array( 'password' => '***' ) );
    		$record = array(
    			'password' => 'password',
    			'array' => array(
    				'password' => 'password',
    			),
    		);
    		$expected = array(
    			'password' => '***',
    			'array' => array(
    				'password' => '***',
    			),
    		);
    		$this->assertEquals( $expected, $processor->__invoke( $record ) );
    	}
    
    	public function testShouldNotReplaceWhenNotMatched() {
    		$processor = new SensitiveDataProcessor( array( 'password' => '***' ) );
    		$record = array(
    			'text' => 'text',
    			'array' => array(
    				'text' => 'text',
    			),
    		);
    		$expected = array(
    			'text' => 'text',
    			'array' => array(
    				'text' => 'text',
    			),
    		);
    		$this->assertEquals( $expected, $processor->__invoke( $record ) );
    	}
    
    }