Skip to content

Commit

Permalink
using memory db tables makes tests which use a db a lot faster.
Browse files Browse the repository at this point in the history
a *lot* faster
  • Loading branch information
AD7six committed May 15, 2011
1 parent bd0a303 commit 13488fe
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/Cake/TestSuite/Fixture/CakeTestFixture.php
Expand Up @@ -145,7 +145,30 @@ public function create($db) {
return false;
}

if (empty($this->fields['tableParameters']['engine'])) {
$canUseMemory = true;
foreach($this->fields as $field => $args) {

if (is_string($args)) {
$type = $args;
} elseif (!empty($args['type'])) {
$type = $args['type'];
} else {
continue;
}

if (in_array($type, array('blob', 'text'))) {
$canUseMemory = false;
break;
}
}

if ($canUseMemory) {
$this->fields['tableParameters']['engine'] = 'MEMORY';
}
}
$this->Schema->build(array($this->table => $this->fields));

return (
$db->execute($db->createSchema($this->Schema), array('log' => false)) !== false
);
Expand Down

0 comments on commit 13488fe

Please sign in to comment.