public function testGetDiffWriterByFormatException() { try { $name = ezcDbSchemaHandlerManager::getDiffWriterByFormat('bogus'); self::fail('Expected exception not thrown'); } catch (ezcDbSchemaUnknownFormatException $e) { self::assertEquals("There is no 'difference write' handler available for the 'bogus' format.", $e->getMessage()); } }
/** * Returns the $db specific SQL queries that would create the tables * defined in the schema. * * The database type can be given as both a database handler (instanceof * ezcDbHandler) or the name of the database as string as retrieved through * calling getName() on the database handler object. * * @see ezcDbHandler::getName() * * @throws ezcDbSchemaInvalidWriterClassException if the handler associated * with the $format is not a database schema writer. * * @param string|ezcDbHandler $db * @return array(string) */ public function convertToDDL($db) { self::initOptions(); if ($db instanceof ezcDbHandler) { $db = $db->getName(); } $className = ezcDbSchemaHandlerManager::getDiffWriterByFormat($db); $writer = new $className(); self::checkSchemaWriter($writer, self::DATABASE); return $writer->convertToDDL($this); }