Completed
Push — develop ( a5af85...1a2502 )
by Jaap
09:00
created

phpDocumentor/Scrybe/Template/FactoryTest.php (6 issues)

Upgrade to new PHP Analysis Engine

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-2014 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
/**
15
 * Test for the Template\Factory class of phpDocumentor Scrybe.
16
 */
17
class FactoryTest extends \PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * Tests whether a Template can be registered using the constructor.
21
     *
22
     * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::__construct
23
     */
24
    public function testRegisterTemplateEngineViaConstructor()
25
    {
26
        $factory = new Factory(
27
            array('Mock' => '\phpDocumentor\Plugin\Scrybe\Template\Mock\Template')
0 ignored issues
show
array('Mock' => '\\phpDo...plate\\Mock\\Template') is of type array<string,string,{"Mock":"string"}>, but the function expects a array<integer,object<php...ate\TemplateInterface>>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
28
        );
29
30
        $this->assertInstanceOf(
31
            '\phpDocumentor\Plugin\Scrybe\Template\Mock\Template',
32
            $factory->get('Mock')
33
        );
34
    }
35
36
    /**
37
     * Tests whether this factory registers the twig template engine by default.
38
     *
39
     * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory
40
     */
41
    public function testHasTwigTemplateEngine()
42
    {
43
        $factory = new Factory();
44
        $this->assertInstanceOf(
45
            '\phpDocumentor\Plugin\Scrybe\Template\Twig',
46
            $factory->get('twig')
47
        );
48
    }
49
50
    /**
51
     * Tests whether a Template could be registered using the register method.
52
     *
53
     * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::register
54
     */
55
    public function testRegisterTemplateEngine()
56
    {
57
        $factory = new Factory();
58
        $factory->register('Mock', '\phpDocumentor\Plugin\Scrybe\Template\Mock\Template');
0 ignored issues
show
'\\phpDocumentor\\Plugin...mplate\\Mock\\Template' is of type string, but the function expects a object<phpDocumentor\Plu...late\TemplateInterface>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
59
        $this->assertInstanceOf(
60
            '\phpDocumentor\Plugin\Scrybe\Template\Mock\Template',
61
            $factory->get('Mock')
62
        );
63
    }
64
65
    /**
66
     * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::register
67
     * @expectedException \InvalidArgumentException
68
     */
69
    public function testRegisterInvalidName()
70
    {
71
        $factory = new Factory();
72
        $factory->register(array(), '');
0 ignored issues
show
array() is of type array, but the function expects a string.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
'' is of type string, but the function expects a object<phpDocumentor\Plu...late\TemplateInterface>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
73
    }
74
75
    /**
76
     * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::register
77
     * @expectedException \InvalidArgumentException
78
     */
79
    public function testRegisterInvalidClassName()
80
    {
81
        $factory = new Factory();
82
        $factory->register('', array());
0 ignored issues
show
array() is of type array, but the function expects a object<phpDocumentor\Plu...late\TemplateInterface>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
83
    }
84
85
    /**
86
     * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::get
87
     * @expectedException \InvalidArgumentException
88
     */
89
    public function testGetUnknownTemplateEngine()
90
    {
91
        $factory = new Factory();
92
        $factory->get('Mock');
93
    }
94
95
    /**
96
     * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::get
97
     * @expectedException \RuntimeException
98
     */
99
    public function testGetInvalidTemplateEngine()
100
    {
101
        $factory = new Factory();
102
        $factory->register('Mock', '\DOMDocument');
0 ignored issues
show
'\\DOMDocument' is of type string, but the function expects a object<phpDocumentor\Plu...late\TemplateInterface>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
103
        $factory->get('Mock');
104
    }
105
}
106