/** * 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 } }
/** * Databases and tables list helper * * @return array */ public function processDatabaseList() { $aConfiguration = Propel::getConfiguration(); // Extract default connection $sDefault = ''; if (isset($aConfiguration['datasources']['default'])) { $sDefault = $aConfiguration['datasources']['default']; unset($aConfiguration['datasources']['default']); } $aDatabases = array(); // Generating response foreach ($aConfiguration['datasources'] as $db_connection => $db_connecttion_info) { $sDsn = $db_connecttion_info['connection']['dsn']; $aDsnInfo = afsDatabaseQuery::parseDSN($sDsn); $aTables = afsDatabaseQuery::getTables($db_connection); // Generate list of databases and tables $aDatabases[] = array('name' => $aDsnInfo['dbname'], 'tables_num' => count($aTables), 'connection' => $db_connection, 'tables' => array_values((array) $aTables)); } return $aDatabases; }