diff options
author | Andrew Dolgov <[email protected]> | 2022-07-16 16:30:46 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2022-07-16 16:30:46 +0300 |
commit | b8c1d622a77226b14fb307cfe3e0f4cea9e4268a (patch) | |
tree | 3df519798dcfef20c96a079e0956ebcd5509b619 /vendor/j4mie/idiorm/test/CacheIntegrationTest.php | |
parent | fdd1c43612011060b4b876db438eb7ec62dd077d (diff) |
add missing files for forked idiorm
Diffstat (limited to 'vendor/j4mie/idiorm/test/CacheIntegrationTest.php')
-rw-r--r-- | vendor/j4mie/idiorm/test/CacheIntegrationTest.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/vendor/j4mie/idiorm/test/CacheIntegrationTest.php b/vendor/j4mie/idiorm/test/CacheIntegrationTest.php new file mode 100644 index 000000000..0a5dc6101 --- /dev/null +++ b/vendor/j4mie/idiorm/test/CacheIntegrationTest.php @@ -0,0 +1,43 @@ +<?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 )'); + // needs to be individually inserted to support SQLite before + // version 3.7.11 + ORM::raw_execute('INSERT INTO `league`(`class_id`) VALUES (1)'); + ORM::raw_execute('INSERT INTO `league`(`class_id`) VALUES (2)'); + ORM::raw_execute('INSERT INTO `league`(`class_id`) VALUES (3)'); + + $x = ORM::for_table('league')->count(); + $this->assertEquals(3, $x); + } + + 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()); + } + +} |