Skip to content

Commit

Permalink
Fixing a few failing test cases and attempting to work around php seg…
Browse files Browse the repository at this point in the history
…mentation fault when running the complete test suite
  • Loading branch information
lorenzo committed Sep 29, 2011
1 parent 6b7c752 commit 7b3ceb5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 46 deletions.
45 changes: 12 additions & 33 deletions lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php
Expand Up @@ -39,6 +39,13 @@ class FixtureTaskTest extends CakeTestCase {
*/
public $fixtures = array('core.article', 'core.comment', 'core.datatype', 'core.binary_test', 'core.user');

/**
* Whether backup global state for each test method or not
*
* @var bool false
*/
public $backupGlobals = false;

/**
* setUp method
*
Expand All @@ -53,8 +60,8 @@ public function setUp() {
array('in', 'err', 'createFile', '_stop', 'clear'),
array($out, $out, $in)
);
$this->Task->Model = $this->getMock('Shell',
array('in', 'out', 'error', 'createFile', 'getName', 'getTable', 'listAll'),
$this->Task->Model = $this->getMock('ModelTask',
array('in', 'out', 'err', 'createFile', 'getName', 'getTable', 'listAll'),
array($out, $out, $in)
);
$this->Task->Template = new TemplateTask($out, $out, $in);
Expand Down Expand Up @@ -191,6 +198,7 @@ function testImportRecordsNoEscaping() {
/**
* test that execute passes runs bake depending with named model.
*
*
* @return void
*/
public function testExecuteWithNamedModel() {
Expand All @@ -201,36 +209,7 @@ public function testExecuteWithNamedModel() {

$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticleFixture/'));

$this->Task->execute();
}

/**
* data provider for model name variations.
*
* @return array
*/
public static function modelNameProvider() {
return array(
array('article'), array('articles'), array('Articles'), array('Article')
);
}

/**
* test that execute passes runs bake depending with named model.
*
* @dataProvider modelNameProvider
* @return void
*/
public function testExecuteWithNamedModelVariations($modelName) {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';

$this->Task->args = array($modelName);
$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->once())->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticleFixture/'));


$this->Task->execute();
}

Expand All @@ -245,7 +224,7 @@ public function testExecuteIntoAll() {
$this->Task->args = array('all');
$this->Task->Model->expects($this->any())
->method('listAll')
->will($this->returnValue(array('articles', 'comments')));
->will($this->returnValue(array('Article', 'comments')));

$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->at(0))
Expand Down
16 changes: 3 additions & 13 deletions lib/Cake/Test/Case/Model/CakeSchemaTest.php
Expand Up @@ -575,29 +575,19 @@ public function testSchemaRead() {
*/
public function testSchemaReadWithAppModel() {
$connections = ConnectionManager::enumConnectionObjects();
if (!empty($connections['default'])) {
$backup = $connections['default'];
ConnectionManager::drop('default');
}
ConnectionManager::drop('default');
ConnectionManager::create('default', $connections['test']);
try {
$read = $this->Schema->read(array(
'connection' => 'default',
'name' => 'TestApp',
'models' => array('AppModel')
));
if (!empty($backup)) {
ConnectionManager::drop('default');
ConnectionManager::create('default', $backup);
}
} catch(MissingTableException $mte) {
if (!empty($backup)) {
ConnectionManager::drop('default');
ConnectionManager::create('default', $backup);
}
ConnectionManager::drop('default');
$this->fail($mte->getMessage());
}

ConnectionManager::drop('default');
}

/**
Expand Down

0 comments on commit 7b3ceb5

Please sign in to comment.