SubdomainMiddlewareTest::tearDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 7
rs 9.4285
c 2
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/**
3
 * CakePHP Plugin : CakePHP Subdomain Routing
4
 * Copyright (c) Multidimension.al (http://multidimension.al)
5
 * Github : https://github.com/multidimension-al/cakephp-subdomains
6
 *
7
 * Licensed under The MIT License
8
 * For full copyright and license information, please see the LICENSE file
9
 * Redistributions of files must retain the above copyright notice.
10
 *
11
 * @copyright (c) Multidimension.al (http://multidimension.al)
12
 * @link      https://github.com/multidimension-al/cakephp-subdomains Github
13
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
14
 */
15
16
namespace Multidimensional\Subdomains\Tests\TestCase\Middleware;
17
18
use Cake\Core\Configure;
19
use Cake\TestSuite\IntegrationTestCase;
20
use Multidimensional\Subdomains\Middleware\SubdomainMiddleware;
21
22
class SubdomainMiddlewareTest extends IntegrationTestCase
23
{
24
25
    private $subdomainMiddleware;
26
    private $defaultSubdomains;
27
28
    /**
29
     * @return void
30
     */
31
    public function setUp()
32
    {
33
        parent::setUp();
34
        Configure::write('Multidimensional/Subdomains.Subdomains', ['admin']);
35
        $this->subdomainMiddleware = new SubdomainMiddleware();
36
        $this->defaultSubdomains = $this->subdomainMiddleware->defaultSubdomains;
37
        $this->useHttpServer(true);
38
    }
39
40
    /**
41
     * @return void
42
     */
43
    public function tearDown()
44
    {
45
        parent::tearDown();
46
        Configure::delete('Multidimensional/Subdomains.Subdomains');
47
        unset($this->subdomainMiddleware);
48
        unset($this->defaultSubdomains);
49
    }
50
51
    /**
52
     * @return void
53
     */
54
    public function testGetSubdomains()
55
    {
56
        $subdomains = $this->subdomainMiddleware->getSubdomains();
57
        $this->assertNotEmpty($subdomains);
58
        $this->assertNotEmpty($this->defaultSubdomains);
59
        $this->assertEquals($subdomains, array_merge($this->defaultSubdomains, ['admin']));
60
    }
61
62
    /**
63
     * @return void
64
     */
65
    public function testGetPrefixAndHost()
66
    {
67
        $array = $this->subdomainMiddleware->getPrefixAndHost('admin.example.com');
68
        $this->assertEquals($array, ['admin', 'example.com']);
69
        $array = $this->subdomainMiddleware->getPrefixAndHost('subdomain.example.com');
70
        $this->assertEquals($array, [false, 'example.com']);
71
        $array = $this->subdomainMiddleware->getPrefixAndHost('example.com');
72
        $this->assertEquals($array, [false, 'example.com']);
73
        $array = $this->subdomainMiddleware->getPrefixAndHost('www.example.com');
74
        $this->assertEquals($array, ['www', 'example.com']);
75
        $array = $this->subdomainMiddleware->getPrefixAndHost('false.example.com');
76
        $this->assertEquals($array, ['false', 'example.com']);
77
    }
78
79
    /**
80
     * @return void
81
     */
82
    public function testInvoke()
83
    {
84
        $this->markTestIncomplete('Not implemented yet.');
85
        /*$this->configRequest(['uri' => ['_host' => 'admin.example.com']]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
68% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
86
        $request = $this->getMockBuilder('Psr\Http\Message\ServerRequestInterface')->getMock();
87
        $response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
88
        $this->subdomainMiddleware->__invoke($request, $resposne, $name);*/
89
    }
90
}
91