api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

SqliteTest.php 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. require_once(__DIR__ . '/Tests.php');
  3. class SqliteTest extends Tests
  4. {
  5. /**
  6. * Connects to the Database
  7. *
  8. * @return object Database connection
  9. */
  10. public function connect($config)
  11. {
  12. $db = new SQLite3($config['database']);
  13. if (!$db) {
  14. die("Could not open '$database' SQLite database: ".SQLite3::lastErrorMsg().' ('.SQLite3::lastErrorCode().")\n");
  15. }
  16. return $db;
  17. }
  18. /**
  19. * Disconnects from the Database
  20. *
  21. * @return boolean Success
  22. */
  23. public function disconnect($db)
  24. {
  25. return $db->close();
  26. }
  27. /**
  28. * Checks the version of the Database
  29. *
  30. * @return void
  31. */
  32. public function checkVersion($db)
  33. {
  34. $major = 3;
  35. $minor = 0;
  36. $version = SQLite3::version();
  37. $v = explode('.',$version['versionString']);
  38. if ($v[0]<$major || ($v[0]==$major && $v[1]<$minor)) {
  39. die("Detected SQLite $v[0].$v[1], but only $major.$minor and up are supported\n");
  40. }
  41. }
  42. /**
  43. * Gets the capabilities of the Database
  44. *
  45. * @return int Capabilites
  46. */
  47. public function getCapabilities($db)
  48. {
  49. $capabilities = 0;
  50. return $capabilities;
  51. }
  52. /**
  53. * Seeds the database for this connection
  54. *
  55. * @return void
  56. */
  57. public function seedDatabase($db, $capabilities)
  58. {
  59. $fixture = __DIR__.'/data/blog_sqlite.sql';
  60. $contents = file_get_contents($fixture);
  61. if (!($capabilities & self::GIS)) {
  62. $contents = preg_replace('/GEOMETRY NOT NULL/i','text NOT NULL',$contents);
  63. }
  64. if (!($capabilities & self::JSON)) {
  65. $contents = preg_replace('/JSON NOT NULL/i','text NOT NULL',$contents);
  66. }
  67. $queries = preg_split('/;\s*\n/', $contents);
  68. array_pop($queries);
  69. foreach ($queries as $i=>$query) {
  70. if (!$db->query($query.';')) {
  71. $i++;
  72. die("Loading '$fixture' failed on statemement #$i with error:\n".$db->lastErrorCode().': '.$db->lastErrorMsg()."\n");
  73. }
  74. }
  75. }
  76. }