/
PluginAppTest.php
113 lines (99 loc) · 3 KB
/
PluginAppTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.6.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Test\TestCase\Core;
use Cake\Console\CommandCollection;
use Cake\Core\Plugin;
use Cake\Core\PluginApp;
use Cake\Http\MiddlewareQueue;
use Cake\TestSuite\TestCase;
use Company\TestPluginThree\Plugin as TestPluginThree;
use TestPlugin\Plugin as TestPlugin;
/**
* PluginAppTest class
*/
class PluginAppTest extends TestCase
{
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
Plugin::unload();
}
/**
* testConfigForRoutesAndBootstrap
*
* @return void
*/
public function testConfigForRoutesAndBootstrap()
{
$plugin = new PluginApp([
'bootstrap' => false,
'routes' => false
]);
$this->assertFalse($plugin->isBootstrapEnabled());
$this->assertFalse($plugin->isRoutesEnabled());
}
public function testGetName()
{
$plugin = new TestPlugin();
$this->assertSame('TestPlugin', $plugin->getName());
$plugin = new TestPluginThree();
$this->assertSame('Company/TestPluginThree', $plugin->getName());
}
public function testMiddleware()
{
$plugin = new PluginApp();
$middleware = new MiddlewareQueue();
$this->assertSame($middleware, $plugin->middleware($middleware));
}
public function testConsole()
{
$plugin = new PluginApp();
$commands = new CommandCollection();
$this->assertSame($commands, $plugin->console($commands));
}
public function testConstructorArguments()
{
$plugin = new PluginApp([
'routes' => false,
'bootstrap' => false,
'console' => false,
'middleware' => false
]);
$this->assertFalse($plugin->isRoutesEnabled());
$this->assertFalse($plugin->isBootstrapEnabled());
$this->assertFalse($plugin->isConsoleEnabled());
$this->assertFalse($plugin->isMiddlewareEnabled());
}
public function testGetPathBaseClass()
{
$plugin = new PluginApp();
$expected = CAKE . 'Core' . DS;
$this->assertSame($expected, $plugin->getPath());
}
public function testGetPathOptionValue()
{
$plugin = new PluginApp(['path' => '/some/path']);
$this->assertSame('/some/path', $plugin->getPath());
}
public function testGetPathSubclass()
{
$plugin = new TestPlugin();
$this->assertSame(TEST_APP . 'Plugin/TestPlugin' . DS, $plugin->getPath());
}
}