mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding tests for loading classes from the libs folder
This commit is contained in:
parent
fd84b1494d
commit
ecc6a22b3b
2 changed files with 22 additions and 2 deletions
|
@ -513,8 +513,8 @@ class App {
|
||||||
|
|
||||||
if (empty($plugin)) {
|
if (empty($plugin)) {
|
||||||
$appLibs = empty(self::$__packages['Lib']) ? APPLIBS : current(self::$__packages['Lib']);
|
$appLibs = empty(self::$__packages['Lib']) ? APPLIBS : current(self::$__packages['Lib']);
|
||||||
$paths[] = $appLibs . self::$__classMap[$className] . DS;
|
$paths[] = $appLibs . $package . DS;
|
||||||
$paths[] = LIBS . self::$__classMap[$className] . DS;
|
$paths[] = LIBS . $package . DS;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
|
|
|
@ -657,4 +657,24 @@ class AppImportTest extends CakeTestCase {
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$this->assertEqual($text, 'This is the welcome.php file in test_plugin/vendors directory');
|
$this->assertEqual($text, 'This is the welcome.php file in test_plugin/vendors directory');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that the automatic class loader will also find in "libs" folder for both
|
||||||
|
* app and plugins if it does not find the class in other configured paths
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testLoadClassInLibs() {
|
||||||
|
App::build(array(
|
||||||
|
'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
|
||||||
|
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||||
|
), true);
|
||||||
|
|
||||||
|
$this->assertFalse(class_exists('CustomLibClass', false));
|
||||||
|
App::uses('CustomLibClass', 'TestPlugin.Custom/Package');
|
||||||
|
$this->assertTrue(class_exists('CustomLibClass'));
|
||||||
|
|
||||||
|
$this->assertFalse(class_exists('TestUtilityClass', false));
|
||||||
|
App::uses('TestUtilityClass', 'Utility');
|
||||||
|
$this->assertTrue(class_exists('CustomLibClass'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue