/** * Test on table query response * * @depends testIsAvailableAdapters * * @author Sergey Startsev */ public function testTableQueryResponse() { $tables = afsDatabaseQuery::getTables('propel'); if (!empty($tables)) { $table = $tables[0]['tableName']; $model = $tables[0]['modelName']; // check sql query $response = afsDatabaseQuery::processQuery("SELECT * FROM {$table}", 'propel', 'sql'); $this->assertTrue($response->getParameter(afResponseSuccessDecorator::IDENTIFICATOR), 'response should contains success => true'); $this->assertTrue($response->hasParameter(afResponseDatasetDecorator::IDENTIFICATOR), 'response should contains dataset => array'); $dataset = $response->getParameter(afResponseDatasetDecorator::IDENTIFICATOR); $this->assertTrue($dataset[0][afResponseSuccessDecorator::IDENTIFICATOR], "query should be successfully executed"); $this->assertTrue(is_array($dataset[0][afResponseDataDecorator::IDENTIFICATOR_DATA]), "data in response should be array"); // check query class $query_class = "{$model}Query"; $this->assertTrue(class_exists($query_class), "Class query '{$query_class}' doesn't exists"); // check propel query - need to solve proble with propel entire ob_end_flush fatal } }
/** * Execute query helper method * * @param $query Query which will be processed * @param $connection Connection name for executing query * @param $type Type of query (sql, propel) * @param $offset Offset for query * @param $limit Limit for query * @return array */ public function processQuery($query, $connection, $type = 'sql', $offset = 0, $limit = 50) { return afsDatabaseQuery::processQuery($query, $connection, $type, $offset, $limit)->asArray(); }