/** * Testing the getLastQuery method after various persistance calls. * * @since 1.0 * @dataProvider getActiveRecordProviders */ public function testGetLastQuery($provider) { $config = ConfigProvider::getInstance(); $config->set('db.provider.name', $provider); $this->person->save(); if ($config->get('db.provider.name') == 'ActiveRecordProviderMySQL') { $this->assertEquals('INSERT INTO Person', mb_substr($this->person->getLastQuery(), 0, 18), 'Testing the getLastQuery method after various persistance calls'); $this->person->checkTableNeedsUpdate(); $this->assertEquals('SHOW INDEX FROM Person', mb_substr($this->person->getLastQuery(), 0, 22), 'Testing the getLastQuery method after various persistance calls'); $this->person->getCount(); $this->assertEquals('SELECT COUNT(OID)', mb_substr($this->person->getLastQuery(), 0, 17), 'Testing the getLastQuery method after various persistance calls'); $this->person->getMAX(); $this->assertEquals('SELECT MAX(OID)', mb_substr($this->person->getLastQuery(), 0, 15), 'Testing the getLastQuery method after various persistance calls'); $this->person->load($this->person->getID()); $this->assertEquals('SHOW COLUMNS FROM Person', mb_substr($this->person->getLastQuery(), 0, 24), 'Testing the getLastQuery method after various persistance calls'); } if ($config->get('db.provider.name') == 'ActiveRecordProviderSQLite') { $this->assertEquals('PRAGMA table_info(Person)', mb_substr($this->person->getLastQuery(), 0, 25), 'Testing the getLastQuery method after various persistance calls'); $this->person->checkTableNeedsUpdate(); $this->assertEquals('SELECT name FROM sqlite_master WHERE type=\'index\'', mb_substr($this->person->getLastQuery(), 0, 49), 'Testing the getLastQuery method after various persistance calls'); $this->person->getCount(); $this->assertEquals('SELECT COUNT(OID)', mb_substr($this->person->getLastQuery(), 0, 17), 'Testing the getLastQuery method after various persistance calls'); $this->person->getMAX(); $this->assertEquals('SELECT MAX(OID)', mb_substr($this->person->getLastQuery(), 0, 15), 'Testing the getLastQuery method after various persistance calls'); $this->person->load($this->person->getID()); $this->assertEquals('SELECT displayName,email,password,state,URL,OID,version_num,created_ts,created_by,updated_ts,updated_by FROM Person WHERE OID = :OID LIMIT 1;', mb_substr($this->person->getLastQuery(), 0, 150), 'Testing the getLastQuery method after various persistance calls'); } }