X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fphp%2Fsrc%2FTests%2FCondition%2FPhpConditionTest.php;fp=web%2Fmodules%2Fcontrib%2Fphp%2Fsrc%2FTests%2FCondition%2FPhpConditionTest.php;h=84476ed3a1c31bc94f625122b9965748e280b2ac;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/php/src/Tests/Condition/PhpConditionTest.php b/web/modules/contrib/php/src/Tests/Condition/PhpConditionTest.php new file mode 100644 index 000000000..84476ed3a --- /dev/null +++ b/web/modules/contrib/php/src/Tests/Condition/PhpConditionTest.php @@ -0,0 +1,70 @@ +manager = $this->container->get('plugin.manager.condition'); + } + + /** + * Tests conditions. + */ + public function testConditions() { + // Grab the PHP condition and configure it to check against a php snippet. + $condition = $this->manager->createInstance('php') + ->setConfig('php', ''); + $this->assertTrue($condition->execute(), 'PHP condition passes as expected.'); + // Check for the proper summary. + self::assertEquals($condition->summary(), 'When the given PHP evaluates as TRUE.'); + + // Set the PHP snippet to return FALSE. + $condition->setConfig('php', ''); + $this->assertFalse($condition->execute(), 'PHP condition fails as expected.'); + + // Negate the condition. + $condition->setConfig('negate', TRUE); + // Check for the proper summary. + self::assertEquals($condition->summary(), 'When the given PHP evaluates as FALSE.'); + + // Reverse the negation. + $condition->setConfig('negate', FALSE); + // Set and empty snippet. + $condition->setConfig('php', FALSE); + // Check for the proper summary. + self::assertEquals($condition->summary(), 'No PHP code has been provided.'); + } + +}