\Phake::when(Arsse::$db)->feedUpdate(2, true)->thenThrow(new \JKingWeb\Arsse\Feed\Exception("http://example.com/", new \PicoFeed\Client\InvalidUrlException));
@ -95,7 +95,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertResult([['id' => 1]], Arsse::$db->feedMatchIds(1, ['e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda'])); // this ID appears in both feed 1 and feed 2; only one result should be returned
}
public function testUpdateAFeed() {
public function testUpdateAFeed():void {
// update a valid feed with both new and changed items
$test = new $this->resultClass(...$this->makeResult("SELECT 1867 as year, 19 as century union all select 1970 as year, 20 as century union all select 2112 as year, 22 as century"));
@ -110,7 +110,7 @@ abstract class BaseResult extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame(null, $test->getValue());
}
public function testGetRows() {
public function testGetRows():void {
$exp = [
['album' => '2112', 'track' => '2112'],
['album' => 'Clockwork Angels', 'track' => 'The Wreckers'],
@ -121,7 +121,7 @@ abstract class BaseResult extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame(null, $test->getRow());
}
public function testGetAllRows() {
public function testGetAllRows():void {
$exp = [
['album' => '2112', 'track' => '2112'],
['album' => 'Clockwork Angels', 'track' => 'The Wreckers'],
@ -46,12 +46,12 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
self::clearData();
}
public function testConstructStatement() {
public function testConstructStatement():void {
$this->assertInstanceOf(Statement::class, new $this->statementClass(...$this->makeStatement("SELECT ? as value")));
}
/** @dataProvider provideBindings */
public function testBindATypedValue($value, string $type, string $exp) {
public function testBindATypedValue($value, string $type, string $exp):void {
if ($exp === "null") {
$query = "SELECT (? is null) as pass";
} else {
@ -65,7 +65,7 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
}
/** @dataProvider provideBinaryBindings */
public function testHandleBinaryData($value, string $type, string $exp) {
public function testHandleBinaryData($value, string $type, string $exp):void {
if (in_array(static::$implementation, ["PostgreSQL", "PDO PostgreSQL"])) {
$this->markTestIncomplete("Correct handling of binary data with PostgreSQL is not currently implemented");
}
@ -81,13 +81,13 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertTrue((bool) $act);
}
public function testBindMissingValue() {
public function testBindMissingValue():void {
$s = new $this->statementClass(...$this->makeStatement("SELECT ? as value", ["int"]));
$val = $s->runArray()->getRow()['value'];
$this->assertSame(null, $val);
}
public function testBindMultipleValues() {
public function testBindMultipleValues():void {
$exp = [
'one' => "A",
'two' => "B",
@ -97,7 +97,7 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, $val);
}
public function testBindRecursively() {
public function testBindRecursively():void {
$exp = [
'one' => "A",
'two' => "B",
@ -109,20 +109,20 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, $val);
}
public function testBindWithoutType() {
public function testBindWithoutType():void {
$this->assertException("paramTypeMissing", "Db");
$s = new $this->statementClass(...$this->makeStatement("SELECT ? as value", []));
$s->runArray([1]);
}
public function testViolateConstraint() {
public function testViolateConstraint():void {
(new $this->statementClass(...$this->makeStatement("CREATE TABLE if not exists arsse_meta(\"key\" varchar(255) primary key not null, value text)")))->run();
$s = new $this->statementClass(...$this->makeStatement("INSERT INTO arsse_meta(\"key\") values(?)", ["str"]));
(new $this->statementClass(...$this->makeStatement("CREATE TABLE if not exists arsse_feeds(id integer primary key not null, url text not null)")))->run();
$s = new $this->statementClass(...$this->makeStatement("INSERT INTO arsse_feeds(id,url) values(?,?)", ["str", "str"]));
@ -222,7 +222,7 @@ class TestImportExport extends \JKingWeb\Arsse\Test\AbstractTest {
$this->compareExpectations($this->drv, $exp);
}
public function testImportAFeed() {
public function testImportAFeed():void {
$in = [[
['url' => "http://localhost:8000/Import/some-feed", 'title' => "Some Feed", 'folder' => 0, 'tags' => ["frequent", "cryptic"]], //one existing tag and one new one
], []];
@ -237,7 +237,7 @@ class TestImportExport extends \JKingWeb\Arsse\Test\AbstractTest {
$this->compareExpectations($this->drv, $exp);
}
public function testImportAFeedWithAnInvalidTag() {
public function testImportAFeedWithAnInvalidTag():void {
@ -11,14 +11,14 @@ use JKingWeb\Arsse\Misc\ValueInfo;
/** @covers \JKingWeb\Arsse\Misc\Query */
class TestQuery extends \JKingWeb\Arsse\Test\AbstractTest {
public function testBasicQuery() {
public function testBasicQuery():void {
$q = new Query("select * from table where a = ?", "int", 3);
$this->assertSame("select * from table where a = ?", $q->getQuery());
$this->assertSame(["int"], $q->getTypes());
$this->assertSame([3], $q->getValues());
}
public function testWhereQuery() {
public function testWhereQuery():void {
// simple where clause
$q = (new Query("select * from table"))->setWhere("a = ?", "int", 3);
$this->assertSame("select * from table WHERE a = ?", $q->getQuery());
@ -46,21 +46,21 @@ class TestQuery extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame([2, 4, 1, 3], $q->getValues());
}
public function testGroupedQuery() {
public function testGroupedQuery():void {
$q = (new Query("select col1, col2, count(*) as count from table"))->setGroup("col1", "col2");
$this->assertSame("select col1, col2, count(*) as count from table GROUP BY col1, col2", $q->getQuery());
$this->assertSame([], $q->getTypes());
$this->assertSame([], $q->getValues());
}
public function testOrderedQuery() {
public function testOrderedQuery():void {
$q = (new Query("select col1, col2, col3 from table"))->setOrder("col1 desc", "col2")->setOrder("col3 asc");
$this->assertSame("select col1, col2, col3 from table ORDER BY col1 desc, col2, col3 asc", $q->getQuery());
$this->assertSame([], $q->getTypes());
$this->assertSame([], $q->getValues());
}
public function testLimitedQuery() {
public function testLimitedQuery():void {
// no offset
$q = (new Query("select * from table"))->setLimit(5);
$this->assertSame("select * from table LIMIT 5", $q->getQuery());
@ -78,7 +78,7 @@ class TestQuery extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame([], $q->getValues());
}
public function testQueryWithCommonTableExpression() {
public function testQueryWithCommonTableExpression():void {
$q = (new Query("select * from table where a in (select * from cte where a = ?)", "int", 1))->setCTE("cte", "select * from other_table where a = ? and b = ?", ["str", "str"], [2, 3]);
$this->assertSame("WITH RECURSIVE cte as (select * from other_table where a = ? and b = ?) select * from table where a in (select * from cte where a = ?)", $q->getQuery());
@ -33,7 +33,7 @@ class TestInternal extends \JKingWeb\Arsse\Test\AbstractTest {
* @dataProvider provideAuthentication
* @group slow
*/
public function testAuthenticateAUser(bool $authorized, string $user, $password, bool $exp) {
public function testAuthenticateAUser(bool $authorized, string $user, $password, bool $exp):void {
if ($authorized) {
\Phake::when(Arsse::$db)->userPasswordGet("john.doe@example.com")->thenReturn('$2y$10$1zbqRJhxM8uUjeSBPp4IhO90xrqK0XjEh9Z16iIYEFRV4U.zeAFom'); // hash of "secret"
\Phake::when(Arsse::$db)->userPasswordGet("jane.doe@example.com")->thenReturn('$2y$10$bK1ljXfTSyc2D.NYvT.Eq..OpehLRXVbglW.23ihVuyhgwJCd.7Im'); // hash of "superman"
@ -74,12 +74,12 @@ class TestInternal extends \JKingWeb\Arsse\Test\AbstractTest {
public function assertTime($exp, $test, string $msg = '') {
public function assertTime($exp, $test, string $msg = ''): void {
$test = $this->approximateTime($exp, $test);
$exp = Date::transform($exp, "iso8601");
$test = Date::transform($test, "iso8601");
@ -299,7 +299,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
return $out;
}
public function assertResult(array $expected, Result $data) {
public function assertResult(array $expected, Result $data): void {
$data = $data->getAll();
$this->assertCount(sizeof($expected), $data, "Number of result rows (".sizeof($data).") differs from number of expected rows (".sizeof($expected).")");