X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fconfig%2FTests%2FDefinition%2FArrayNodeTest.php;h=089cb56638d352b8ecdb344380eff61cfe58f299;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=0b5565e0b379bf08b30608dc90f578149bb70cd5;hpb=eba34333e3c89f208d2f72fa91351ad019a71583;p=yaffs-website diff --git a/vendor/symfony/config/Tests/Definition/ArrayNodeTest.php b/vendor/symfony/config/Tests/Definition/ArrayNodeTest.php index 0b5565e0b..089cb5663 100644 --- a/vendor/symfony/config/Tests/Definition/ArrayNodeTest.php +++ b/vendor/symfony/config/Tests/Definition/ArrayNodeTest.php @@ -56,10 +56,10 @@ class ArrayNodeTest extends TestCase { if ($expected instanceof \Exception) { if (method_exists($this, 'expectException')) { - $this->expectException(get_class($expected)); + $this->expectException(\get_class($expected)); $this->expectExceptionMessage($expected->getMessage()); } else { - $this->setExpectedException(get_class($expected), $expected->getMessage()); + $this->setExpectedException(\get_class($expected), $expected->getMessage()); } } $node = new ArrayNode('root'); @@ -216,4 +216,36 @@ class ArrayNodeTest extends TestCase $node = new ArrayNode('foo'); $node->getDefaultValue(); } + + public function testSetDeprecated() + { + $childNode = new ArrayNode('foo'); + $childNode->setDeprecated('"%node%" is deprecated'); + + $this->assertTrue($childNode->isDeprecated()); + $this->assertSame('"foo" is deprecated', $childNode->getDeprecationMessage($childNode->getName(), $childNode->getPath())); + + $node = new ArrayNode('root'); + $node->addChild($childNode); + + $deprecationTriggered = false; + $deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) { + if (E_USER_DEPRECATED === $level) { + return $deprecationTriggered = true; + } + + return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false; + }; + + $prevErrorHandler = set_error_handler($deprecationHandler); + $node->finalize(array()); + restore_error_handler(); + + $this->assertFalse($deprecationTriggered, '->finalize() should not trigger if the deprecated node is not set'); + + $prevErrorHandler = set_error_handler($deprecationHandler); + $node->finalize(array('foo' => array())); + restore_error_handler(); + $this->assertTrue($deprecationTriggered, '->finalize() should trigger if the deprecated node is set'); + } }