1 | <?php |
||||
2 | |||||
3 | namespace Devmachine\Bundle\ServicesInjectorBundle\Tests\Request; |
||||
4 | |||||
5 | use Devmachine\Bundle\ServicesInjectorBundle\Request\Services; |
||||
6 | use Devmachine\Bundle\ServicesInjectorBundle\ServiceLocator\CallableServiceLocator; |
||||
7 | |||||
8 | class ServicesTest extends \PHPUnit_Framework_TestCase |
||||
9 | { |
||||
10 | /** |
||||
11 | * @test |
||||
12 | * |
||||
13 | * @expectedException \InvalidArgumentException |
||||
14 | */ |
||||
15 | public function it_throws_exception_on_missing_service() |
||||
16 | { |
||||
17 | $services = new Services([], new CallableServiceLocator(function ($id) {})); |
||||
0 ignored issues
–
show
|
|||||
18 | $services->get('twig'); |
||||
19 | } |
||||
20 | |||||
21 | /** |
||||
22 | * @test |
||||
23 | */ |
||||
24 | public function it_proxies_mapped_service_id() |
||||
25 | { |
||||
26 | $locator = $this->getMock('Devmachine\Bundle\ServicesInjectorBundle\ServiceLocator\ServiceLocator'); |
||||
27 | $locator |
||||
28 | ->expects($this->once()) |
||||
29 | ->method('get') |
||||
30 | ->with($this->equalTo('router')) |
||||
31 | ; |
||||
32 | |||||
33 | (new Services(['url_generator' => 'router'], $locator))->get('url_generator'); |
||||
34 | } |
||||
35 | |||||
36 | /** |
||||
37 | * @test |
||||
38 | * |
||||
39 | * @expectedException \InvalidArgumentException |
||||
40 | * @expectedExceptionMessage Service with alias "foo" is not registered. |
||||
41 | */ |
||||
42 | public function it_throws_exception_on_aliased_method_call_with_invalid_service() |
||||
43 | { |
||||
44 | $services = new Services([], new CallableServiceLocator(function ($id) {})); |
||||
0 ignored issues
–
show
The parameter
$id is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
45 | $services->getFoo(); |
||||
0 ignored issues
–
show
The method
getFoo() does not exist on Devmachine\Bundle\Servic...Bundle\Request\Services . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
46 | } |
||||
47 | |||||
48 | /** |
||||
49 | * @test |
||||
50 | */ |
||||
51 | public function it_maps_method_call_service_retrieval() |
||||
52 | { |
||||
53 | $ids = []; |
||||
54 | $map = ['url_generator' => 'router', 'template' => 'twig']; |
||||
55 | |||||
56 | $services = new Services($map, new CallableServiceLocator(function ($id) use (&$ids) { $ids[] = $id; })); |
||||
57 | $services->getUrlGenerator(); |
||||
0 ignored issues
–
show
The method
getUrlGenerator() does not exist on Devmachine\Bundle\Servic...Bundle\Request\Services . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
58 | $services->getTemplate(); |
||||
0 ignored issues
–
show
The method
getTemplate() does not exist on Devmachine\Bundle\Servic...Bundle\Request\Services . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
59 | |||||
60 | $this->assertSame(['router', 'twig'], $ids); |
||||
61 | } |
||||
62 | } |
||||
63 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.