-
Notifications
You must be signed in to change notification settings - Fork 0
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
11 changed files
with
424 additions
and
37 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,7 +1,6 @@ | ||
language: php | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
|
||
|
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,71 @@ | ||
# SilexManagerProvider | ||
|
||
[![Build Status](https://img.shields.io/travis/jpcercal/silex-manager-provider/master.svg?style=flat-square)](http://travis-ci.org/jpcercal/silex-manager-provider) | ||
[![Coverage Status](https://coveralls.io/repos/jpcercal/silex-manager-provider/badge.svg)](https://coveralls.io/r/jpcercal/silex-manager-provider) | ||
[![Latest Stable Version](https://img.shields.io/packagist/v/cekurte/silex-manager-provider.svg?style=flat-square)](https://packagist.org/packages/cekurte/silex-manager-provider) | ||
[![License](https://img.shields.io/packagist/l/cekurte/silex-manager-provider.svg?style=flat-square)](https://packagist.org/packages/cekurte/silex-manager-provider) | ||
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/b00b1e95-36e7-4ac7-b576-6617e89e7d9f/mini.png)](https://insight.sensiolabs.com/projects/b00b1e95-36e7-4ac7-b576-6617e89e7d9f) | ||
|
||
- A simple silex service provider that adds a Manager to register other Service Providers to increase the power of your application, **contribute with this project**! | ||
|
||
## Installation | ||
|
||
The package is available on [Packagist](http://packagist.org/packages/cekurte/silex-manager-provider). | ||
The source files is [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) compatible. | ||
Autoloading is [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md) compatible. | ||
|
||
```shell | ||
composer require cekurte/silex-manager-provider | ||
``` | ||
|
||
## Documentation | ||
|
||
To use this library you need register the [Cekurte\Silex\Manager\Provider\ManagerServiceProvider](https://github.com/jpcercal/silex-manager-provider/blob/v0.0.2/src/Provider/ManagerServiceProvider.php). See also the library Environment [cekurte/environment](http://packagist.org/packages/cekurte/environment). | ||
|
||
```php | ||
<?php | ||
|
||
use Cekurte\Environment\Environment; | ||
use Cekurte\Silex\Manager\Provider\ManagerServiceProvider; | ||
|
||
// ... | ||
$app['cekurte.manager.providers'] = [ | ||
// ... | ||
'Silex\Provider\SessionServiceProvider' => [ | ||
'register' => true, | ||
], | ||
'Silex\Provider\SwiftmailerServiceProvider' => [ | ||
'register' => true, | ||
'type' => 'array', | ||
'src' => [ | ||
'swiftmailer.use_spool' => Environment::get('SWIFTMAILER_USE_SPOOL'), | ||
'swiftmailer.options' => [ | ||
'host' => Environment::get('SMTP_HOST'), | ||
'port' => Environment::get('SMTP_PORT'), | ||
'username' => Environment::get('SMTP_USERNAME'), | ||
'password' => Environment::get('SMTP_PASSWORD'), | ||
'encryption' => Environment::get('SMTP_ENCRYPTION'), | ||
'auth_mode' => Environment::get('SMTP_AUTH_MODE'), | ||
], | ||
], | ||
], | ||
// ... | ||
]; | ||
|
||
$app->register(new ManagerServiceProvider()); | ||
|
||
// ... | ||
``` | ||
|
||
If you liked of this library, give me a *star* **=)**. | ||
|
||
Contributing | ||
------------ | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Make your changes | ||
4. Run the tests, adding new ones for your own code if necessary (`vendor/bin/phpunit`) | ||
5. Commit your changes (`git commit -am 'Added some feature'`) | ||
6. Push to the branch (`git push origin my-new-feature`) | ||
7. Create new Pull Request |
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
File renamed without changes.
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
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,126 @@ | ||
<?php | ||
|
||
namespace Cekurte\Silex\Translation\Test\Provider; | ||
|
||
use Cekurte\Silex\Manager\Provider\ManagerServiceProvider; | ||
use Cekurte\Tdd\ReflectionTestCase; | ||
use Silex\Application; | ||
|
||
class ManagerServiceProviderTest extends ReflectionTestCase | ||
{ | ||
public function testImplementsServiceProviderInterface() | ||
{ | ||
$reflection = new \ReflectionClass( | ||
'\\Cekurte\\Silex\\Manager\\Provider\\ManagerServiceProvider' | ||
); | ||
|
||
$this->assertTrue($reflection->implementsInterface( | ||
'\\Silex\\ServiceProviderInterface' | ||
)); | ||
} | ||
|
||
public function testRegisterNotIssetServiceProviders() | ||
{ | ||
$app = new Application(); | ||
|
||
$app->register(new ManagerServiceProvider()); | ||
} | ||
|
||
public function testRegisterEmptyServiceProviders() | ||
{ | ||
$app = new Application(); | ||
|
||
$app['cekurte.manager.providers'] = []; | ||
|
||
$app->register(new ManagerServiceProvider()); | ||
} | ||
|
||
public function testRegisterServiceProvidersWithRegisterNotIsset() | ||
{ | ||
$app = new Application(); | ||
|
||
$app['cekurte.manager.providers'] = [ | ||
'Silex\Provider\HttpFragmentServiceProvider' | ||
]; | ||
|
||
$app->register(new ManagerServiceProvider()); | ||
|
||
$app->boot(); | ||
|
||
$this->assertFalse(isset($app['fragment.path'])); | ||
} | ||
|
||
public function testRegisterServiceProvidersWithRegisterWithInvalidValue() | ||
{ | ||
$app = new Application(); | ||
|
||
$app['cekurte.manager.providers'] = [ | ||
'Silex\Provider\HttpFragmentServiceProvider' => [ | ||
'register' => 'invalid-value' | ||
], | ||
]; | ||
|
||
$app->register(new ManagerServiceProvider()); | ||
|
||
$app->boot(); | ||
|
||
$this->assertFalse(isset($app['fragment.path'])); | ||
} | ||
|
||
public function testRegisterServiceProvidersWithRegisterWithValidValue() | ||
{ | ||
$app = new Application(); | ||
|
||
$app['cekurte.manager.providers'] = [ | ||
'Silex\Provider\HttpFragmentServiceProvider' => [ | ||
'register' => true | ||
], | ||
]; | ||
|
||
$app->register(new ManagerServiceProvider()); | ||
|
||
$app->boot(); | ||
|
||
$this->assertTrue(isset($app['fragment.path'])); | ||
} | ||
|
||
public function testRegisterServiceProvidersWithRegisterWithValidValueAndParameters() | ||
{ | ||
$app = new Application(); | ||
|
||
$app['cekurte.manager.providers'] = [ | ||
'Silex\Provider\HttpFragmentServiceProvider' => [ | ||
'register' => true, | ||
'type' => 'array', | ||
'src' => [ | ||
'fragment.path' => 'fake' | ||
] | ||
], | ||
]; | ||
|
||
$app->register(new ManagerServiceProvider()); | ||
|
||
$app->boot(); | ||
|
||
$this->assertEquals('fake', $app['fragment.path']); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testRegisterServiceProvidersWithRegisterWithValidValueAndParametersWithTypeError() | ||
{ | ||
$app = new Application(); | ||
|
||
$app['cekurte.manager.providers'] = [ | ||
'Silex\Provider\HttpFragmentServiceProvider' => [ | ||
'register' => true, | ||
'type' => 'invalid-value', | ||
], | ||
]; | ||
|
||
$app->register(new ManagerServiceProvider()); | ||
|
||
$app->boot(); | ||
} | ||
} |
Oops, something went wrong.