From a49bd88e715ec77355c26ac07225fc9807b3640f Mon Sep 17 00:00:00 2001 From: Tom Gregory Date: Tue, 22 Jan 2013 01:39:15 -0500 Subject: Apparently not all files were included in previous commit. --- test/CacheTest.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'test/CacheTest.php') 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 -- cgit v1.2.3