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),
|
'class' => array('extends' => null, 'core' => true),
|
||||||
'file' => array('extends' => null, 'core' => true),
|
'file' => array('extends' => null, 'core' => true),
|
||||||
'model' => array('extends' => 'AppModel', 'core' => false),
|
'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),
|
'controller' => array('suffix' => 'Controller', 'extends' => 'AppController', 'core' => true),
|
||||||
'component' => array('suffix' => 'Component', 'extends' => null, 'core' => true),
|
'component' => array('suffix' => 'Component', 'extends' => null, 'core' => true),
|
||||||
'lib' => array('extends' => null, 'core' => true),
|
'lib' => array('extends' => null, 'core' => true),
|
||||||
|
@ -643,6 +643,9 @@ class App {
|
||||||
list($plugin, $name) = pluginSplit($name);
|
list($plugin, $name) = pluginSplit($name);
|
||||||
if (!empty($plugin)) {
|
if (!empty($plugin)) {
|
||||||
$plugin = Inflector::camelize($plugin);
|
$plugin = Inflector::camelize($plugin);
|
||||||
|
if (!CakePlugin::loaded($plugin)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$specialPackage) {
|
if (!$specialPackage) {
|
||||||
|
@ -679,10 +682,15 @@ class App {
|
||||||
$suffix = self::$types[$originalType]['suffix'];
|
$suffix = self::$types[$originalType]['suffix'];
|
||||||
$name .= ($suffix == $name) ? '' : $suffix;
|
$name .= ($suffix == $name) ? '' : $suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($parent && isset(self::$types[$originalType]['extends'])) {
|
if ($parent && isset(self::$types[$originalType]['extends'])) {
|
||||||
$extends = 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'))) {
|
if ($plugin && in_array($originalType, array('controller', 'model'))) {
|
||||||
App::uses($plugin . $extends, $plugin . '.' .$type);
|
App::uses($plugin . $extends, $plugin . '.' .$type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -802,8 +802,8 @@ class View extends Object {
|
||||||
$paths = array();
|
$paths = array();
|
||||||
$viewPaths = App::path('View');
|
$viewPaths = App::path('View');
|
||||||
$corePaths = array_flip(App::core('View'));
|
$corePaths = array_flip(App::core('View'));
|
||||||
|
|
||||||
if (!empty($plugin)) {
|
if (!empty($plugin)) {
|
||||||
|
$plugin = Inflector::camelize($plugin);
|
||||||
$count = count($viewPaths);
|
$count = count($viewPaths);
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
if (!isset($corePaths[$viewPaths[$i]])) {
|
if (!isset($corePaths[$viewPaths[$i]])) {
|
||||||
|
|
|
@ -7,6 +7,15 @@
|
||||||
*/
|
*/
|
||||||
class AppImportTest extends CakeTestCase {
|
class AppImportTest extends CakeTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tearDown method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function tearDown() {
|
||||||
|
CakePlugin::unload();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testBuild method
|
* testBuild method
|
||||||
*
|
*
|
||||||
|
@ -311,6 +320,7 @@ class AppImportTest extends CakeTestCase {
|
||||||
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS),
|
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS),
|
||||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||||
));
|
));
|
||||||
|
CakePlugin::loadAll();
|
||||||
|
|
||||||
$result = App::objects('TestPlugin.model');
|
$result = App::objects('TestPlugin.model');
|
||||||
$this->assertTrue(in_array('TestPluginPost', $result));
|
$this->assertTrue(in_array('TestPluginPost', $result));
|
||||||
|
@ -361,16 +371,14 @@ class AppImportTest extends CakeTestCase {
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||||
));
|
));
|
||||||
$path = App::pluginPath('test_plugin');
|
CakePlugin::loadAll();
|
||||||
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
|
|
||||||
$this->assertEqual($path, $expected);
|
|
||||||
|
|
||||||
$path = App::pluginPath('TestPlugin');
|
$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);
|
$this->assertEqual($path, $expected);
|
||||||
|
|
||||||
$path = App::pluginPath('TestPluginTwo');
|
$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);
|
$this->assertEqual($path, $expected);
|
||||||
App::build();
|
App::build();
|
||||||
}
|
}
|
||||||
|
@ -438,7 +446,7 @@ class AppImportTest extends CakeTestCase {
|
||||||
$file = App::import('Model', array('NonExistingPlugin.NonExistingModel'), false);
|
$file = App::import('Model', array('NonExistingPlugin.NonExistingModel'), false);
|
||||||
$this->assertFalse($file);
|
$this->assertFalse($file);
|
||||||
|
|
||||||
if (!class_exists('AppController')) {
|
if (!class_exists('AppController', false)) {
|
||||||
$classes = array_flip(get_declared_classes());
|
$classes = array_flip(get_declared_classes());
|
||||||
|
|
||||||
$this->assertFalse(isset($classes['PagesController']));
|
$this->assertFalse(isset($classes['PagesController']));
|
||||||
|
@ -485,6 +493,7 @@ class AppImportTest extends CakeTestCase {
|
||||||
'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Lib' . DS),
|
'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Lib' . DS),
|
||||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||||
));
|
));
|
||||||
|
CakePlugin::loadAll();
|
||||||
|
|
||||||
$result = App::import('Controller', 'TestPlugin.Tests');
|
$result = App::import('Controller', 'TestPlugin.Tests');
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@ -662,6 +671,7 @@ class AppImportTest extends CakeTestCase {
|
||||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
|
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
|
||||||
'vendors' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
|
'vendors' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
|
||||||
), App::RESET);
|
), App::RESET);
|
||||||
|
CakePlugin::loadAll();
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$result = App::import('Vendor', 'css/TestAsset', array('ext' => 'css'));
|
$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),
|
'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
|
||||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||||
), App::RESET);
|
), App::RESET);
|
||||||
|
CakePlugin::loadAll();
|
||||||
|
|
||||||
$this->assertFalse(class_exists('CustomLibClass', false));
|
$this->assertFalse(class_exists('CustomLibClass', false));
|
||||||
App::uses('CustomLibClass', 'TestPlugin.Custom/Package');
|
App::uses('CustomLibClass', 'TestPlugin.Custom/Package');
|
||||||
|
|
|
@ -243,18 +243,19 @@ class ConfigureTest extends CakeTestCase {
|
||||||
function testLoadPlugin() {
|
function testLoadPlugin() {
|
||||||
App::build(array('plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
|
App::build(array('plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
|
||||||
Configure::config('test', new PhpReader());
|
Configure::config('test', new PhpReader());
|
||||||
|
CakePlugin::load('TestPlugin');
|
||||||
$result = Configure::load('test_plugin.load', 'test');
|
$result = Configure::load('TestPlugin.load', 'test');
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$expected = '/test_app/plugins/test_plugin/config/load.php';
|
$expected = '/test_app/plugins/test_plugin/config/load.php';
|
||||||
$config = Configure::read('plugin_load');
|
$config = Configure::read('plugin_load');
|
||||||
$this->assertEqual($config, $expected);
|
$this->assertEqual($config, $expected);
|
||||||
|
|
||||||
$result = Configure::load('test_plugin.more.load', 'test');
|
$result = Configure::load('TestPlugin.more.load', 'test');
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$expected = '/test_app/plugins/test_plugin/config/more.load.php';
|
$expected = '/test_app/plugins/test_plugin/config/more.load.php';
|
||||||
$config = Configure::read('plugin_more_load');
|
$config = Configure::read('plugin_more_load');
|
||||||
$this->assertEqual($config, $expected);
|
$this->assertEqual($config, $expected);
|
||||||
|
CakePlugin::unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
App::uses('Object', 'Core');
|
App::uses('Object', 'Core');
|
||||||
|
App::uses('Router', 'Routing');
|
||||||
App::uses('Controller', 'Controller');
|
App::uses('Controller', 'Controller');
|
||||||
App::uses('Model', 'Model');
|
App::uses('Model', 'Model');
|
||||||
|
|
||||||
|
@ -355,17 +356,9 @@ class ObjectTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
unset($this->object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* endTest
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function endTest() {
|
|
||||||
App::build();
|
App::build();
|
||||||
|
CakePlugin::unload();
|
||||||
|
unset($this->object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -725,7 +718,7 @@ class ObjectTest extends CakeTestCase {
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
|
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
|
||||||
));
|
));
|
||||||
App::objects('plugin', null, false);
|
CakePlugin::loadAll();
|
||||||
Router::reload();
|
Router::reload();
|
||||||
|
|
||||||
$result = $this->object->requestAction('/test_plugin/tests/index', array('return'));
|
$result = $this->object->requestAction('/test_plugin/tests/index', array('return'));
|
||||||
|
@ -753,7 +746,7 @@ class ObjectTest extends CakeTestCase {
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
App::build();
|
App::build();
|
||||||
App::objects('plugin', null, false);
|
CakePlugin::unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -765,9 +758,11 @@ class ObjectTest extends CakeTestCase {
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS),
|
'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS),
|
||||||
'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View' . 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(
|
$result = $this->object->requestAction(
|
||||||
array('controller' => 'request_action', 'action' => 'test_request_action')
|
array('controller' => 'request_action', 'action' => 'test_request_action')
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue