1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 09:02:41 +00:00

Sundry article test fixes; things are still broken

This commit is contained in:
J. King 2023-02-12 18:30:19 -05:00
parent 30dbd850e3
commit 9fb57defa2
15 changed files with 412 additions and 362 deletions

View file

@ -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;

File diff suppressed because it is too large Load diff

View file

@ -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([

View file

@ -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 {

View file

@ -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' => [

View file

@ -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 = [

View file

@ -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 {

View file

@ -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' => [

View file

@ -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,

View file

@ -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([

View file

@ -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' => [

View file

@ -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;

View file

@ -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"));

View file

@ -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' => [

View file

@ -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 {