These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * phpDocumentor |
||
4 | * |
||
5 | * PHP Version 5.3 |
||
6 | * |
||
7 | * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
||
8 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
9 | * @link http://phpdoc.org |
||
10 | */ |
||
11 | |||
12 | namespace phpDocumentor\Plugin\Scrybe\Template; |
||
13 | |||
14 | use Mockery as m; |
||
15 | |||
16 | /** |
||
17 | * Test for the Template\Factory class of phpDocumentor Scrybe. |
||
18 | */ |
||
19 | class FactoryTest extends \Mockery\Adapter\Phpunit\MockeryTestCase |
||
20 | { |
||
21 | /** |
||
22 | * Tests whether a Template can be registered using the constructor. |
||
23 | * |
||
24 | * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::__construct |
||
25 | */ |
||
26 | public function testRegisterTemplateEngineViaConstructor() |
||
27 | { |
||
28 | $factory = new Factory( |
||
29 | ['Mock' => m::mock('\phpDocumentor\Plugin\Scrybe\Template\Mock\Template')] |
||
0 ignored issues
–
show
|
|||
30 | ); |
||
31 | |||
32 | $this->assertInstanceOf( |
||
33 | '\phpDocumentor\Plugin\Scrybe\Template\Mock\Template', |
||
34 | $factory->get('Mock') |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Tests whether a Template could be registered using the register method. |
||
40 | * |
||
41 | * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::register |
||
42 | */ |
||
43 | public function testRegisterTemplateEngine() |
||
44 | { |
||
45 | $factory = new Factory(); |
||
46 | $factory->register('Mock', m::mock('\phpDocumentor\Plugin\Scrybe\Template\Mock\Template')); |
||
47 | $this->assertInstanceOf( |
||
48 | '\phpDocumentor\Plugin\Scrybe\Template\Mock\Template', |
||
49 | $factory->get('Mock') |
||
50 | ); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::register |
||
55 | * @expectedException \InvalidArgumentException |
||
56 | */ |
||
57 | public function testRegisterInvalidName() |
||
58 | { |
||
59 | $factory = new Factory(); |
||
60 | $factory->register('', m::mock('\phpDocumentor\Plugin\Scrybe\Template\Mock\Template')); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::get |
||
65 | * @expectedException \InvalidArgumentException |
||
66 | */ |
||
67 | public function testGetUnknownTemplateEngine() |
||
68 | { |
||
69 | $factory = new Factory(); |
||
70 | $factory->get('Mock'); |
||
71 | } |
||
72 | } |
||
73 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: