add missing files for forked idiorm

This commit is contained in:
Andrew Dolgov
2022-07-16 16:30:46 +03:00
parent fdd1c43612
commit b8c1d622a7
187 changed files with 11950 additions and 45862 deletions

42
vendor/j4mie/idiorm/test/CacheTest.php vendored Normal file
View File

@@ -0,0 +1,42 @@
<?php
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);
ORM::configure('caching', true, self::ALTERNATE);
}
public function tearDown() {
ORM::reset_config();
ORM::reset_db();
}
// 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());
}
public function testQueryGenerationOnlyOccursOnceWithMultipleConnections() {
// 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();
$expected = 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($expected, ORM::get_last_query(self::ALTERNATE));
}
}