mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch 'master' into 2.6
This commit is contained in:
commit
4c93f103c7
3 changed files with 62 additions and 17 deletions
|
@ -349,14 +349,7 @@ class MemcachedEngineTest extends CakeTestCase {
|
|||
'password' => 'password'
|
||||
);
|
||||
|
||||
$this->skipIf(
|
||||
method_exists($Memcached->getMemcached(), 'setSaslAuthData'),
|
||||
'Memcached extension is installed with SASL support'
|
||||
);
|
||||
|
||||
$this->setExpectedException(
|
||||
'CacheException', 'Memcached extension is not build with SASL support'
|
||||
);
|
||||
$this->setExpectedException('PHPUnit_Framework_Error_Warning');
|
||||
$Memcached->init($settings);
|
||||
}
|
||||
|
||||
|
@ -707,6 +700,8 @@ class MemcachedEngineTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testLongDurationEqualToZero() {
|
||||
$this->markTestSkipped('Cannot run as Memcached cannot be reflected');
|
||||
|
||||
$memcached = new TestMemcachedEngine();
|
||||
$memcached->settings['compress'] = false;
|
||||
|
||||
|
|
|
@ -17,9 +17,27 @@
|
|||
* @since CakePHP v 1.2.0.4487
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('CakePlugin', 'Core');
|
||||
App::uses('Controller', 'Controller');
|
||||
App::uses('CakeHtmlReporter', 'TestSuite/Reporter');
|
||||
App::uses('Model', 'Model');
|
||||
|
||||
/**
|
||||
* Secondary Post stub class.
|
||||
*/
|
||||
class SecondaryPost extends Model {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $useTable = 'posts';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $useDbConfig = 'secondary';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* CakeTestCaseTest
|
||||
|
@ -391,9 +409,9 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
*/
|
||||
public function testGetMockForModel() {
|
||||
App::build(array(
|
||||
'Model' => array(
|
||||
CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS
|
||||
)
|
||||
'Model' => array(
|
||||
CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS
|
||||
)
|
||||
), App::RESET);
|
||||
$Post = $this->getMockForModel('Post');
|
||||
|
||||
|
@ -408,6 +426,27 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
$this->assertInternalType('array', $Post->find('all'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getMockForModel on secondary datasources.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetMockForModelSecondaryDatasource() {
|
||||
App::build(array(
|
||||
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
|
||||
'Model/Datasource/Database' => array(
|
||||
CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS . 'Datasource' . DS . 'Database' . DS
|
||||
)
|
||||
), App::RESET);
|
||||
CakePlugin::load('TestPlugin');
|
||||
ConnectionManager::create('test_secondary', array(
|
||||
'datasource' => 'Database/TestLocalDriver'
|
||||
));
|
||||
$post = $this->getMockForModel('SecondaryPost', array('save'));
|
||||
$this->assertEquals('test_secondary', $post->useDbConfig);
|
||||
ConnectionManager::drop('test_secondary');
|
||||
}
|
||||
|
||||
/**
|
||||
* test getMockForModel() with plugin models
|
||||
*
|
||||
|
@ -415,9 +454,9 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
*/
|
||||
public function testGetMockForModelWithPlugin() {
|
||||
App::build(array(
|
||||
'Plugin' => array(
|
||||
CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS
|
||||
)
|
||||
'Plugin' => array(
|
||||
CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS
|
||||
)
|
||||
), App::RESET);
|
||||
CakePlugin::load('TestPlugin');
|
||||
$this->getMockForModel('TestPlugin.TestPluginAppModel');
|
||||
|
@ -425,6 +464,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
|
||||
$result = ClassRegistry::init('TestPlugin.TestPluginComment');
|
||||
$this->assertInstanceOf('TestPluginComment', $result);
|
||||
$this->assertEquals('test', $result->useDbConfig);
|
||||
|
||||
$TestPluginComment = $this->getMockForModel('TestPlugin.TestPluginComment', array('save'));
|
||||
|
||||
|
@ -445,7 +485,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testGetMockForModelModel() {
|
||||
$Mock = $this->getMockForModel('Model', array('save'), array('name' => 'Comment'));
|
||||
$Mock = $this->getMockForModel('Model', array('save', 'setDataSource'), array('name' => 'Comment'));
|
||||
|
||||
$result = ClassRegistry::init('Comment');
|
||||
$this->assertInstanceOf('Model', $result);
|
||||
|
|
|
@ -722,13 +722,23 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
|
||||
list($plugin, $name) = pluginSplit($model, true);
|
||||
App::uses($name, $plugin . 'Model');
|
||||
|
||||
$config = array_merge((array)$config, array('name' => $name));
|
||||
unset($config['ds']);
|
||||
|
||||
if (!class_exists($name)) {
|
||||
throw new MissingModelException(array($model));
|
||||
}
|
||||
|
||||
$mock = $this->getMock($name, $methods, array($config));
|
||||
|
||||
$availableDs = array_keys(ConnectionManager::enumConnectionObjects());
|
||||
if ($mock->useDbConfig === 'default') {
|
||||
$mock->setDataSource('test');
|
||||
}
|
||||
if ($mock->useDbConfig !== 'test' && in_array('test_' . $mock->useDbConfig, $availableDs)) {
|
||||
$mock->setDataSource('test_' . $mock->useDbConfig);
|
||||
}
|
||||
|
||||
ClassRegistry::removeObject($name);
|
||||
ClassRegistry::addObject($name, $mock);
|
||||
return $mock;
|
||||
|
|
Loading…
Reference in a new issue