GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ChainProcedureLoaderTest   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 156
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 156
c 0
b 0
f 0
wmc 8
lcom 1
cbo 2
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvalidArgumentExceptionIsThrownIfNoValidLoaderCanBeFound() 0 9 1
A testInstanceOfProcedureIsReturnedIfProcedureIsLoaded() 0 16 1
A testLoaderCanBeAddedToChainLoader() 0 11 1
A testInvalidArgumentExceptionIsThrownIfNoValidLoaderCanBeFoundWhenLoadingTemplate() 0 9 1
A testTemplateIsReturnedIfProcedureTemplateIsLoaded() 0 16 1
A getChainProcedureLoader() 0 6 1
A getProcedureLoader() 0 6 1
A getProcedure() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the php-phantomjs.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
namespace JonnyW\PhantomJs\Tests\Unit\Procedure;
10
11
use JonnyW\PhantomJs\Procedure\ChainProcedureLoader;
12
13
/**
14
 * PHP PhantomJs
15
 *
16
 * @author Jon Wenmoth <[email protected]>
17
 */
18
class ChainProcedureLoaderTest extends \PHPUnit_Framework_TestCase
19
{
20
21
/** +++++++++++++++++++++++++++++++++++ **/
22
/** ++++++++++++++ TESTS ++++++++++++++ **/
23
/** +++++++++++++++++++++++++++++++++++ **/
24
25
    /**
26
     * Test invalid argument exception is thrown if
27
     * not valid loader can be found.
28
     *
29
     * @access public
30
     * @return void
31
     */
32
    public function testInvalidArgumentExceptionIsThrownIfNoValidLoaderCanBeFound()
33
    {
34
        $this->setExpectedException('\InvalidArgumentException');
35
36
        $procedureLoaders = array();
37
38
        $chainProcedureLoader = $this->getChainProcedureLoader($procedureLoaders);
39
        $chainProcedureLoader->load('test');
40
    }
41
42
    /**
43
     * Test instance of procedure is returned
44
     * if procedure is loaded
45
     *
46
     * @access public
47
     * @return void
48
     */
49
    public function testInstanceOfProcedureIsReturnedIfProcedureIsLoaded()
50
    {
51
        $procedure = $this->getProcedure();
52
53
        $procedureLoader = $this->getProcedureLoader();
54
        $procedureLoader->method('load')
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<JonnyW\PhantomJs\...ocedureLoaderInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
            ->will($this->returnValue($procedure));
56
57
        $procedureLoaders = array(
58
            $procedureLoader
59
        );
60
61
        $chainProcedureLoader = $this->getChainProcedureLoader($procedureLoaders);
62
63
        $this->assertInstanceOf('\JonnyW\PhantomJs\Procedure\ProcedureInterface', $chainProcedureLoader->load('test'));
64
    }
65
66
    /**
67
     * Test loader can be added to chain
68
     * loader.
69
     *
70
     * @access public
71
     * @return void
72
     */
73
    public function testLoaderCanBeAddedToChainLoader()
74
    {
75
        $chainProcedureLoader = $this->getChainProcedureLoader(array());
76
77
        $procedureLoader =  $this->getProcedureLoader();
78
        $procedureLoader->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<JonnyW\PhantomJs\...ocedureLoaderInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
79
            ->method('load');
80
81
        $chainProcedureLoader->addLoader($procedureLoader);
82
        $chainProcedureLoader->load('test');
83
    }
84
85
    /**
86
     * Test invalid argument exception is thrown if
87
     * not valid loader can be found when loading template
88
     *
89
     * @access public
90
     * @return void
91
     */
92
    public function testInvalidArgumentExceptionIsThrownIfNoValidLoaderCanBeFoundWhenLoadingTemplate()
93
    {
94
        $this->setExpectedException('\InvalidArgumentException');
95
96
        $procedureLoaders = array();
97
98
        $chainProcedureLoader = $this->getChainProcedureLoader($procedureLoaders);
99
        $chainProcedureLoader->loadTemplate('test');
100
    }
101
102
    /**
103
     * Test template is returned if
104
     * procedure template is loaded.
105
     *
106
     * @access public
107
     * @return void
108
     */
109
    public function testTemplateIsReturnedIfProcedureTemplateIsLoaded()
110
    {
111
        $template = 'Test template';
112
113
        $procedureLoader = $this->getProcedureLoader();
114
        $procedureLoader->method('loadTemplate')
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<JonnyW\PhantomJs\...ocedureLoaderInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
115
            ->will($this->returnValue($template));
116
117
        $procedureLoaders = array(
118
            $procedureLoader
119
        );
120
121
        $chainProcedureLoader = $this->getChainProcedureLoader($procedureLoaders);
122
123
        $this->assertSame($template, $chainProcedureLoader->loadTemplate('test'));
124
    }
125
126
/** +++++++++++++++++++++++++++++++++++ **/
127
/** ++++++++++ TEST ENTITIES ++++++++++ **/
128
/** +++++++++++++++++++++++++++++++++++ **/
129
130
    /**
131
     * Get chain procedure loader instance.
132
     *
133
     * @access protected
134
     * @param  array                                            $procedureLoaders
135
     * @return \JonnyW\PhantomJs\Procedure\ChainProcedureLoader
136
     */
137
    protected function getChainProcedureLoader(array $procedureLoaders)
138
    {
139
        $chainProcedureLoader = new ChainProcedureLoader($procedureLoaders);
140
141
        return $chainProcedureLoader;
142
    }
143
144
/** +++++++++++++++++++++++++++++++++++ **/
145
/** ++++++++++ MOCKS / STUBS ++++++++++ **/
146
/** +++++++++++++++++++++++++++++++++++ **/
147
148
    /**
149
     * Get procedure loader.
150
     *
151
     * @access protected
152
     * @return \JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface
153
     */
154
    protected function getProcedureLoader()
155
    {
156
        $procedureLoader = $this->getMock('\JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface');
157
158
        return $procedureLoader;
159
    }
160
161
    /**
162
     * Get procedure.
163
     *
164
     * @access protected
165
     * @return \JonnyW\PhantomJs\Procedure\ProcedureInterface
166
     */
167
    protected function getProcedure()
168
    {
169
        $procedure = $this->getMock('\JonnyW\PhantomJs\Procedure\ProcedureInterface');
170
171
        return $procedure;
172
    }
173
}
174