diff options
author | Tom Gregory <[email protected]> | 2013-01-22 00:23:04 -0500 |
---|---|---|
committer | Tom Gregory <[email protected]> | 2013-01-22 00:23:04 -0500 |
commit | 98b806652bab694797c0d09b41f198b7bf6f2c4c (patch) | |
tree | 077eefaaea3098418fa9eea317b87a854abd6f51 /test/CacheTest.php | |
parent | 349532a2c5b8d968f8fa7743b33b8d50d3525630 (diff) | |
parent | 6391acb3371e07742cf94c7c4bc4cc3888a6cae5 (diff) |
Merge remote-tracking branch 'upstream/develop' into dev-multi. Updated documentation to rat format, and tests to use phpunit.
(Resolved)Conflicts:
README.markdown
idiorm.php
test/test_queries.php
Diffstat (limited to 'test/CacheTest.php')
-rw-r--r-- | test/CacheTest.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/CacheTest.php b/test/CacheTest.php new file mode 100644 index 0000000..ef079aa --- /dev/null +++ b/test/CacheTest.php @@ -0,0 +1,29 @@ +<?php + +class CacheTest extends PHPUnit_Framework_TestCase { + + public function setUp() { + // Enable logging + ORM::configure('logging', true); + ORM::configure('caching', true); + + // Set up the dummy database connection + $db = new MockPDO('sqlite::memory:'); + ORM::set_db($db); + } + + public function tearDown() { + ORM::configure('logging', false); + ORM::configure('caching', false); + ORM::set_db(null); + } + + // Test caching. This is a bit of a hack. + public function testQueryGenerationOnlyOccursOnce() { + ORM::for_table('widget')->where('name', 'Fred')->where('age', 17)->find_one(); + ORM::for_table('widget')->where('name', 'Bob')->where('age', 42)->find_one(); + $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()); + } +}
\ No newline at end of file |