Skip to content

Commit

Permalink
making the fixture update work again
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Aug 20, 2012
1 parent b859660 commit 69fea43
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Core/Libs/Console/Command/InfinitasFixturesShell.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
App::import('lib', 'Libs.InfinitasAppShell');
App::uses('FixtureTask', 'Console/Command/Task');

class InfinitasFixturesShell extends AppShell {
public $uses = array();
Expand Down Expand Up @@ -66,7 +66,7 @@ public function import() {
}

private function __generateFixture($plugin, $new) {
$models = App::objects('model', App::pluginPath($plugin) . 'models', false);
$models = App::objects('Model', InfinitasPlugin::path($plugin) . 'Model', false);
$models = array_combine(range(1, count($models)), $models);

foreach($models as $k => $model) {
Expand Down
26 changes: 13 additions & 13 deletions Core/Libs/Console/Command/Task/InfinitasFixtureBakeTask.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @file
*
*
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package Infinitas.Libs.Vendors.Shells
Expand Down Expand Up @@ -46,14 +46,14 @@ public function setup($modelName = null, $new = true) {
$useTable = ClassRegistry::init($this->plugin . '.' . $modelName)->tablePrefix . ClassRegistry::init($this->plugin . '.' . $modelName)->useTable;
}
catch(Exception $e) {

}

$newFixture = $this->getNewFixture($modelName, $useTable, array());

if(!$new) {
$oldFixture = $this->getOldFixture($this->plugin, $modelName);

if(!$oldFixture) {
$this->err(sprintf('There is no fixture for %s', $modelName));
return false;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function setup($modelName = null, $new = true) {
$oldTableParams = $oldFixture['fields']['indexes'];
unset($oldFixture['fields']['indexes']);
$oldFixture['fields']['indexes'] = $oldTableParams;

$oldTableParams = $oldFixture['fields']['tableParameters'];
unset($oldFixture['fields']['tableParameters']);
$oldFixture['fields']['tableParameters'] = $oldTableParams;
Expand Down Expand Up @@ -115,7 +115,7 @@ private function __cleanupRecords($fixture, $new, $old) {
$fixture['records'][$k][$newField] = 'null';
}
}

foreach($old as $oldField) {
foreach($fixture['records'] as $k => $record) {
unset($fixture['records'][$k][$oldField]);
Expand Down Expand Up @@ -148,14 +148,14 @@ public function getNewFixture($model, $useTable = false, $importOptions = array(
if (!class_exists('CakeSchema')) {
App::import('Model', 'CakeSchema', false);
}

$table = $schema = $records = $import = $modelImport = null;
$importBits = array();

if (!$useTable) {
$useTable = Inflector::tableize($model);
}
}

else if ($useTable != Inflector::tableize($model)) {
$table = $useTable;
}
Expand Down Expand Up @@ -192,12 +192,12 @@ public function getNewFixture($model, $useTable = false, $importOptions = array(
* @return array details of the fixture (records, fields etc)
*/
public function getOldFixture($plugin, $model) {
$file = App::pluginPath($plugin) . 'tests' . DS . 'fixtures' . DS . Inflector::underscore($model) . '_fixture.php';
$file = App::pluginPath($plugin) . 'Test' . DS . 'Fixture' . DS . $model . 'Fixture.php';
if(!is_file($file)) {
return array();
}

$cakeFixture = CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'tests' . DS . 'lib' . DS . 'cake_test_fixture.php';
$cakeFixture = CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'TestSuite' . DS . 'Fixture' . DS . 'CakeTestFixture.php';
require_once $cakeFixture;
require_once $file;

Expand All @@ -213,7 +213,7 @@ public function getOldFixture($plugin, $model) {
* to cakes normal fixture writing method.
*
* @access public
*
*
* @param string $model the
* @param array $options the data for the fixture
*
Expand All @@ -227,7 +227,7 @@ public function generateFixtureFile($model, $options) {
$options['fields'] = implode("\n", $options['fields']);

$options['schema'] = $options['fields'];

$options['records'] = explode("\n", $this->_makeRecordString($options['records']));
foreach($options['records'] as $k => $line) {
$options['records'][$k] = "\t" . $options['records'][$k];
Expand Down

0 comments on commit 69fea43

Please sign in to comment.