Pass configuration settings to the class in the form of
key/value pairs. As a shortcut, if the second argument
is omitted and the key is a string, the setting is
assumed to be the DSN string used by PDO to connect
to the database (often, this will be the only configuration
required to use Idiorm). If you have more than one setting
you wish to configure, another shortcut is to pass an array
of settings (and omit the second argument).
public function setUp() { // Enable logging ORM::configure('logging', true); // Set up the dummy database connection $db = new PDO('sqlite::memory:'); ORM::set_db($db); }
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); }
public function testFindResultSetByDefault() { ORM::configure('return_result_sets', true); $result_set = ORM::for_table('test')->find_many(); $this->assertInstanceOf('Granada\\ResultSet', $result_set); $this->assertSame(count($result_set), 5); ORM::configure('return_result_sets', false); $result_set = ORM::for_table('test')->find_many(); $this->assertInternalType('array', $result_set); $this->assertSame(count($result_set), 5); }
public function testLoggerCallback() { ORM::configure('logger', function ($log_string) { return $log_string; }); $function = ORM::get_config('logger'); $this->assertTrue(is_callable($function)); $log_string = "UPDATE `widget` SET `added` = NOW() WHERE `id` = '1'"; $this->assertEquals($log_string, $function($log_string)); ORM::configure('logger', null); }
public function tearDown() { ORM::configure('logging', false); ORM::setDb(null); }
public function testGetConfig() { $this->assertTrue(ORM::get_config('logging')); ORM::configure('logging', false); $this->assertFalse(ORM::get_config('logging')); ORM::configure('logging', true); }