forked from cakephp/upgrade
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cakephp#46 from cakephp/issue-44
Fix fixture task duplicating primary key index
- Loading branch information
Showing
6 changed files
with
165 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
namespace Cake\Upgrade\Test\TestCase\Shell\Task; | ||
|
||
use Cake\TestSuite\TestCase; | ||
use Cake\Upgrade\Shell\Task\FixturesTask; | ||
use Cake\Utility\Folder; | ||
|
||
/** | ||
* FixturesTaskTest | ||
* | ||
*/ | ||
class FixturesTest extends TestCase { | ||
|
||
/** | ||
* Task instance | ||
* | ||
* @var mixed | ||
*/ | ||
public $sut; | ||
|
||
/** | ||
* setUp | ||
* | ||
* Create a mock for all tests to use | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() { | ||
parent::setUp(); | ||
|
||
$io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false); | ||
|
||
$this->sut = $this->getMock( | ||
'Cake\Upgrade\Shell\Task\FixturesTask', | ||
['in', 'out', 'hr', 'err', '_shouldProcess'], | ||
[$io] | ||
); | ||
$this->sut->loadTasks(); | ||
} | ||
|
||
/** | ||
* SkeletonTaskTest::testProcess() | ||
* | ||
* @return void | ||
*/ | ||
public function testProcess() { | ||
$this->sut->expects($this->any()) | ||
->method('_shouldProcess') | ||
->will($this->returnValue(true)); | ||
|
||
$path = TESTS . 'test_files' . DS; | ||
$result = $this->sut->process($path . 'ArticleFixture.php'); | ||
$this->assertTrue($result); | ||
|
||
$result = $this->sut->Stage->source($path . 'ArticleFixture.php'); | ||
$expected = file_get_contents($path . 'ArticleFixtureAfter.php'); | ||
$this->assertTextEquals($expected, $result); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* ArticleFixture | ||
*/ | ||
class ArticleFixture extends CakeTestFixture { | ||
|
||
/** | ||
* Fields | ||
* | ||
* @var array | ||
*/ | ||
public $fields = array( | ||
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false, 'key' => 'primary'), | ||
'title' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'), | ||
'body' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'), | ||
'created' => array('type' => 'datetime', 'null' => true, 'default' => null), | ||
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null), | ||
'indexes' => array( | ||
'PRIMARY' => array('column' => 'id', 'unique' => 1) | ||
), | ||
'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB') | ||
); | ||
|
||
/** | ||
* Records | ||
* | ||
* @var array | ||
*/ | ||
public $records = array( | ||
array( | ||
'id' => 1, | ||
'title' => 'A title', | ||
'body' => 'A body', | ||
'created' => '2014-10-09 20:34:42', | ||
'modified' => '2014-10-09 20:34:42' | ||
), | ||
); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* ArticleFixture | ||
*/ | ||
class ArticleFixture extends CakeTestFixture { | ||
|
||
/** | ||
* Fields | ||
* | ||
* @var array | ||
*/ | ||
public $fields = array( | ||
'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false], | ||
'title' => ['type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'], | ||
'body' => ['type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'], | ||
'created' => ['type' => 'datetime', 'null' => true, 'default' => null], | ||
'modified' => ['type' => 'datetime', 'null' => true, 'default' => null], | ||
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]], | ||
'_options' => ['charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB'] | ||
); | ||
|
||
/** | ||
* Records | ||
* | ||
* @var array | ||
*/ | ||
public $records = array( | ||
array( | ||
'id' => 1, | ||
'title' => 'A title', | ||
'body' => 'A body', | ||
'created' => '2014-10-09 20:34:42', | ||
'modified' => '2014-10-09 20:34:42' | ||
), | ||
); | ||
|
||
} |