HummingBirdAnimeClient/tests/Ion/Di/ContainerTest.php

51 lines
1.0 KiB
PHP
Raw Normal View History

2015-09-18 22:55:40 -04:00
<?php
use Aviat\Ion\Di\Container;
use Aviat\Ion\Di\Exception\ContainerException;
class ContainerTest extends AnimeClient_TestCase {
public function setUp()
{
$this->container = new Container();
}
public function dataGetWithException()
{
return [
'Bad index type: number' => [
'id' => 42,
'exception' => 'Aviat\Ion\Di\Exception\ContainerException',
'message' => 'Id must be a string'
],
'Bad index type: array' => [
'id' => [],
'exception' => 'Aviat\Ion\Di\Exception\ContainerException',
'message' => 'Id must be a string'
],
'Non-existent id' => [
'id' => 'foo',
'exception' => 'Aviat\Ion\Di\Exception\NotFoundException',
'message' => "Item 'foo' does not exist in container."
]
];
}
/**
* @dataProvider dataGetWithException
*/
public function testGetWithException($id, $exception, $message)
{
try
{
$this->container->get($id);
}
catch(ContainerException $e)
{
$this->assertInstanceOf($exception, $e);
$this->assertEquals($message, $e->getMessage());
}
}
}