mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing plugin related tests in Core package
This commit is contained in:
parent
a8122a5afe
commit
54eb934892
5 changed files with 42 additions and 27 deletions
|
@ -92,7 +92,7 @@ class App {
|
|||
'class' => array('extends' => null, 'core' => true),
|
||||
'file' => array('extends' => null, 'core' => true),
|
||||
'model' => array('extends' => 'AppModel', 'core' => false),
|
||||
'behavior' => array('extends' => 'ModelBehavior', 'core' => true),
|
||||
'behavior' => array( 'suffix' => 'Behavior', 'extends' => 'Model/ModelBehavior', 'core' => true),
|
||||
'controller' => array('suffix' => 'Controller', 'extends' => 'AppController', 'core' => true),
|
||||
'component' => array('suffix' => 'Component', 'extends' => null, 'core' => true),
|
||||
'lib' => array('extends' => null, 'core' => true),
|
||||
|
@ -643,6 +643,9 @@ class App {
|
|||
list($plugin, $name) = pluginSplit($name);
|
||||
if (!empty($plugin)) {
|
||||
$plugin = Inflector::camelize($plugin);
|
||||
if (!CakePlugin::loaded($plugin)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$specialPackage) {
|
||||
|
@ -679,10 +682,15 @@ class App {
|
|||
$suffix = self::$types[$originalType]['suffix'];
|
||||
$name .= ($suffix == $name) ? '' : $suffix;
|
||||
}
|
||||
|
||||
if ($parent && isset(self::$types[$originalType]['extends'])) {
|
||||
$extends = self::$types[$originalType]['extends'];
|
||||
App::uses($extends, $type);
|
||||
$extendType = $type;
|
||||
if (strpos($extends, '/') !== false) {
|
||||
$parts = explode('/', $extends);
|
||||
$extends = array_pop($parts);
|
||||
$extendType = implode('/', $parts);
|
||||
}
|
||||
App::uses($extends, $extendType);
|
||||
if ($plugin && in_array($originalType, array('controller', 'model'))) {
|
||||
App::uses($plugin . $extends, $plugin . '.' .$type);
|
||||
}
|
||||
|
|
|
@ -802,8 +802,8 @@ class View extends Object {
|
|||
$paths = array();
|
||||
$viewPaths = App::path('View');
|
||||
$corePaths = array_flip(App::core('View'));
|
||||
|
||||
if (!empty($plugin)) {
|
||||
$plugin = Inflector::camelize($plugin);
|
||||
$count = count($viewPaths);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (!isset($corePaths[$viewPaths[$i]])) {
|
||||
|
|
|
@ -7,6 +7,15 @@
|
|||
*/
|
||||
class AppImportTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown() {
|
||||
CakePlugin::unload();
|
||||
}
|
||||
|
||||
/**
|
||||
* testBuild method
|
||||
*
|
||||
|
@ -311,6 +320,7 @@ class AppImportTest extends CakeTestCase {
|
|||
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS),
|
||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||
));
|
||||
CakePlugin::loadAll();
|
||||
|
||||
$result = App::objects('TestPlugin.model');
|
||||
$this->assertTrue(in_array('TestPluginPost', $result));
|
||||
|
@ -361,16 +371,14 @@ class AppImportTest extends CakeTestCase {
|
|||
App::build(array(
|
||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||
));
|
||||
$path = App::pluginPath('test_plugin');
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
|
||||
$this->assertEqual($path, $expected);
|
||||
CakePlugin::loadAll();
|
||||
|
||||
$path = App::pluginPath('TestPlugin');
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'TestPlugin' . DS;
|
||||
$this->assertEqual($path, $expected);
|
||||
|
||||
$path = App::pluginPath('TestPluginTwo');
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS;
|
||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'TestPluginTwo' . DS;
|
||||
$this->assertEqual($path, $expected);
|
||||
App::build();
|
||||
}
|
||||
|
@ -438,7 +446,7 @@ class AppImportTest extends CakeTestCase {
|
|||
$file = App::import('Model', array('NonExistingPlugin.NonExistingModel'), false);
|
||||
$this->assertFalse($file);
|
||||
|
||||
if (!class_exists('AppController')) {
|
||||
if (!class_exists('AppController', false)) {
|
||||
$classes = array_flip(get_declared_classes());
|
||||
|
||||
$this->assertFalse(isset($classes['PagesController']));
|
||||
|
@ -485,6 +493,7 @@ class AppImportTest extends CakeTestCase {
|
|||
'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Lib' . DS),
|
||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||
));
|
||||
CakePlugin::loadAll();
|
||||
|
||||
$result = App::import('Controller', 'TestPlugin.Tests');
|
||||
$this->assertTrue($result);
|
||||
|
@ -662,6 +671,7 @@ class AppImportTest extends CakeTestCase {
|
|||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
|
||||
'vendors' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
|
||||
), App::RESET);
|
||||
CakePlugin::loadAll();
|
||||
|
||||
ob_start();
|
||||
$result = App::import('Vendor', 'css/TestAsset', array('ext' => 'css'));
|
||||
|
@ -718,6 +728,7 @@ class AppImportTest extends CakeTestCase {
|
|||
'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
|
||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||
), App::RESET);
|
||||
CakePlugin::loadAll();
|
||||
|
||||
$this->assertFalse(class_exists('CustomLibClass', false));
|
||||
App::uses('CustomLibClass', 'TestPlugin.Custom/Package');
|
||||
|
|
|
@ -243,18 +243,19 @@ class ConfigureTest extends CakeTestCase {
|
|||
function testLoadPlugin() {
|
||||
App::build(array('plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
|
||||
Configure::config('test', new PhpReader());
|
||||
|
||||
$result = Configure::load('test_plugin.load', 'test');
|
||||
CakePlugin::load('TestPlugin');
|
||||
$result = Configure::load('TestPlugin.load', 'test');
|
||||
$this->assertTrue($result);
|
||||
$expected = '/test_app/plugins/test_plugin/config/load.php';
|
||||
$config = Configure::read('plugin_load');
|
||||
$this->assertEqual($config, $expected);
|
||||
|
||||
$result = Configure::load('test_plugin.more.load', 'test');
|
||||
$result = Configure::load('TestPlugin.more.load', 'test');
|
||||
$this->assertTrue($result);
|
||||
$expected = '/test_app/plugins/test_plugin/config/more.load.php';
|
||||
$config = Configure::read('plugin_more_load');
|
||||
$this->assertEqual($config, $expected);
|
||||
CakePlugin::unload();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
App::uses('Object', 'Core');
|
||||
App::uses('Router', 'Routing');
|
||||
App::uses('Controller', 'Controller');
|
||||
App::uses('Model', 'Model');
|
||||
|
||||
|
@ -355,17 +356,9 @@ class ObjectTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
unset($this->object);
|
||||
}
|
||||
|
||||
/**
|
||||
* endTest
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
App::build();
|
||||
CakePlugin::unload();
|
||||
unset($this->object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -725,7 +718,7 @@ class ObjectTest extends CakeTestCase {
|
|||
App::build(array(
|
||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
|
||||
));
|
||||
App::objects('plugin', null, false);
|
||||
CakePlugin::loadAll();
|
||||
Router::reload();
|
||||
|
||||
$result = $this->object->requestAction('/test_plugin/tests/index', array('return'));
|
||||
|
@ -753,7 +746,7 @@ class ObjectTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
|
||||
App::build();
|
||||
App::objects('plugin', null, false);
|
||||
CakePlugin::unload();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -765,9 +758,11 @@ class ObjectTest extends CakeTestCase {
|
|||
App::build(array(
|
||||
'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS),
|
||||
'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS),
|
||||
'controllers' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Controller' . DS)
|
||||
'controllers' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Controller' . DS),
|
||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins'. DS)
|
||||
));
|
||||
|
||||
CakePlugin::loadAll();
|
||||
|
||||
$result = $this->object->requestAction(
|
||||
array('controller' => 'request_action', 'action' => 'test_request_action')
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue