Skip to content
This repository has been archived by the owner on Dec 9, 2017. It is now read-only.

Commit

Permalink
correct CS
Browse files Browse the repository at this point in the history
  • Loading branch information
sstok committed Jun 19, 2015
1 parent f0f6ab4 commit 68439b6
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 15 deletions.
13 changes: 11 additions & 2 deletions src/DependencyInjection/Compiler/ExtensionPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the RollerworksDatagrid package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* 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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the RollerworksDatagrid package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* 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;
Expand Down
10 changes: 9 additions & 1 deletion src/DependencyInjection/DatagridExtension.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<?php

/*
* This file is part of the RollerworksDatagrid package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* 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;
Expand Down
9 changes: 9 additions & 0 deletions src/Extension/Symfony/DependencyInjectionExtension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the RollerworksDatagrid package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* 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;
Expand Down
9 changes: 9 additions & 0 deletions src/RollerworksDatagridBundle.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the RollerworksDatagrid package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* 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;
Expand Down
33 changes: 21 additions & 12 deletions tests/DependencyInjection/Compiler/ExtensionPassTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the RollerworksDatagrid package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* 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;
Expand All @@ -13,32 +22,32 @@ 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();

$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();
Expand All @@ -48,22 +57,22 @@ 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)
);
}

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);
Expand All @@ -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'),
)
]
);
}

Expand Down
37 changes: 37 additions & 0 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
* This file is part of the RollerworksDatagrid package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* 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');
}
}
43 changes: 43 additions & 0 deletions tests/DependencyInjection/DatagridExtensionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
* This file is part of the RollerworksDatagrid package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* 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(),
];
}
}

0 comments on commit 68439b6

Please sign in to comment.