Skip to content
Snippets Groups Projects
Select Git revision
  • 60a744d8061f43b66c15f6b3b4b959e77d485e54
  • master default protected
  • bugfix/wordpress-review
  • fix/duplicate
  • bugfix/get_current_screen_fail
  • feature/dismiss-nonce
  • replace-dodgy-path
  • bugfix/notice-not-show
  • devel
  • 3.3.0
  • 3.2.5
  • 3.2.4
  • 3.2.3
  • 3.2.2
  • 3.2.1
  • 3.2.0
  • 3.2.0-beta7
  • 3.2.0-beta6
  • 3.2.0-beta5
  • 3.2.0-beta4
  • 3.2.0-beta3
  • 3.2.0-beta2
  • 3.2.0-beta1
  • 3.1.4
  • 3.1.4-beta1
  • 3.1.3
  • 3.1.1
  • 3.1
  • 3.0
29 results

wp-notice-init.php

Blame
  • TestGetStrategy.php 1.38 KiB
    <?php
    
    namespace unit;
    
    use PHPUnit\Framework\TestCase;
    use WPDesk\ShowDecision\GetStrategy;
    
    class TestGetStrategy extends TestCase {
    	const true_1 = [ 'a' => '1' ];
    	const true_2 = [ 'b' => '2' ];
    	const true_3 = [ 'c' => '3' ];
    
    	const false_1 = [ 'x' => '1' ];
    	const false_2 = [ 'y' => '2' ];
    
    	/**
    	 * Prepares $_GET with true clauses
    	 */
    	private function prepare_get() {
    		$_GET = [
    			self::true_1,
    			self::true_2,
    			self::true_3
    		];
    	}
    
    	protected function setUp() {
    		parent::setUp();
    		$this->prepare_get();
    	}
    
    	public function testAndClausesFailure() {
    		$strategy = new GetStrategy( [
    			[
    				self::true_1,
    				self::false_1
    			]
    		] );
    		$this->assertFalse( $strategy->shouldDisplay() );
    	}
    
    	public function testAndClausesSuccess() {
    		$strategy = new GetStrategy( [
    			[
    				self::true_1,
    				self::true_2,
    				self::true_3
    			]
    		] );
    		$this->assertTrue( $strategy->shouldDisplay() );
    	}
    
    	public function testOrClausesSuccess() {
    		$strategy = new GetStrategy( [
    			[
    				self::true_1,
    				self::false_1
    			],
    			[
    				self::true_1,
    				self::true_2
    			]
    		] );
    		$this->assertTrue( $strategy->shouldDisplay() );
    	}
    
    	public function testOrClausesFailure() {
    		$strategy = new GetStrategy( [
    			[
    				self::true_1,