public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { if (!class_exists($suite->getName())) { return; } if (!self::$booted && self::$logSQL) { self::$booted = true; $app = new \Alchemy\Phrasea\Application(\Alchemy\Phrasea\Application::ENV_TEST); self::$conn = $app['dbal.provider']($app['db.info']($app['db.appbox.info'])); unset($app); self::$conn->connect(); $schema = self::$conn->getSchemaManager(); $tableTest = new \Doctrine\DBAL\Schema\Table("tests"); /* Add some columns to the table */ $tableTest->addColumn("id", "integer", array("unsigned" => true, "autoincrement" => true)); $tableTest->addColumn("test", "string", array("length" => 256)); $tableTest->addColumn("name", "string", array("length" => 256)); $tableTest->addColumn("status", "string", array("length" => 16)); $tableTest->addColumn("duration", "float"); /* Add a primary key */ $tableTest->setPrimaryKey(array("id")); $schema->dropAndCreateTable($tableTest); } }
/** * Deletes previously created Resources. */ private static function deleteResources() { if (self::$recordsInitialized !== false) { foreach (self::$recordsInitialized as $i) { self::$DI['record_' . $i]->delete(); } self::$recordsInitialized = []; } $duration = PhraseanetPHPUnitListener::getDurationByTest(); $tests = []; foreach ($duration as $name => $data) { $tests[$name . '(total : ' . $data['time'] . ' and ' . $data['executions'] . ' executions)'] = $data['time'] / $data['executions']; } asort($tests); $csvData = PhraseanetPHPUnitListener::getCsv(); if (count($csvData) > 0) { foreach ($csvData as $data) { file_put_contents(__DIR__ . '/../../report.csv', "\"" . implode('","', array_map(function ($value) { return str_replace('"', '""', $value); }, $data)) . "\"\n", FILE_APPEND); } } PhraseanetPHPUnitListener::resetDuration(); return; }