-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit tests for dependency injection
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* (c) Christian Gripp <mail@core23.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Core23\LastFmBundle\Tests\DependencyInjection; | ||
|
||
use Core23\LastFmBundle\DependencyInjection\Configuration; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Config\Definition\Processor; | ||
|
||
class ConfigurationTest extends TestCase | ||
{ | ||
public function testOptions() | ||
{ | ||
$processor = new Processor(); | ||
|
||
$config = $processor->processConfiguration(new Configuration(), array(array( | ||
'api' => array( | ||
'app_id' => 'foo_id', | ||
'shared_secret' => 'bar_secret', | ||
), | ||
))); | ||
|
||
$expected = array( | ||
'api' => array( | ||
'app_id' => 'foo_id', | ||
'shared_secret' => 'bar_secret', | ||
'endpoint' => 'http://ws.audioscrobbler.com/2.0/', | ||
'auth_url' => 'http://www.last.fm/api/auth/', | ||
), | ||
'auth_success' => array( | ||
'route' => null, | ||
'route_parameters' => array(), | ||
), | ||
'auth_error' => array( | ||
'route' => null, | ||
'route_parameters' => array(), | ||
), | ||
'http' => array( | ||
'client' => 'httplug.client.default', | ||
'message_factory' => 'httplug.message_factory.default', | ||
), | ||
); | ||
|
||
$this->assertSame($expected, $config); | ||
} | ||
} |
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,46 @@ | ||
<?php | ||
|
||
/* | ||
* (c) Christian Gripp <mail@core23.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Core23\LastFmBundle\Tests\DependencyInjection; | ||
|
||
use Core23\LastFmBundle\DependencyInjection\Core23LastFmExtension; | ||
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; | ||
|
||
class Core23LastFmExtensionTest extends AbstractExtensionTestCase | ||
{ | ||
public function testLoadDefault() | ||
{ | ||
$this->load(array( | ||
'api' => array( | ||
'app_id' => 'foo_id', | ||
'shared_secret' => 'bar_secret', | ||
), | ||
)); | ||
|
||
$this->assertContainerBuilderHasParameter('core23.lastfm.auth_success.redirect_route', null); | ||
$this->assertContainerBuilderHasParameter('core23.lastfm.auth_success.redirect_route_params', array()); | ||
$this->assertContainerBuilderHasParameter('core23.lastfm.auth_error.redirect_route', null); | ||
$this->assertContainerBuilderHasParameter('core23.lastfm.auth_error.redirect_route_params', array()); | ||
|
||
$this->assertContainerBuilderHasParameter('core23.lastfm.api.app_id', 'foo_id'); | ||
$this->assertContainerBuilderHasParameter('core23.lastfm.api.shared_secret', 'bar_secret'); | ||
$this->assertContainerBuilderHasParameter('core23.lastfm.api.endpoint', 'http://ws.audioscrobbler.com/2.0/'); | ||
$this->assertContainerBuilderHasParameter('core23.lastfm.api.auth_url', 'http://www.last.fm/api/auth/'); | ||
|
||
$this->assertContainerBuilderHasAlias('core23.lastfm.http.client', 'httplug.client.default'); | ||
$this->assertContainerBuilderHasAlias('core23.lastfm.http.message_factory', 'httplug.message_factory.default'); | ||
} | ||
|
||
protected function getContainerExtensions() | ||
{ | ||
return array( | ||
new Core23LastFmExtension(), | ||
); | ||
} | ||
} |
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