Skip to content

Commit

Permalink
Fixing issue where fixtures without field definitions would drop tables,
Browse files Browse the repository at this point in the history
even though they had no way to re-create them. Fixes #1519
  • Loading branch information
markstory committed Feb 9, 2011
1 parent 9a94070 commit a5fb2cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cake/tests/cases/libs/cake_test_fixture.test.php
Expand Up @@ -391,6 +391,10 @@ function testDrop() {
$this->criticDb->setReturnValueAt(1, 'execute', false); $this->criticDb->setReturnValueAt(1, 'execute', false);
$return = $Fixture->drop($this->criticDb); $return = $Fixture->drop($this->criticDb);
$this->assertFalse($return); $this->assertFalse($return);

unset($Fixture->fields);
$return = $Fixture->drop($this->criticDb);
$this->assertFalse($return);
} }


/** /**
Expand Down
3 changes: 3 additions & 0 deletions cake/tests/lib/cake_test_fixture.php
Expand Up @@ -153,6 +153,9 @@ function create(&$db) {
* @access public * @access public
*/ */
function drop(&$db) { function drop(&$db) {
if (empty($this->fields)) {
return false;
}
$this->Schema->_build(array($this->table => $this->fields)); $this->Schema->_build(array($this->table => $this->fields));
return ( return (
$db->execute($db->dropSchema($this->Schema), array('log' => false)) !== false $db->execute($db->dropSchema($this->Schema), array('log' => false)) !== false
Expand Down

0 comments on commit a5fb2cf

Please sign in to comment.