From 7b3ceb5a2980444647ee5ea4a6ee3179c44deb69 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 28 Sep 2011 22:57:50 -0430 Subject: [PATCH] Fixing a few failing test cases and attempting to work around php segmentation fault when running the complete test suite --- .../Console/Command/Task/FixtureTaskTest.php | 45 +++++-------------- lib/Cake/Test/Case/Model/CakeSchemaTest.php | 16 ++----- 2 files changed, 15 insertions(+), 46 deletions(-) diff --git a/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php index 8d7ed887eb9..7ffbe90496c 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php @@ -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 * @@ -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); @@ -191,6 +198,7 @@ function testImportRecordsNoEscaping() { /** * test that execute passes runs bake depending with named model. * + * * @return void */ public function testExecuteWithNamedModel() { @@ -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(); } @@ -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)) diff --git a/lib/Cake/Test/Case/Model/CakeSchemaTest.php b/lib/Cake/Test/Case/Model/CakeSchemaTest.php index 0de6c7d3d23..c61783c5f53 100644 --- a/lib/Cake/Test/Case/Model/CakeSchemaTest.php +++ b/lib/Cake/Test/Case/Model/CakeSchemaTest.php @@ -575,10 +575,7 @@ 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( @@ -586,18 +583,11 @@ public function testSchemaReadWithAppModel() { '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'); } /**