diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php new file mode 100644 index 00000000..0667330b --- /dev/null +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Core23\DompdfBundle\Tests\DependencyInjection; + +use Core23\DompdfBundle\DependencyInjection\Configuration; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Processor; + +class ConfigurationTest extends TestCase +{ + public function testDefaultOptions() + { + $processor = new Processor(); + + $config = $processor->processConfiguration(new Configuration(), array(array( + ))); + + $expected = array( + 'webDir' => '%kernel.root_dir%/../web', + 'defaults' => array(), + ); + + $this->assertSame($expected, $config); + } + + public function testOptions() + { + $processor = new Processor(); + + $config = $processor->processConfiguration(new Configuration(), array(array( + 'webDir' => '%kernel.root_dir%/../customWeb', + 'defaults' => array( + 'foo' => 'bar', + 'bar' => 'baz', + ), + ))); + + $expected = array( + 'webDir' => '%kernel.root_dir%/../customWeb', + 'defaults' => array( + 'foo' => 'bar', + 'bar' => 'baz', + ), + ); + + $this->assertSame($expected, $config); + } +} diff --git a/Tests/DependencyInjection/Core23DompdfExtensionTest.php b/Tests/DependencyInjection/Core23DompdfExtensionTest.php new file mode 100644 index 00000000..2dfafdca --- /dev/null +++ b/Tests/DependencyInjection/Core23DompdfExtensionTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Core23\DompdfBundle\Tests\DependencyInjection; + +use Core23\DompdfBundle\DependencyInjection\Core23DompdfExtension; +use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; + +class Core23DompdfExtensionTest extends AbstractExtensionTestCase +{ + public function testLoadDefault() + { + $this->load(array( + 'webDir' => '%kernel.root_dir%/../customWeb', + 'defaults' => array( + 'foo' => 'bar', + 'bar' => 'baz', + ), + )); + + $this->assertContainerBuilderHasParameter('core23.dompdf_web', '%kernel.root_dir%/../customWeb'); + $this->assertContainerBuilderHasParameter('core23.dompdf_options', array( + 'foo' => 'bar', + 'bar' => 'baz', + )); + } + + protected function getContainerExtensions() + { + return array( + new Core23DompdfExtension(), + ); + } +} diff --git a/composer.json b/composer.json index f9bec4f6..a3a4d452 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.0", + "matthiasnoback/symfony-dependency-injection-test": "^1.1", "phpunit/phpunit": "^5.7", "sllh/php-cs-fixer-styleci-bridge": "^2.0", "symfony/phpunit-bridge": "^3.1"