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
|
|
|
|
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(); |
|
|
|
|
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(); |
|
|
|
|
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'); |
|
|
|
|
63
|
|
|
$this->assertEquals($array, ['admin', 'example.com']); |
64
|
|
|
unset($array); |
65
|
|
|
$array = $this->SubdomainMiddleware->getPrefixAndHost('subdomain.example.com'); |
|
|
|
|
66
|
|
|
$this->assertEquals($array, [false, 'example.com']); |
67
|
|
|
unset($array); |
68
|
|
|
$array = $this->SubdomainMiddleware->getPrefixAndHost('example.com'); |
|
|
|
|
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
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.