-
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 #25 from cocur/silex
Added Silex service provider.
- Loading branch information
Showing
4 changed files
with
133 additions
and
2 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
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,47 @@ | ||
<?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\Silex; | ||
|
||
use Cocur\Slugify\Slugify; | ||
use Silex\Application; | ||
use Silex\ServiceProviderInterface; | ||
|
||
/** | ||
* SlugifyServiceProvider | ||
* | ||
* @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 SlugifyServiceProvider implements ServiceProviderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function register(Application $app) | ||
{ | ||
$app['slugify'] = $app->share(function ($app) { | ||
$app->flush(); | ||
|
||
return new Slugify(); | ||
}); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function boot(Application $app) | ||
{ | ||
} | ||
} |
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,61 @@ | ||
<?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\Silex; | ||
|
||
use Cocur\Slugify\Bridge\Silex\SlugifyServiceProvider; | ||
|
||
/** | ||
* SlugifyServiceProviderTest | ||
* | ||
* @category test | ||
* @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 | ||
* @group unit | ||
*/ | ||
class SlugifyServiceProviderTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var SlugifyServiceProvider */ | ||
private $provider; | ||
|
||
public function setUp() | ||
{ | ||
$this->provider = new SlugifyServiceProvider(); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers Cocur\Slugify\Bridge\Silex\SlugifyServiceProvider::boot() | ||
*/ | ||
public function boot() | ||
{ | ||
// it seems like Application is not mockable. | ||
$app = new \Silex\Application(); | ||
$this->provider->boot($app); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers Cocur\Slugify\Bridge\Silex\SlugifyServiceProvider::register() | ||
*/ | ||
public function register() | ||
{ | ||
// it seems like Application is not mockable. | ||
$app = new \Silex\Application(); | ||
$this->provider->register($app); | ||
|
||
$this->assertArrayHasKey('slugify', $app); | ||
$this->assertInstanceOf('Cocur\Slugify\Slugify', $app['slugify']); | ||
} | ||
} |