summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Holywell <[email protected]>2018-01-03 17:14:25 +1000
committerSimon Holywell <[email protected]>2018-01-03 17:14:25 +1000
commit5f220f371dc250b1c65dfb5f767ebc8b8b40a92d (patch)
treec586545a9ce6e85522e96f4936b98d6986333193 /test
parent16a53cddf06739c910d7899684370442daa01a4c (diff)
Closes #319 - no reset on cached response
Diffstat (limited to 'test')
-rw-r--r--test/CacheIntegrationTest.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/CacheIntegrationTest.php b/test/CacheIntegrationTest.php
new file mode 100644
index 0000000..ae56880
--- /dev/null
+++ b/test/CacheIntegrationTest.php
@@ -0,0 +1,36 @@
+<?php
+
+class CacheIntegrationTest extends PHPUnit_Framework_TestCase {
+
+ public function setUp() {
+ ORM::configure('sqlite::memory:');
+ ORM::configure('logging', true);
+ ORM::configure('caching', true);
+
+ ORM::raw_execute('CREATE TABLE `league` ( `class_id` INTEGER )');
+ ORM::raw_execute('INSERT INTO `league`(`class_id`) VALUES (1), (2), (3)');
+ }
+
+ public function tearDown() {
+ ORM::raw_execute('DROP TABLE `league`');
+ }
+
+ public function testRegressionForPullRequest319() {
+ $rs = ORM::for_table('league')->where('class_id', 1);
+ $total = $rs->count();
+ $this->assertEquals(1, $total);
+ $row = $rs->find_one();
+ $this->assertEquals(array('class_id' => 1), $row->as_array());
+
+ $rs = ORM::for_table('league')->where('class_id', 1);
+ $total = $rs->count();
+ $this->assertEquals(1, $total);
+ try {
+ $row = $rs->find_one();
+ } catch(PDOException $e) {
+ $this->fail("Caching is breaking subsequent queries!\n{$e->getMessage()}");
+ }
+ $this->assertEquals(array('class_id' => 1), $row->as_array());
+ }
+
+}