diff options
author | Simon Holywell <[email protected]> | 2013-01-23 14:24:12 +0000 |
---|---|---|
committer | Simon Holywell <[email protected]> | 2013-01-23 14:24:12 +0000 |
commit | b10aff0001e61565831cc0578d4a939619f59643 (patch) | |
tree | 577693b079608919346e30ff2425bff98b2b2e50 /test/CacheTest.php | |
parent | 07f2e634d68218b9e4edd7f5007708de1fb9553d (diff) | |
parent | a49bd88e715ec77355c26ac07225fc9807b3640f (diff) |
Merge remote-tracking branch 'tag/dev-multi' into multiple-connections
Diffstat (limited to 'test/CacheTest.php')
-rw-r--r-- | test/CacheTest.php | 22 |
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 |