2018-11-23 00:55:54 +00:00
|
|
|
<?php
|
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\Arsse\TestCase\Db;
|
|
|
|
|
|
|
|
use JKingWeb\Arsse\Test\DatabaseInformation;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \JKingWeb\Arsse\Db\PDOResult<extended>
|
|
|
|
*/
|
|
|
|
class TestResultPDO extends \JKingWeb\Arsse\TestCase\Db\BaseResult {
|
2018-11-27 19:26:33 +00:00
|
|
|
protected static $implementation;
|
2018-11-23 00:55:54 +00:00
|
|
|
|
|
|
|
public static function setUpBeforeClass() {
|
|
|
|
self::setConf();
|
|
|
|
// we only need to test one PDO implementation (they all use the same result class), so we find the first usable one
|
|
|
|
$drivers = DatabaseInformation::listPDO();
|
2018-11-27 19:26:33 +00:00
|
|
|
self::$implementation = $drivers[0];
|
2018-11-23 00:55:54 +00:00
|
|
|
foreach ($drivers as $driver) {
|
|
|
|
$info = new DatabaseInformation($driver);
|
|
|
|
$interface = ($info->interfaceConstructor)();
|
|
|
|
if ($interface) {
|
2018-11-27 19:26:33 +00:00
|
|
|
self::$implementation = $driver;
|
2018-11-23 00:55:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-11-27 19:26:33 +00:00
|
|
|
unset($interface);
|
|
|
|
unset($info);
|
|
|
|
parent::setUpBeforeClass();
|
2018-11-23 00:55:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function makeResult(string $q): array {
|
2018-11-27 19:26:33 +00:00
|
|
|
$set = static::$interface->query($q);
|
2018-11-23 00:55:54 +00:00
|
|
|
$rows = $set->rowCount();
|
2018-11-27 19:26:33 +00:00
|
|
|
$id = static::$interface->lastInsertID();
|
2018-11-23 00:55:54 +00:00
|
|
|
return [$set, [$rows, $id]];
|
|
|
|
}
|
|
|
|
}
|