RequireHttpTest::testHttpCollection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the silex-annotation-provider package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @license       MIT License
8
 * @copyright (c) 2018, Dana Desrosiers <[email protected]>
9
 */
10
11
namespace DDesrosiers\Test\SilexAnnotations\Annotations;
12
13
use DDesrosiers\Test\SilexAnnotations\AnnotationTestBase;
14
use Symfony\Component\HttpFoundation\Request;
15
16 View Code Duplication
class RequireHttpTest extends AnnotationTestBase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    public function testHttp()
19
    {
20
        $this->assertEndPointStatus(self::GET_METHOD, "/test/requirehttp", self::STATUS_OK);
21
    }
22
23
    /**
24
     * @throws \Exception
25
     */
26
    public function testHttps()
27
    {
28
        // we make the request as https, but it should be redirected to a http request
29
        $this->registerProviders();
30
        $_SERVER['REQUEST_URI'] = '/test/requirehttp';
31
        $request = Request::create('https://test.com/test/requirehttp');
32
        $response = $this->app->handle($request);
33
        $this->assertEquals(301, $response->getStatusCode());
34
        $this->assertTrue($response->isRedirect('http://test.com/test/requirehttp'));
35
    }
36
37
    public function testHttpCollection()
38
    {
39
        $this->assertEndPointStatus(self::GET_METHOD, "/requirehttp/test", self::STATUS_OK);
40
    }
41
42
    /**
43
     * @throws \Exception
44
     */
45
    public function testHttpsCollection()
46
    {
47
        // we make the request as https, but it should be redirected to a http request
48
        $this->registerProviders();
49
        $_SERVER['REQUEST_URI'] = '/requirehttp/test';
50
        $request = Request::create('https://test.com/requirehttp/test');
51
        $response = $this->app->handle($request);
52
        $this->assertEquals(301, $response->getStatusCode());
53
        $this->assertTrue($response->isRedirect('http://test.com/requirehttp/test'));
54
    }
55
}
56