Code Duplication    Length = 18-18 lines in 3 locations

tests/Vectorface/SnappyRouterTests/SnappyRouterTest.php 3 locations

@@ 147-164 (lines=18) @@
144
    /**
145
     * Tests that the CLI routing functionality works.
146
     */
147
    public function testStandardCliRoute()
148
    {
149
        $config = $this->getStandardConfig();
150
        $router = new SnappyRouter(new Config($config));
151
152
        $_SERVER['argv'] = array(
153
            'dummyScript.php',
154
            '--task',
155
            'TestTask',
156
            '--action',
157
            'testMethod'
158
        );
159
        $_SERVER['argc'] = count($_SERVER['argv']);
160
        $response = $router->handleRoute();
161
162
        $expected = 'Hello World'.PHP_EOL;
163
        $this->assertEquals($expected, $response);
164
    }
165
166
    /**
167
     * Tests a CLI route that throws an exception.
@@ 169-186 (lines=18) @@
166
    /**
167
     * Tests a CLI route that throws an exception.
168
     */
169
    public function testCliRouteWithException()
170
    {
171
        $config = $this->getStandardConfig();
172
        $router = new SnappyRouter(new Config($config));
173
174
        $_SERVER['argv'] = array(
175
            'dummyScript.php',
176
            '--task',
177
            'TestTask',
178
            '--action',
179
            'throwsException'
180
        );
181
        $_SERVER['argc'] = count($_SERVER['argv']);
182
        $response = $router->handleRoute();
183
184
        $expected = 'An exception was thrown.'.PHP_EOL;
185
        $this->assertEquals($expected, $response);
186
    }
187
188
    /**
189
     * Tests that a CLI route with no appropriate handlers throws an
@@ 192-209 (lines=18) @@
189
     * Tests that a CLI route with no appropriate handlers throws an
190
     * exception.
191
     */
192
    public function testCliRouteWithNoHandler()
193
    {
194
        $config = $this->getStandardConfig();
195
        $router = new SnappyRouter(new Config($config));
196
197
        $_SERVER['argv'] = array(
198
            'dummyScript.php',
199
            '--task',
200
            'NotDefinedTask',
201
            '--action',
202
            'anyAction'
203
        );
204
        $_SERVER['argc'] = count($_SERVER['argv']);
205
        $response = $router->handleRoute();
206
207
        $expected = 'No CLI handler registered.'.PHP_EOL;
208
        $this->assertEquals($expected, $response);
209
    }
210
}
211