This repository has been archived by the owner on Dec 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
148 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -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(); | ||
|
@@ -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); | ||
|
@@ -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'), | ||
) | ||
] | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
]; | ||
} | ||
} |