Completed
Push — master ( 650d31...1f25f1 )
by AJ
02:01
created

SubdomainMiddlewareTest::testInvoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 2
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;
0 ignored issues
show
Unused Code introduced by
The property $subdomainMiddleware is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
26
    
27
    /**
28
     * @return void
29
     */
30
    public function setUp()
31
    {
32
        parent::setUp();
33
        Configure::write('Multidimensional/Subdomains.Subdomains', ['admin']);
34
        $this->SubdomainMiddleware = new SubdomainMiddleware();
0 ignored issues
show
Bug introduced by
The property SubdomainMiddleware does not seem to exist. Did you mean subdomainMiddleware?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
35
        $this->useHttpServer(true);
36
    }
37
    
38
    /**
39
     * @return void
40
     */
41
    public function tearDown()
42
    {
43
        parent::tearDown();
44
        Configure::delete('Multidimensional/Subdomains.Subdomains');
45
        unset($this->SubdomainMiddleware);
46
    }
47
48
    /**
49
     * @return void
50
     */
51
    public function testGetSubdomains()
52
    {
53
        $subdomains = $this->SubdomainMiddleware->getSubdomains();
0 ignored issues
show
Bug introduced by
The property SubdomainMiddleware does not seem to exist. Did you mean subdomainMiddleware?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
54
        $this->assertEquals($subdomains, ['admin']);
55
    }
56
57
    /**
58
     * @return void
59
     */
60
    public function testGetPrefixAndHost()
61
    {
62
        $array = $this->SubdomainMiddleware->getPrefixAndHost('admin.example.com');
0 ignored issues
show
Bug introduced by
The property SubdomainMiddleware does not seem to exist. Did you mean subdomainMiddleware?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
63
        $this->assertEquals($array, ['admin', 'example.com']);
64
        unset($array);
65
        $array = $this->SubdomainMiddleware->getPrefixAndHost('subdomain.example.com');
0 ignored issues
show
Bug introduced by
The property SubdomainMiddleware does not seem to exist. Did you mean subdomainMiddleware?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
66
        $this->assertEquals($array, [false, 'example.com']);
67
        unset($array);
68
        $array = $this->SubdomainMiddleware->getPrefixAndHost('example.com');
0 ignored issues
show
Bug introduced by
The property SubdomainMiddleware does not seem to exist. Did you mean subdomainMiddleware?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
69
        $this->assertEquals($array, [false, 'example.com']);
70
    }
71
72
    /**
73
     * @return void
74
     */
75
    public function testInvoke() {
76
        $this->markTestIncomplete('Not implemented yet.');
77
        /*$this->configRequest(['uri' => ['_host' => 'admin.example.com']]);
78
        $request = $this->getMockBuilder('Psr\Http\Message\ServerRequestInterface')->getMock();
79
        $response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
80
        $this->SubdomainMiddleware->__invoke($request, $resposne, $name);*/
81
    }
82
   
83
}
84