Skip to content

Commit

Permalink
Added unit tests for dependency injection
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Feb 26, 2017
1 parent 2dff829 commit bbfb02a
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
55 changes: 55 additions & 0 deletions Tests/DependencyInjection/ConfigurationTest.php
@@ -0,0 +1,55 @@
<?php

/*
* (c) Christian Gripp <mail@core23.de>
*
* 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);
}
}
40 changes: 40 additions & 0 deletions Tests/DependencyInjection/Core23DompdfExtensionTest.php
@@ -0,0 +1,40 @@
<?php

/*
* (c) Christian Gripp <mail@core23.de>
*
* 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(),
);
}
}
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -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"
Expand Down

0 comments on commit bbfb02a

Please sign in to comment.