2017-03-31 13:24:00 -04:00
|
|
|
<?php
|
2017-11-16 20:23:18 -05:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2017-03-31 13:24:00 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\Arsse\Test\Database;
|
2017-08-29 10:50:31 -04:00
|
|
|
|
2017-07-17 07:47:57 -04:00
|
|
|
use JKingWeb\Arsse\Arsse;
|
2017-03-31 13:24:00 -04:00
|
|
|
use JKingWeb\Arsse\Db\SQLite3\Driver;
|
|
|
|
|
|
|
|
trait DriverSQLite3 {
|
2017-08-29 10:50:31 -04:00
|
|
|
public function setUpDriver() {
|
2017-12-22 11:45:24 -05:00
|
|
|
if (!Driver::requirementsMet()) {
|
2017-05-22 10:02:36 -04:00
|
|
|
$this->markTestSkipped("SQLite extension not loaded");
|
|
|
|
}
|
2017-07-17 07:47:57 -04:00
|
|
|
Arsse::$conf->dbSQLite3File = ":memory:";
|
2017-10-19 15:32:18 -04:00
|
|
|
$this->drv = new Driver();
|
2017-03-31 13:24:00 -04:00
|
|
|
}
|
2017-05-10 21:21:23 -04:00
|
|
|
|
2017-08-29 10:50:31 -04:00
|
|
|
public function nextID(string $table): int {
|
2017-05-10 21:21:23 -04:00
|
|
|
return $this->drv->query("SELECT (case when max(id) then max(id) else 0 end)+1 from $table")->getValue();
|
|
|
|
}
|
2017-08-29 10:50:31 -04:00
|
|
|
}
|