Example #1
0
 public function testTheXorLogicalValidatorReturnsExpectedResponse()
 {
     $test = new LXor($this->true, $this->true);
     $this->assertFalse($test->isValid('foo'));
     $test = new LXor($this->true, $this->false);
     $this->assertTrue($test->isValid('foo'));
     $test = new LXor($this->false, $this->true);
     $this->assertTrue($test->isValid('foo'));
     $test = new LXor($this->false, $this->false);
     $this->assertFalse($test->isValid('foo'));
 }
Example #2
0
 public function testCombinationsOfTheLogicalValidatorsWorkCorrectly()
 {
     //a AND (b OR c)
     $test = new LAnd($this->true, new LOr($this->true, $this->false));
     $this->assertTrue($test->isValid('foo'));
     $test = new LAnd($this->true, new LOr($this->false, $this->true));
     $this->assertTrue($test->isValid('foo'));
     $test = new LAnd($this->true, new LOr($this->true, $this->true));
     $this->assertTrue($test->isValid('foo'));
     $test = new LAnd($this->true, new LOr($this->false, $this->false));
     $this->assertFalse($test->isValid('foo'));
     $test = new LAnd($this->false, new LOr($this->true, $this->false));
     $this->assertFalse($test->isValid('foo'));
     $test = new LAnd($this->false, new LOr($this->false, $this->true));
     $this->assertFalse($test->isValid('foo'));
     $test = new LAnd($this->false, new LOr($this->true, $this->true));
     $this->assertFalse($test->isValid('foo'));
     $test = new LAnd($this->false, new LOr($this->false, $this->false));
     $this->assertFalse($test->isValid('foo'));
     //(a AND b) OR c
     $test = new Lor(new LAnd($this->true, $this->true), $this->true);
     $this->assertTrue($test->isValid('foo'));
     $test = new Lor(new LAnd($this->false, $this->true), $this->true);
     $this->assertTrue($test->isValid('foo'));
     $test = new Lor(new LAnd($this->true, $this->false), $this->true);
     $this->assertTrue($test->isValid('foo'));
     $test = new Lor(new LAnd($this->false, $this->false), $this->true);
     $this->assertTrue($test->isValid('foo'));
     $test = new Lor(new LAnd($this->true, $this->true), $this->false);
     $this->assertTrue($test->isValid('foo'));
     $test = new Lor(new LAnd($this->false, $this->true), $this->false);
     $this->assertFalse($test->isValid('foo'));
     $test = new Lor(new LAnd($this->true, $this->false), $this->false);
     $this->assertFalse($test->isValid('foo'));
     $test = new Lor(new LAnd($this->false, $this->false), $this->false);
     $this->assertFalse($test->isValid('foo'));
     //a AND (b XOR c)
     $test = new LAnd($this->true, new LXor($this->true, $this->false));
     $this->assertTrue($test->isValid('foo'));
     $test = new LAnd($this->true, new LXor($this->false, $this->true));
     $this->assertTrue($test->isValid('foo'));
     $test = new LAnd($this->true, new LXor($this->true, $this->true));
     $this->assertFalse($test->isValid('foo'));
     $test = new LAnd($this->true, new LXor($this->false, $this->false));
     $this->assertFalse($test->isValid('foo'));
     $test = new LAnd($this->false, new LXor($this->true, $this->false));
     $this->assertFalse($test->isValid('foo'));
     $test = new LAnd($this->false, new LXor($this->false, $this->true));
     $this->assertFalse($test->isValid('foo'));
     $test = new LAnd($this->false, new LXor($this->true, $this->true));
     $this->assertFalse($test->isValid('foo'));
     $test = new LAnd($this->false, new LXor($this->false, $this->false));
     $this->assertFalse($test->isValid('foo'));
     //(a AND b) XOR c
     $test = new LXor(new LAnd($this->true, $this->true), $this->true);
     $this->assertFalse($test->isValid('foo'));
     $test = new LXor(new LAnd($this->false, $this->true), $this->true);
     $this->assertTrue($test->isValid('foo'));
     $test = new LXor(new LAnd($this->true, $this->false), $this->true);
     $this->assertTrue($test->isValid('foo'));
     $test = new LXor(new LAnd($this->false, $this->false), $this->true);
     $this->assertTrue($test->isValid('foo'));
     $test = new LXor(new LAnd($this->true, $this->true), $this->false);
     $this->assertTrue($test->isValid('foo'));
     $test = new LXor(new LAnd($this->false, $this->true), $this->false);
     $this->assertFalse($test->isValid('foo'));
     $test = new LXor(new LAnd($this->true, $this->false), $this->false);
     $this->assertFalse($test->isValid('foo'));
     $test = new LXor(new LAnd($this->false, $this->false), $this->false);
     $this->assertFalse($test->isValid('foo'));
     //using not
     //NOT (a AND (b OR c))
     $test = new LAnd($this->true, new LOr($this->true, $this->false));
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new LAnd($this->true, new LOr($this->false, $this->true));
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new LAnd($this->true, new LOr($this->true, $this->true));
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new LAnd($this->true, new LOr($this->false, $this->false));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LAnd($this->false, new LOr($this->true, $this->false));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LAnd($this->false, new LOr($this->false, $this->true));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LAnd($this->false, new LOr($this->true, $this->true));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LAnd($this->false, new LOr($this->false, $this->false));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     //NOT ((a AND b) OR c)
     $test = new Lor(new LAnd($this->true, $this->true), $this->true);
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new Lor(new LAnd($this->false, $this->true), $this->true);
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new Lor(new LAnd($this->true, $this->false), $this->true);
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new Lor(new LAnd($this->false, $this->false), $this->true);
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new Lor(new LAnd($this->true, $this->true), $this->false);
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new Lor(new LAnd($this->false, $this->true), $this->false);
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new Lor(new LAnd($this->true, $this->false), $this->false);
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new Lor(new LAnd($this->false, $this->false), $this->false);
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     //NOT (a AND (b XOR c))
     $test = new LAnd($this->true, new LXor($this->true, $this->false));
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new LAnd($this->true, new LXor($this->false, $this->true));
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new LAnd($this->true, new LXor($this->true, $this->true));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LAnd($this->true, new LXor($this->false, $this->false));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LAnd($this->false, new LXor($this->true, $this->false));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LAnd($this->false, new LXor($this->false, $this->true));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LAnd($this->false, new LXor($this->true, $this->true));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LAnd($this->false, new LXor($this->false, $this->false));
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     //NOT ((a AND b) XOR c)
     $test = new LXor(new LAnd($this->true, $this->true), $this->true);
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LXor(new LAnd($this->false, $this->true), $this->true);
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new LXor(new LAnd($this->true, $this->false), $this->true);
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new LXor(new LAnd($this->false, $this->false), $this->true);
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new LXor(new LAnd($this->true, $this->true), $this->false);
     $not = new LNot($test);
     $this->assertFalse($not->isValid('foo'));
     $test = new LXor(new LAnd($this->false, $this->true), $this->false);
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LXor(new LAnd($this->true, $this->false), $this->false);
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     $test = new LXor(new LAnd($this->false, $this->false), $this->false);
     $not = new LNot($test);
     $this->assertTrue($not->isValid('foo'));
     //feel free to add other combinations if you are bored!
 }