diff -r 000000000000 -r 7f95f8617b0b vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/XMLSchemaTest.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/XMLSchemaTest.php Sat Sep 24 15:40:41 2011 +0200 @@ -0,0 +1,64 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection; + +class XMLSchemaTest extends \PHPUnit_Framework_TestCase +{ + static public function dataValidateSchemaFiles() + { + $schemaFiles = array(); + $di = new \DirectoryIterator(__DIR__."/Fixtures/config/xml"); + foreach ($di as $element) { + if ($element->isFile() && strpos($element->getFilename(), ".xml") !== false) { + $schemaFiles[] = array($element->getPathname()); + } + } + + return $schemaFiles; + } + + /** + * @dataProvider dataValidateSchemaFiles + * @param string $file + */ + public function testValidateSchema($file) + { + $found = false; + $dom = new \DOMDocument('1.0', 'UTF-8'); + $dom->load($file); + + + $dbalElements = $dom->getElementsByTagNameNS("http://symfony.com/schema/dic/doctrine", "config"); + if ($dbalElements->length) { + $dbalDom = new \DOMDocument('1.0', 'UTF-8'); + $dbalNode = $dbalDom->importNode($dbalElements->item(0)); + $dbalDom->appendChild($dbalNode); + + $ret = $dbalDom->schemaValidate(__DIR__."/../../Resources/config/schema/doctrine-1.0.xsd"); + $this->assertTrue($ret, "DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance."); + $found = true; + } + + $ormElements = $dom->getElementsByTagNameNS("http://symfony.com/schema/dic/doctrine", "config"); + if ($ormElements->length) { + $ormDom = new \DOMDocument('1.0', 'UTF-8'); + $ormNode = $ormDom->importNode($ormElements->item(0)); + $ormDom->appendChild($ormNode); + + $ret = $ormDom->schemaValidate(__DIR__."/../../Resources/config/schema/doctrine-1.0.xsd"); + $this->assertTrue($ret, "DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance."); + $found = true; + } + + $this->assertTrue($found, "Neither nor elements found in given XML. Are namespaces configured correctly?"); + } +}