-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from cocur/bundle
Add Symfony2 service
- Loading branch information
Showing
6 changed files
with
181 additions
and
1 deletion.
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
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
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,40 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of cocur/slugify. | ||
* | ||
* (c) Florian Eckerstorfer <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Cocur\Slugify\Bridge\Bundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* CourSlugifyBundle | ||
* | ||
* @package cocur/slugify | ||
* @subpackage bridge | ||
* @author Florian Eckerstorfer <[email protected]> | ||
* @copyright 2012-2014 Florian Eckerstorfer | ||
* @license http://www.opensource.org/licenses/MIT The MIT License | ||
*/ | ||
class CocurSlugifyBundle extends Bundle | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function build(ContainerBuilder $container) | ||
{ | ||
parent::build($container); | ||
|
||
$extension = new CocurSlugifyExtension(); | ||
$extension->load(array(), $container); | ||
|
||
$container->registerExtension($extension); | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of cocur/slugify. | ||
* | ||
* (c) Florian Eckerstorfer <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Cocur\Slugify\Bridge\Bundle; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
||
/** | ||
* CocurSlugifyExtension | ||
* | ||
* @package cocur/slugify | ||
* @subpackage bridge | ||
* @author Florian Eckerstorfer <[email protected]> | ||
* @copyright 2012-2014 Florian Eckerstorfer | ||
* @license http://www.opensource.org/licenses/MIT The MIT License | ||
*/ | ||
class CocurSlugifyExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
* | ||
* @param mixed[] $configs | ||
* @param ContainerBuilder $container | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$container->setDefinition('cocur_slugify', new Definition('Cocur\Slugify\Slugify')); | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
namespace Cocur\Slugify\Bridge\Bundle; | ||
|
||
use Cocur\Slugify\Bridge\Bundle\CocurSlugifyBundle; | ||
|
||
/** | ||
* CocurSlugifyBundleTest | ||
* | ||
* @group unit | ||
*/ | ||
class CocurSlugifyBundleTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->bundle = new CocurSlugifyBundle(); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers Cocur\Slugify\Bridge\Bundle\CocurSlugifyBundle::build() | ||
*/ | ||
public function build() | ||
{ | ||
$container = $this->getMock( | ||
'Symfony\Component\DependencyInjection\ContainerBuilder', | ||
array('registerExtension') | ||
); | ||
$container->expects($this->once()) | ||
->method('registerExtension') | ||
->with($this->isInstanceOf('Cocur\Slugify\Bridge\Bundle\CocurSlugifyExtension')); | ||
|
||
$this->bundle->build($container); | ||
} | ||
} | ||
|
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,36 @@ | ||
<?php | ||
|
||
namespace Cocur\Slugify\Bridge\Bundle; | ||
|
||
use Cocur\Slugify\Bridge\Bundle\CocurSlugifyExtension; | ||
|
||
/** | ||
* CocurSlugifyExtensionTest | ||
* | ||
* @group unit | ||
*/ | ||
class CocurSlugifyExtensionTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->extension = new CocurSlugifyExtension(); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers Cocur\Slugify\Bridge\Bundle\CocurSlugifyExtension::load() | ||
*/ | ||
public function load() | ||
{ | ||
$container = $this->getMock( | ||
'Symfony\Component\DependencyInjection\ContainerBuilder', | ||
array('setDefinition') | ||
); | ||
$container->expects($this->once()) | ||
->method('setDefinition') | ||
->with('cocur_slugify', $this->isInstanceOf('Symfony\Component\DependencyInjection\Definition')); | ||
|
||
$this->extension->load(array(), $container); | ||
} | ||
} | ||
|