Upgrade CakePHP from 2.2.5 to 2.9.5

This commit is contained in:
Brm Ko 2017-02-26 15:29:44 +01:00
parent 5a580df460
commit 235a541597
793 changed files with 60746 additions and 23753 deletions

View file

@ -2,19 +2,18 @@
/**
* FixtureTask Test case
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Test.Case.Console.Command.Task
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('ShellDispatcher', 'Console');
@ -43,7 +42,7 @@ class FixtureTaskTest extends CakeTestCase {
/**
* Whether backup global state for each test method or not
*
* @var bool false
* @var bool
*/
public $backupGlobals = false;
@ -99,6 +98,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testImportOptionsSchemaRecords() {
$this->Task->interactive = true;
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y'));
@ -113,6 +113,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testImportOptionsNothing() {
$this->Task->interactive = true;
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n'));
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('n'));
$this->Task->expects($this->at(2))->method('in')->will($this->returnValue('n'));
@ -122,12 +123,70 @@ class FixtureTaskTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
/**
* test importOptions with overwriting command line options.
*
* @return void
*/
public function testImportOptionsWithCommandLineOptions() {
$this->Task->params = array('schema' => true, 'records' => true);
$result = $this->Task->importOptions('Article');
$expected = array('schema' => 'Article', 'fromTable' => true);
$this->assertEquals($expected, $result);
}
/**
* test importOptions with overwriting CLI options
*
* @return void
*/
public function testImportOptionsWithCommandLineOptionsPlugin() {
$this->Task->params = array('schema' => true, 'records' => true, 'plugin' => 'TestPlugin');
$result = $this->Task->importOptions('Article');
$expected = array('schema' => 'TestPlugin.Article', 'fromTable' => true);
$this->assertEquals($expected, $result);
}
/**
* test importOptions with schema.
*
* @return void
*/
public function testImportOptionsWithSchema() {
$this->Task->interactive = true;
$this->Task->params = array('schema' => true);
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n'));
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('n'));
$result = $this->Task->importOptions('Article');
$expected = array('schema' => 'Article');
$this->assertEquals($expected, $result);
}
/**
* test importOptions with records.
*
* @return void
*/
public function testImportOptionsWithRecords() {
$this->Task->interactive = true;
$this->Task->params = array('records' => true);
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n'));
$result = $this->Task->importOptions('Article');
$expected = array('fromTable' => true);
$this->assertEquals($expected, $result);
}
/**
* test importOptions choosing from Table.
*
* @return void
*/
public function testImportOptionsTable() {
$this->Task->interactive = true;
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n'));
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('n'));
$this->Task->expects($this->at(2))->method('in')->will($this->returnValue('y'));
@ -145,6 +204,9 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->interactive = true;
$this->Task->expects($this->at(0))->method('in')
->will($this->returnValue('WHERE 1=1'));
$this->Task->expects($this->at(1))->method('in')
->with($this->anything(), $this->anything(), '3')
->will($this->returnValue('2'));
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
@ -156,9 +218,8 @@ class FixtureTaskTest extends CakeTestCase {
$this->assertContains('class ArticleFixture extends CakeTestFixture', $result);
$this->assertContains('public $records', $result);
$this->assertContains('public $import', $result);
$this->assertContains("'title' => 'First Article'", $result, 'Missing import data %s');
$this->assertContains('Second Article', $result, 'Missing import data %s');
$this->assertContains('Third Article', $result, 'Missing import data %s');
$this->assertContains("'title' => 'First Article'", $result, 'Missing import data');
$this->assertContains('Second Article', $result, 'Missing import data');
}
/**
@ -202,8 +263,63 @@ class FixtureTaskTest extends CakeTestCase {
}
/**
* test that execute passes runs bake depending with named model.
* test that execute includes import options
*
* @return void
*/
public function testExecuteWithImportSchema() {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('article');
$this->Task->params = array(
'schema' => true,
'records' => false,
);
$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->never())
->method('in');
$this->Task->expects($this->at(0))
->method('createFile')
->with($filename, $this->logicalAnd(
$this->stringContains('class ArticleFixture'),
$this->stringContains("\$import = array('model' => 'Article'")
));
$this->Task->execute();
}
/**
* test that execute includes import options
*
* @return void
*/
public function testExecuteWithImportRecords() {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('article');
$this->Task->params = array(
'schema' => true,
'records' => true,
);
$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->never())
->method('in');
$this->Task->expects($this->at(0))
->method('createFile')
->with($filename, $this->logicalAnd(
$this->stringContains('class ArticleFixture'),
$this->stringContains("\$import = array('model' => 'Article', 'connection' => 'test')")
));
$this->Task->execute();
}
/**
* test that execute passes runs bake depending with named model.
*
* @return void
*/
@ -271,6 +387,32 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->all();
}
/**
* test using all() with -schema
*
* @return void
*/
public function testAllWithSchemaImport() {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->params = array('schema' => true);
$this->Task->Model->expects($this->any())->method('listAll')
->will($this->returnValue(array('Articles', 'comments')));
$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->at(0))->method('createFile')
->with($filename, $this->stringContains('public $import = array(\'model\' => \'Article\''));
$filename = '/my/path/CommentFixture.php';
$this->Task->expects($this->at(1))->method('createFile')
->with($filename, $this->stringContains('public $import = array(\'model\' => \'Comment\''));
$this->Task->expects($this->exactly(2))->method('createFile');
$this->Task->all();
}
/**
* test interactive mode of execute
*
@ -360,9 +502,8 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expects($this->at(1))->method('createFile')
->with($filename, $this->stringContains('<?php'));
$result = $this->Task->generateFixtureFile('Article', array());
$result = $this->Task->generateFixtureFile('Article', array());
$this->Task->generateFixtureFile('Article', array());
$this->Task->generateFixtureFile('Article', array());
}
/**
@ -381,7 +522,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expects($this->at(0))->method('createFile')
->with($filename, $this->stringContains('class Article'));
$result = $this->Task->generateFixtureFile('Article', array());
$this->Task->generateFixtureFile('Article', array());
CakePlugin::unload();
}