mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixed error where App::import() failed to load new class types added in 2.0. Also fixed couple of test cases.
This commit is contained in:
parent
d61ebaee5d
commit
75437b45d9
2 changed files with 10 additions and 8 deletions
|
@ -614,10 +614,10 @@ class App {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$originalType = $type = strtolower($type);
|
$originalType = strtolower($type);
|
||||||
$specialPackage = in_array($type, array('file', 'vendor'));
|
$specialPackage = in_array($originalType, array('file', 'vendor'));
|
||||||
if (!$specialPackage && isset(self::$legacy[$type . 's'])) {
|
if (!$specialPackage && isset(self::$legacy[$originalType . 's'])) {
|
||||||
$type = self::$legacy[$type . 's'];
|
$type = self::$legacy[$originalType . 's'];
|
||||||
}
|
}
|
||||||
list($plugin, $name) = pluginSplit($name);
|
list($plugin, $name) = pluginSplit($name);
|
||||||
if (!empty($plugin)) {
|
if (!empty($plugin)) {
|
||||||
|
@ -628,11 +628,11 @@ class App {
|
||||||
return self::_loadClass($name, $plugin, $type, $originalType, $parent);
|
return self::_loadClass($name, $plugin, $type, $originalType, $parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'file' && !empty($file)) {
|
if ($originalType == 'file' && !empty($file)) {
|
||||||
return self::_loadFile($name, $plugin, $search, $file, $return);
|
return self::_loadFile($name, $plugin, $search, $file, $return);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'vendor') {
|
if ($originalType == 'vendor') {
|
||||||
return self::_loadVendor($name, $plugin, $file, $ext);
|
return self::_loadVendor($name, $plugin, $file, $ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -285,9 +285,11 @@ class AppImportTest extends CakeTestCase {
|
||||||
$this->assertTrue(in_array('TestPluginPersisterOne', $result));
|
$this->assertTrue(in_array('TestPluginPersisterOne', $result));
|
||||||
|
|
||||||
$result = App::objects('TestPlugin.helper');
|
$result = App::objects('TestPlugin.helper');
|
||||||
|
sort($result);
|
||||||
$expected = array('OtherHelperHelper', 'PluggedHelper', 'TestPluginApp');
|
$expected = array('OtherHelperHelper', 'PluggedHelper', 'TestPluginApp');
|
||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($result, $expected);
|
||||||
$result = App::objects('TestPlugin.View/Helper');
|
$result = App::objects('TestPlugin.View/Helper');
|
||||||
|
sort($result);
|
||||||
$expected = array('OtherHelperHelper', 'PluggedHelper', 'TestPluginApp');
|
$expected = array('OtherHelperHelper', 'PluggedHelper', 'TestPluginApp');
|
||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($result, $expected);
|
||||||
|
|
||||||
|
@ -462,7 +464,7 @@ class AppImportTest extends CakeTestCase {
|
||||||
$result = App::import('Helper', 'TestPlugin.OtherHelper');
|
$result = App::import('Helper', 'TestPlugin.OtherHelper');
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$this->assertTrue(class_exists('OtherHelperHelper'));
|
$this->assertTrue(class_exists('OtherHelperHelper'));
|
||||||
|
|
||||||
$result = App::import('Helper', 'TestPlugin.TestPluginApp');
|
$result = App::import('Helper', 'TestPlugin.TestPluginApp');
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$this->assertTrue(class_exists('TestPluginAppHelper'));
|
$this->assertTrue(class_exists('TestPluginAppHelper'));
|
||||||
|
@ -470,7 +472,7 @@ class AppImportTest extends CakeTestCase {
|
||||||
$result = App::import('Datasource', 'TestPlugin.TestSource');
|
$result = App::import('Datasource', 'TestPlugin.TestSource');
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$this->assertTrue(class_exists('TestSource'));
|
$this->assertTrue(class_exists('TestSource'));
|
||||||
|
|
||||||
App::build();
|
App::build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue