From 75998ca91819528b4498ff0a5a6d131bda957050 Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 14 May 2011 18:08:11 +0200 Subject: [PATCH] using memory db tables makes tests which use a db a lot faster. a *lot* faster --- .../TestSuite/Fixture/CakeTestFixture.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php index db29124ac..59310bc70 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php @@ -145,7 +145,30 @@ class CakeTestFixture { 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 );