1 | <?php |
||
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->assertEquals($subdomains, array_merge($this->defaultSubdomains, ['admin']); |
||
|
|||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @return void |
||
62 | */ |
||
63 | public function testGetPrefixAndHost() |
||
64 | { |
||
65 | $array = $this->subdomainMiddleware->getPrefixAndHost('admin.example.com'); |
||
66 | $this->assertEquals($array, ['admin', 'example.com']); |
||
67 | $array = $this->subdomainMiddleware->getPrefixAndHost('subdomain.example.com'); |
||
68 | $this->assertEquals($array, [false, 'example.com']); |
||
69 | $array = $this->subdomainMiddleware->getPrefixAndHost('example.com'); |
||
70 | $this->assertEquals($array, [false, 'example.com']); |
||
71 | $array = $this->subdomainMiddleware->getPrefixAndHost('www.example.com'); |
||
72 | $this->assertEquals($array, ['www', 'example.com']); |
||
73 | $array = $this->subdomainMiddleware->getPrefixAndHost('false.example.com'); |
||
74 | $this->assertEquals($array, ['false', 'example.com']); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @return void |
||
79 | */ |
||
80 | public function testInvoke() |
||
81 | { |
||
82 | $this->markTestIncomplete('Not implemented yet.'); |
||
83 | /*$this->configRequest(['uri' => ['_host' => 'admin.example.com']]); |
||
84 | $request = $this->getMockBuilder('Psr\Http\Message\ServerRequestInterface')->getMock(); |
||
89 |