18
18
*/
19
19
namespace Cake \Test \TestCase \Core ;
20
20
use Cake \Core \App ;
21
+ use Cake \Core \Configure ;
21
22
use Cake \Core \Plugin ;
22
23
use Cake \TestSuite \TestCase ;
23
24
@@ -38,6 +39,49 @@ public function tearDown() {
38
39
Plugin::unload ();
39
40
}
40
41
42
+ /**
43
+ * testClassname method
44
+ *
45
+ * @return void
46
+ */
47
+ public function testClassname () {
48
+ $ currentApp = Configure::read ('App.namespace ' );
49
+ Configure::write ('App.namespace ' , 'TestApp ' );
50
+
51
+ // Test core
52
+ $ this ->assertEquals ('Cake\Core\App ' , App::classname ('App ' , 'Core ' ));
53
+ $ this ->assertFalse (App::classname ('App ' , 'Core ' , 'Suffix ' ));
54
+
55
+ // Assert prefix
56
+ $ this ->assertFalse (App::classname ('Auth ' , 'Controller/Component ' ));
57
+ $ this ->assertEquals ('Cake\Controller\Component\AuthComponent ' , App::classname ('Auth ' , 'Controller/Component ' , 'Component ' ));
58
+
59
+ // Test app
60
+ $ this ->assertEquals ('TestApp\Controller\PagesController ' , App::classname ('Pages ' , 'Controller ' , 'Controller ' ));
61
+ $ this ->assertFalse (App::classname ('Unknown ' , 'Controller ' , 'Controller ' ));
62
+
63
+ // Test plugin
64
+ App::build (array (
65
+ 'Plugin ' => array (CAKE . 'Test ' . DS . 'TestApp ' . DS . 'Plugin ' . DS )
66
+ ), App::RESET );
67
+ Plugin::load ('TestPlugin ' );
68
+ $ this ->assertEquals ('TestPlugin\Utility\TestPluginEngine ' , App::classname ('TestPlugin.TestPlugin ' , 'Utility ' , 'Engine ' ));
69
+ $ this ->assertFalse (App::classname ('TestPlugin.Unknown ' , 'Utility ' ));
70
+
71
+ Plugin::unload ('TestPlugin ' );
72
+ Configure::write ('App.namespace ' , $ currentApp );
73
+ }
74
+
75
+ /**
76
+ * testClassnameUnknownPlugin method
77
+ *
78
+ * @expectedException Cake\Error\MissingPluginException
79
+ * @return void
80
+ */
81
+ public function testClassnameUnknownPlugin () {
82
+ App::classname ('UnknownPlugin.Classname ' , 'Utility ' );
83
+ }
84
+
41
85
/**
42
86
* testBuild method
43
87
*
0 commit comments