Skip to content
Browse files

Added test for annotated file loader

  • Loading branch information...
1 parent acb6a52 commit 14551cd737834c757ab97f51556537d880fca95b @joshiausdemwald committed Jun 2, 2011
View
1 src/Ifschleife/Bundle/AutowiringBundle/DependencyInjection/Loader/AnnotatedFileLoader.php
@@ -20,6 +20,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
+
namespace Ifschleife\Bundle\AutowiringBundle\DependencyInjection\Loader;
use Symfony\Component\Config\FileLocatorInterface;
View
89 ...eife/Bundle/AutowiringBundle/Tests/DependencyInjection/Loader/AnnotatedFileLoaderTest.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * Copyright (c) 2011 Johannes Heinen <johannes.heinen@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+namespace Ifschleife\Bundle\AutowiringBundle\Tests\DependencyInjection\Loader;
+
+use Ifschleife\Bundle\AutowiringBundle\DependencyInjection\Loader\AnnotatedFileLoader;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Ifschleife\Bundle\AutowiringBundle\Autowiring\Parser\PhpParser;
+use Ifschleife\Bundle\AutowiringBundle\Annotation\AnnotationReader;
+use Symfony\Component\Config\FileLocator;
+
+/**
+ * AnnotatedFileLoaderTest
+ *
+ * @author joshi
+ */
+class AnnotatedFileLoaderTest extends \PHPUnit_Framework_Testcase
+{
+ /**
+ * @dataProvider Files
+ */
+ function testFiles($file)
+ {
+ $container = new ContainerBuilder;
+
+ $parser = new PhpParser();
+
+ $reader = new AnnotationReader;
+
+ $locator = new FileLocator();
+
+ $loader = new AnnotatedFileLoader($container, $locator, $parser, $reader);
+
+ $this->assertTrue($loader->supports($file));
+ }
+
+ /**
+ * @dataProvider malformedFiles
+ */
+ function testMalformedFiles($file)
+ {
+ $container = new ContainerBuilder;
+
+ $parser = new PhpParser();
+
+ $reader = new AnnotationReader;
+
+ $locator = new FileLocator();
+
+ $loader = new AnnotatedFileLoader($container, $locator, $parser, $reader);
+
+ $this->assertFalse($loader->supports($file));
+ }
+
+ function files()
+ {
+ return array(
+ array(__DIR__ . '/../../Fixtures/CreateServiceTestclass1.php')
+ );
+ }
+
+ function malformedFiles()
+ {
+ return array(
+ array(__DIR__ . '/../../Fixtures/NonExistent'),
+ array(__DIR__ . '/../../Fixtures/CreateServiceMalformed1.xml')
+ );
+ }
+}
View
13 src/Ifschleife/Bundle/AutowiringBundle/Tests/Fixtures/CreateServiceMalformed.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Document : CreateServiceMalformed.xml
+ Created on : 2. Juni 2011, 11:41
+ Author : joshi
+ Description:
+ Purpose of the document follows.
+-->
+
+<root>
+
+</root>

0 comments on commit 14551cd

Please sign in to comment.
Something went wrong with that request. Please try again.