From 68439b663d5d6488093936c189e0c777c1dcc0f6 Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Fri, 19 Jun 2015 11:32:43 +0200 Subject: [PATCH] correct CS --- .../Compiler/ExtensionPass.php | 13 +++++- src/DependencyInjection/Configuration.php | 9 ++++ src/DependencyInjection/DatagridExtension.php | 10 ++++- .../Symfony/DependencyInjectionExtension.php | 9 ++++ src/RollerworksDatagridBundle.php | 9 ++++ .../Compiler/ExtensionPassTest.php | 33 ++++++++------ .../DependencyInjection/ConfigurationTest.php | 37 ++++++++++++++++ .../DatagridExtensionTest.php | 43 +++++++++++++++++++ 8 files changed, 148 insertions(+), 15 deletions(-) create mode 100644 tests/DependencyInjection/ConfigurationTest.php create mode 100644 tests/DependencyInjection/DatagridExtensionTest.php diff --git a/src/DependencyInjection/Compiler/ExtensionPass.php b/src/DependencyInjection/Compiler/ExtensionPass.php index 0e4a991..798b4d7 100644 --- a/src/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/DependencyInjection/Compiler/ExtensionPass.php @@ -1,5 +1,14 @@ + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Rollerworks\Component\DatagridBundle\DependencyInjection\Compiler; use Rollerworks\Component\Datagrid\Twig\Extension\DatagridExtension as TwigDatagridExtension; @@ -62,7 +71,7 @@ private function processExtensions(ContainerBuilder $container) private function processTypes(Definition $definition, ContainerBuilder $container) { - $types = array(); + $types = []; foreach ($container->findTaggedServiceIds('rollerworks_datagrid.column_type') as $serviceId => $tag) { $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId; @@ -75,7 +84,7 @@ private function processTypes(Definition $definition, ContainerBuilder $containe private function processTypeExtensions(Definition $definition, ContainerBuilder $container) { - $typeExtensions = array(); + $typeExtensions = []; foreach ($container->findTaggedServiceIds('rollerworks_datagrid.column_extension') as $serviceId => $tag) { $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 963553f..e4a5cfd 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -1,5 +1,14 @@ + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Rollerworks\Component\DatagridBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; diff --git a/src/DependencyInjection/DatagridExtension.php b/src/DependencyInjection/DatagridExtension.php index c98b3cb..fae4ae9 100644 --- a/src/DependencyInjection/DatagridExtension.php +++ b/src/DependencyInjection/DatagridExtension.php @@ -1,8 +1,16 @@ + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Rollerworks\Component\DatagridBundle\DependencyInjection; -use Rollerworks\Component\Datagrid\Twig\Extension\DatagridExtension as TwigDatagridExtension; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/src/Extension/Symfony/DependencyInjectionExtension.php b/src/Extension/Symfony/DependencyInjectionExtension.php index a60e744..d81f402 100644 --- a/src/Extension/Symfony/DependencyInjectionExtension.php +++ b/src/Extension/Symfony/DependencyInjectionExtension.php @@ -1,5 +1,14 @@ + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Rollerworks\Component\DatagridBundle\Extension\Symfony; use Rollerworks\Component\Datagrid\DatagridExtensionInterface; diff --git a/src/RollerworksDatagridBundle.php b/src/RollerworksDatagridBundle.php index 2195104..80b3ac9 100644 --- a/src/RollerworksDatagridBundle.php +++ b/src/RollerworksDatagridBundle.php @@ -1,5 +1,14 @@ + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Rollerworks\Component\DatagridBundle; use Rollerworks\Component\DatagridBundle\DependencyInjection\Compiler\ExtensionPass; diff --git a/tests/DependencyInjection/Compiler/ExtensionPassTest.php b/tests/DependencyInjection/Compiler/ExtensionPassTest.php index 31e2f0e..ccc0614 100644 --- a/tests/DependencyInjection/Compiler/ExtensionPassTest.php +++ b/tests/DependencyInjection/Compiler/ExtensionPassTest.php @@ -1,5 +1,14 @@ + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Rollerworks\Component\DatagridBundle\Tests\DependencyInjection\Compiler; use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; @@ -13,12 +22,12 @@ class ExtensionPassTest extends AbstractCompilerPassTestCase public function testRegisteringOfColumnTypes() { $collectingService = new Definition(); - $collectingService->setArguments(array(null, array(), array())); + $collectingService->setArguments([null, [], []]); $this->setDefinition('rollerworks_datagrid.extension', $collectingService); $collectedService = new Definition(); - $collectedService->addTag('rollerworks_datagrid.column_type', array('alias' => 'user_id')); + $collectedService->addTag('rollerworks_datagrid.column_type', ['alias' => 'user_id']); $this->setDefinition('acme_user.datagrid.column_type.user_id', $collectedService); $this->compile(); @@ -26,19 +35,19 @@ public function testRegisteringOfColumnTypes() $collectingService = $this->container->findDefinition('rollerworks_datagrid.extension'); $this->assertNull($collectingService->getArgument(0)); - $this->assertEquals(array('user_id' => 'acme_user.datagrid.column_type.user_id'), $collectingService->getArgument(1)); + $this->assertEquals(['user_id' => 'acme_user.datagrid.column_type.user_id'], $collectingService->getArgument(1)); $this->assertCount(0, $collectingService->getArgument(2)); } public function testRegisteringOfColumnTypesExtensions() { $collectingService = new Definition(); - $collectingService->setArguments(array(null, array(), array())); + $collectingService->setArguments([null, [], []]); $this->setDefinition('rollerworks_datagrid.extension', $collectingService); $collectedService = new Definition(); - $collectedService->addTag('rollerworks_datagrid.column_extension', array('alias' => 'field')); + $collectedService->addTag('rollerworks_datagrid.column_extension', ['alias' => 'field']); $this->setDefinition('acme_user.datagrid.column_extension.field', $collectedService); $this->compile(); @@ -48,7 +57,7 @@ public function testRegisteringOfColumnTypesExtensions() $this->assertNull($collectingService->getArgument(0)); $this->assertCount(0, $collectingService->getArgument(1)); $this->assertEquals( - array('field' => array('acme_user.datagrid.column_extension.field')), + ['field' => ['acme_user.datagrid.column_extension.field']], $collectingService->getArgument(2) ); } @@ -56,14 +65,14 @@ public function testRegisteringOfColumnTypesExtensions() public function testRegisteringOfDatagridExtensions() { $extensionDefinition = new Definition(); - $extensionDefinition->setArguments(array(null, array(), array())); + $extensionDefinition->setArguments([null, [], []]); $this->setDefinition('rollerworks_datagrid.extension', $extensionDefinition); $collectingService = new Definition(); $collectingService->setArguments( - array( - array(new Reference('rollerworks_datagrid.extension')), - ) + [ + [new Reference('rollerworks_datagrid.extension')], + ] ); $this->setDefinition('rollerworks_datagrid.registry', $collectingService); @@ -78,10 +87,10 @@ public function testRegisteringOfDatagridExtensions() $this->assertEquals( $collectingService->getArgument(0), - array( + [ new Reference('rollerworks_datagrid.extension'), new Reference('rollerworks_datagrid.extension.doctrine_orm'), - ) + ] ); } diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php new file mode 100644 index 0000000..7282369 --- /dev/null +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -0,0 +1,37 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Rollerworks\Component\DatagridBundle\Tests\DependencyInjection; + +use Matthias\SymfonyConfigTest\PhpUnit\AbstractConfigurationTestCase; +use Rollerworks\Component\DatagridBundle\DependencyInjection\Configuration; + +class ConfigurationTest extends AbstractConfigurationTestCase +{ + public function testDefaultsAreValid() + { + $this->assertProcessedConfigurationEquals( + [ + [], + ], + [ + 'twig' => [ + 'themes' => ['datagrid.html.twig'], + ], + ] + ); + } + + protected function getConfiguration() + { + return new Configuration('datagrid'); + } +} diff --git a/tests/DependencyInjection/DatagridExtensionTest.php b/tests/DependencyInjection/DatagridExtensionTest.php new file mode 100644 index 0000000..9b91789 --- /dev/null +++ b/tests/DependencyInjection/DatagridExtensionTest.php @@ -0,0 +1,43 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Rollerworks\Component\DatagridBundle\Tests\DependencyInjection; + +use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; +use Rollerworks\Component\DatagridBundle\DependencyInjection\DatagridExtension; +use Symfony\Component\DependencyInjection\Definition; + +final class DatagridExtensionTest extends AbstractExtensionTestCase +{ + protected function setUp() + { + parent::setUp(); + + // Actual class is Symfony\Bundle\TwigBundle\Loader\FilesystemLoader but that is a subclass. + // and the Twig_Loader_Filesystem doesn't require any additional services. + $this->setDefinition('twig.loader.filesystem', new Definition('Twig_Loader_Filesystem')); + } + + public function testDatagridFactoryIsAccessible() + { + $this->load(); + $this->compile(); + + $this->container->get('rollerworks_datagrid.factory'); + } + + protected function getContainerExtensions() + { + return [ + new DatagridExtension(), + ]; + } +}