Browse Source

Sundry article test fixes; things are still broken

redup
J. King 1 year ago
parent
commit
9fb57defa2
  1. 16
      lib/Database.php
  2. 733
      tests/cases/Database/SeriesArticle.php
  3. 2
      tests/cases/Database/SeriesCleanup.php
  4. 1
      tests/cases/Database/SeriesFeed.php
  5. 2
      tests/cases/Database/SeriesFolder.php
  6. 2
      tests/cases/Database/SeriesIcon.php
  7. 1
      tests/cases/Database/SeriesLabel.php
  8. 2
      tests/cases/Database/SeriesMeta.php
  9. 2
      tests/cases/Database/SeriesMiscellany.php
  10. 2
      tests/cases/Database/SeriesSession.php
  11. 2
      tests/cases/Database/SeriesSubscription.php
  12. 2
      tests/cases/Database/SeriesTag.php
  13. 2
      tests/cases/Database/SeriesToken.php
  14. 2
      tests/cases/Database/SeriesUser.php
  15. 1
      tests/cases/Database/TestDatabase.php

16
lib/Database.php

@ -1926,7 +1926,7 @@ class Database {
$setData = array_filter($data, function($v, $k) { $setData = array_filter($data, function($v, $k) {
// filter out anyhing with a value of null (no change), as well as the "rea" key as it required special handling // filter out anyhing with a value of null (no change), as well as the "rea" key as it required special handling
return isset($v) && $k !== "read"; return isset($v) && $k !== "read";
}); }, \ARRAY_FILTER_USE_BOTH);
[$set, $setTypes, $setValues] = $this->generateSet($setData, ['read' => "bool", 'starred' => "bool", 'hidden' => "bool", 'note' => "str"]); [$set, $setTypes, $setValues] = $this->generateSet($setData, ['read' => "bool", 'starred' => "bool", 'hidden' => "bool", 'note' => "str"]);
$set = $set ? "$set, " : ""; $set = $set ? "$set, " : "";
$set .= "read = case when id in (select article from valid_read) then ? else \"read\" end"; $set .= "read = case when id in (select article from valid_read) then ? else \"read\" end";
@ -1939,11 +1939,11 @@ class Database {
[$inClause, $inTypes, $inValues] = $this->generateIn($context->editions ?: (array) $context->edition, "int"); [$inClause, $inTypes, $inValues] = $this->generateIn($context->editions ?: (array) $context->edition, "int");
$out = $this->db->prepare( $out = $this->db->prepare(
"WITH RECURSIVE "WITH RECURSIVE
target_articles(article) as ( target_articles as (
{$subq->getQuery()} {$subq->getQuery()}
), ),
valid_read as ( valid_read as (
select article from ( select selected_editions.article from (
select max(id) as edition, article from arsse_editions where id in ($inClause) group by article select max(id) as edition, article from arsse_editions where id in ($inClause) group by article
) as selected_editions join ( ) as selected_editions join (
SELECT max(id) as edition, article from arsse_editions group by article SELECT max(id) as edition, article from arsse_editions group by article
@ -1953,11 +1953,11 @@ class Database {
set set
$set $set
where where
article in (select article from target_articles)", id in (select id from target_articles)",
$subq->getTypes(), $inTypes, $setTypes $subq->getTypes(), $inTypes, $setTypes
)->run( )->run(
$subq->getValues(), $inValues, $setValues $subq->getValues(), $inValues, $setValues
); )->changes();
} else { } else {
// set up the "SET" clause for the update // set up the "SET" clause for the update
$setData = array_filter($data, function($v) { $setData = array_filter($data, function($v) {
@ -1971,18 +1971,18 @@ class Database {
// prepare the rest of the query // prepare the rest of the query
$out = $this->db->prepare( $out = $this->db->prepare(
"WITH RECURSIVE "WITH RECURSIVE
target_articles(article) as ( target_articles as (
{$subq->getQuery()} {$subq->getQuery()}
) )
update arsse_articles update arsse_articles
set set
$set $set
where where
article in (select article from target_articles)", id in (select id from target_articles)",
$subq->getTypes(), $setTypes $subq->getTypes(), $setTypes
)->run( )->run(
$subq->getValues(), $setValues $subq->getValues(), $setValues
); )->changes();
} }
$tr->commit(); $tr->commit();
return $out; return $out;

733
tests/cases/Database/SeriesArticle.php

File diff suppressed because it is too large

2
tests/cases/Database/SeriesCleanup.php

@ -10,6 +10,8 @@ use JKingWeb\Arsse\Arsse;
use DateTimeImmutable as Date; use DateTimeImmutable as Date;
trait SeriesCleanup { trait SeriesCleanup {
protected static $drv;
protected function setUpSeriesCleanup(): void { protected function setUpSeriesCleanup(): void {
// set up the configuration // set up the configuration
Arsse::$conf->import([ Arsse::$conf->import([

1
tests/cases/Database/SeriesFeed.php

@ -10,6 +10,7 @@ use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Test\Result; use JKingWeb\Arsse\Test\Result;
trait SeriesFeed { trait SeriesFeed {
protected static $drv;
protected $matches; protected $matches;
protected function setUpSeriesFeed(): void { protected function setUpSeriesFeed(): void {

2
tests/cases/Database/SeriesFolder.php

@ -9,6 +9,8 @@ namespace JKingWeb\Arsse\TestCase\Database;
use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Arsse;
trait SeriesFolder { trait SeriesFolder {
protected static $drv;
protected function setUpSeriesFolder(): void { protected function setUpSeriesFolder(): void {
$this->data = [ $this->data = [
'arsse_users' => [ 'arsse_users' => [

2
tests/cases/Database/SeriesIcon.php

@ -9,6 +9,8 @@ namespace JKingWeb\Arsse\TestCase\Database;
use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Arsse;
trait SeriesIcon { trait SeriesIcon {
protected static $drv;
protected function setUpSeriesIcon(): void { protected function setUpSeriesIcon(): void {
// set up the test data // set up the test data
$this->data = [ $this->data = [

1
tests/cases/Database/SeriesLabel.php

@ -11,6 +11,7 @@ use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\Context\Context; use JKingWeb\Arsse\Context\Context;
trait SeriesLabel { trait SeriesLabel {
protected static $drv;
protected $checkLabels; protected $checkLabels;
protected function setUpSeriesLabel(): void { protected function setUpSeriesLabel(): void {

2
tests/cases/Database/SeriesMeta.php

@ -10,6 +10,8 @@ use JKingWeb\Arsse\Test\Database;
use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Arsse;
trait SeriesMeta { trait SeriesMeta {
protected static $drv;
protected function setUpSeriesMeta(): void { protected function setUpSeriesMeta(): void {
$dataBare = [ $dataBare = [
'arsse_meta' => [ 'arsse_meta' => [

2
tests/cases/Database/SeriesMiscellany.php

@ -10,6 +10,8 @@ use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
trait SeriesMiscellany { trait SeriesMiscellany {
protected static $drv;
protected function setUpSeriesMiscellany(): void { protected function setUpSeriesMiscellany(): void {
static::setConf([ static::setConf([
'dbDriver' => static::$dbDriverClass, 'dbDriver' => static::$dbDriverClass,

2
tests/cases/Database/SeriesSession.php

@ -10,6 +10,8 @@ use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Misc\Date; use JKingWeb\Arsse\Misc\Date;
trait SeriesSession { trait SeriesSession {
protected static $drv;
protected function setUpSeriesSession(): void { protected function setUpSeriesSession(): void {
// set up the configuration // set up the configuration
static::setConf([ static::setConf([

2
tests/cases/Database/SeriesSubscription.php

@ -13,6 +13,8 @@ use JKingWeb\Arsse\Feed\Exception as FeedException;
use JKingWeb\Arsse\Misc\Date; use JKingWeb\Arsse\Misc\Date;
trait SeriesSubscription { trait SeriesSubscription {
protected static $drv;
public function setUpSeriesSubscription(): void { public function setUpSeriesSubscription(): void {
$this->data = [ $this->data = [
'arsse_users' => [ 'arsse_users' => [

2
tests/cases/Database/SeriesTag.php

@ -10,6 +10,8 @@ use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
trait SeriesTag { trait SeriesTag {
protected static $drv;
protected $checkMembers; protected $checkMembers;
protected $checkTags; protected $checkTags;

2
tests/cases/Database/SeriesToken.php

@ -9,6 +9,8 @@ namespace JKingWeb\Arsse\TestCase\Database;
use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Arsse;
trait SeriesToken { trait SeriesToken {
protected static $drv;
protected function setUpSeriesToken(): void { protected function setUpSeriesToken(): void {
// set up the test data // set up the test data
$past = gmdate("Y-m-d H:i:s", strtotime("now - 1 minute")); $past = gmdate("Y-m-d H:i:s", strtotime("now - 1 minute"));

2
tests/cases/Database/SeriesUser.php

@ -9,6 +9,8 @@ namespace JKingWeb\Arsse\TestCase\Database;
use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Arsse;
trait SeriesUser { trait SeriesUser {
protected static $drv;
protected function setUpSeriesUser(): void { protected function setUpSeriesUser(): void {
$this->data = [ $this->data = [
'arsse_users' => [ 'arsse_users' => [

1
tests/cases/Database/TestDatabase.php

@ -10,6 +10,7 @@ use JKingWeb\Arsse\Database;
/** @covers \JKingWeb\Arsse\Database */ /** @covers \JKingWeb\Arsse\Database */
class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
protected static $drv;
protected $db = null; protected $db = null;
public function setUp(): void { public function setUp(): void {

Loading…
Cancel
Save