mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding proper -plugin parameter handling
Fixtures can now be baked into plugins. Adding test cases.
This commit is contained in:
parent
d312cd3215
commit
84a496083f
2 changed files with 22 additions and 9 deletions
|
@ -61,7 +61,8 @@ class FixtureTask extends Shell {
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function initialize() {
|
function __construct(&$dispatch) {
|
||||||
|
parent::__construct($dispatch);
|
||||||
$this->path = $this->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
|
$this->path = $this->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
|
||||||
if (!class_exists('CakeSchema')) {
|
if (!class_exists('CakeSchema')) {
|
||||||
App::import('Model', 'Schema');
|
App::import('Model', 'Schema');
|
||||||
|
@ -211,11 +212,9 @@ class FixtureTask extends Shell {
|
||||||
$defaults = array('table' => null, 'schema' => null, 'records' => null, 'import' => null, 'fields' => null);
|
$defaults = array('table' => null, 'schema' => null, 'records' => null, 'import' => null, 'fields' => null);
|
||||||
$vars = array_merge($defaults, $otherVars);
|
$vars = array_merge($defaults, $otherVars);
|
||||||
|
|
||||||
//@todo fix plugin pathing.
|
|
||||||
$path = $this->path;
|
$path = $this->path;
|
||||||
if (isset($this->plugin)) {
|
if (isset($this->plugin)) {
|
||||||
$pluginPath = 'plugins' . DS . Inflector::underscore($this->plugin) . DS;
|
$path = $this->_pluginPath($this->plugin) . 'tests' . DS . 'fixtures' . DS;
|
||||||
$path = APP . $pluginPath . 'tests' . DS . 'fixtures' . DS;
|
|
||||||
}
|
}
|
||||||
$filename = Inflector::underscore($model) . '_fixture.php';
|
$filename = Inflector::underscore($model) . '_fixture.php';
|
||||||
|
|
||||||
|
|
|
@ -92,12 +92,12 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
function testInitialize() {
|
function testConstruct() {
|
||||||
$this->Task->params['working'] = '/my/path';
|
$this->Dispatch->params['working'] = '/my/path';
|
||||||
$this->Task->initialize();
|
$Task =& new FixtureTask($this->Dispatch);
|
||||||
|
|
||||||
$expected = '/my/path/tests/fixtures/';
|
$expected = '/my/path/tests/fixtures/';
|
||||||
$this->assertEqual($this->Task->path, $expected);
|
$this->assertEqual($Task->path, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* test import option array generation
|
* test import option array generation
|
||||||
|
@ -219,5 +219,19 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/\<\?php(.*)\?\>/ms')));
|
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/\<\?php(.*)\?\>/ms')));
|
||||||
$result = $this->Task->generateFixtureFile('Article', array());
|
$result = $this->Task->generateFixtureFile('Article', array());
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* test generating files into plugins.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testGeneratePluginFixtureFile() {
|
||||||
|
$this->Task->connection = 'test_suite';
|
||||||
|
$this->Task->path = '/my/path/';
|
||||||
|
$this->Task->plugin = 'TestFixture';
|
||||||
|
$filename = APP . 'plugins' . DS . 'test_fixture' . DS . 'tests' . DS . 'fixtures' . DS . 'article_fixture.php';
|
||||||
|
|
||||||
|
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/Article/')));
|
||||||
|
$result = $this->Task->generateFixtureFile('Article', array());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue