summaryrefslogtreecommitdiff
path: root/test/CacheTest.php
diff options
context:
space:
mode:
authorTom Gregory <[email protected]>2013-01-22 01:39:15 -0500
committerTom Gregory <[email protected]>2013-01-22 01:39:15 -0500
commita49bd88e715ec77355c26ac07225fc9807b3640f (patch)
tree35cb47ff821f2ab1b5883e04c56b605f3a269b51 /test/CacheTest.php
parent98b806652bab694797c0d09b41f198b7bf6f2c4c (diff)
Apparently not all files were included in previous commit.
Diffstat (limited to 'test/CacheTest.php')
-rw-r--r--test/CacheTest.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/test/CacheTest.php b/test/CacheTest.php
index ef079aa..4d9e778 100644
--- a/test/CacheTest.php
+++ b/test/CacheTest.php
@@ -2,20 +2,27 @@
class CacheTest extends PHPUnit_Framework_TestCase {
+ const ALTERNATE = 'alternate'; // Used as name of alternate connection
+
public function setUp() {
+ // Set up the dummy database connections
+ ORM::set_db(new MockPDO('sqlite::memory:'));
+ ORM::set_db(new MockDifferentPDO('sqlite::memory:'), self::ALTERNATE);
+
// Enable logging
ORM::configure('logging', true);
+ ORM::configure('logging', true, self::ALTERNATE);
ORM::configure('caching', true);
-
- // Set up the dummy database connection
- $db = new MockPDO('sqlite::memory:');
- ORM::set_db($db);
+ ORM::configure('caching', true, self::ALTERNATE);
}
public function tearDown() {
ORM::configure('logging', false);
+ ORM::configure('logging', false, self::ALTERNATE);
ORM::configure('caching', false);
+ ORM::configure('caching', false, self::ALTERNATE);
ORM::set_db(null);
+ ORM::set_db(null, self::ALTERNATE);
}
// Test caching. This is a bit of a hack.
@@ -25,5 +32,12 @@ class CacheTest extends PHPUnit_Framework_TestCase {
$expected = ORM::get_last_query();
ORM::for_table('widget')->where('name', 'Fred')->where('age', 17)->find_one(); // this shouldn't run a query!
$this->assertEquals($expected, ORM::get_last_query());
+
+ // Test caching with multiple connections (also a bit of a hack)
+ ORM::for_table('widget', self::ALTERNATE)->where('name', 'Steve')->where('age', 80)->find_one();
+ ORM::for_table('widget', self::ALTERNATE)->where('name', 'Tom')->where('age', 120)->find_one();
+ $expectedToo = ORM::get_last_query();
+ ORM::for_table('widget', self::ALTERNATE)->where('name', 'Steve')->where('age', 80)->find_one(); // this shouldn't run a query!
+ $this->assertEquals($expectedToo, ORM::get_last_query(self::ALTERNATE));
}
} \ No newline at end of file