mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Coverage fixes and OPML bugfix
This commit is contained in:
parent
b8b8a6aa70
commit
64c3ec3571
9 changed files with 20 additions and 25 deletions
|
@ -3,6 +3,7 @@ Version 0.8.1 (2019-??-??)
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
- Don't crash updating feeds cached solely via ETag
|
- Don't crash updating feeds cached solely via ETag
|
||||||
|
- Don't fail importing new folders from OPML files
|
||||||
- Don't fail adding a feed which collides with another via redirection
|
- Don't fail adding a feed which collides with another via redirection
|
||||||
- Don't fail on very long text-search queries containing question marks
|
- Don't fail on very long text-search queries containing question marks
|
||||||
when using PostgreSQL or MySQL
|
when using PostgreSQL or MySQL
|
||||||
|
|
|
@ -5,6 +5,7 @@ use Robo\Result;
|
||||||
const BASE = __DIR__.\DIRECTORY_SEPARATOR;
|
const BASE = __DIR__.\DIRECTORY_SEPARATOR;
|
||||||
const BASE_TEST = BASE."tests".\DIRECTORY_SEPARATOR;
|
const BASE_TEST = BASE."tests".\DIRECTORY_SEPARATOR;
|
||||||
define("IS_WIN", defined("PHP_WINDOWS_VERSION_MAJOR"));
|
define("IS_WIN", defined("PHP_WINDOWS_VERSION_MAJOR"));
|
||||||
|
define("IS_MAC", php_uname("s") === "Darwin");
|
||||||
|
|
||||||
function norm(string $path): string {
|
function norm(string $path): string {
|
||||||
$out = realpath($path);
|
$out = realpath($path);
|
||||||
|
@ -92,12 +93,13 @@ class RoboFile extends \Robo\Tasks {
|
||||||
$dbg = dirname(\PHP_BINARY)."\\phpdbg.exe";
|
$dbg = dirname(\PHP_BINARY)."\\phpdbg.exe";
|
||||||
$dbg = file_exists($dbg) ? $dbg : "";
|
$dbg = file_exists($dbg) ? $dbg : "";
|
||||||
} else {
|
} else {
|
||||||
$dbg = trim(`which phpdbg`);
|
$dbg = trim(`which phpdbg 2>/dev/null`);
|
||||||
}
|
}
|
||||||
if ($dbg) {
|
if ($dbg) {
|
||||||
return escapeshellarg($dbg)." -qrr";
|
return escapeshellarg($dbg)." -qrr";
|
||||||
} else {
|
} else {
|
||||||
return escapeshellarg(\PHP_BINARY);
|
$ext = IS_WIN ? "dll" : (IS_MAC ? "dylib" : "so");
|
||||||
|
return escapeshellarg(\PHP_BINARY)." -d zend_extension=xdebug.$ext";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ USAGE_TEXT;
|
||||||
$this->logError($e->getMessage());
|
$this->logError($e->getMessage());
|
||||||
return $e->getCode();
|
return $e->getCode();
|
||||||
}
|
}
|
||||||
}
|
} // @codeCoverageIgnore
|
||||||
|
|
||||||
/** @codeCoverageIgnore */
|
/** @codeCoverageIgnore */
|
||||||
protected function logError(string $msg) {
|
protected function logError(string $msg) {
|
||||||
|
@ -248,7 +248,7 @@ USAGE_TEXT;
|
||||||
case "":
|
case "":
|
||||||
return $this->userList();
|
return $this->userList();
|
||||||
}
|
}
|
||||||
}
|
} // @codeCoverageIgnore
|
||||||
|
|
||||||
protected function userAddOrSetPassword(string $method, string $user, string $password = null, string $oldpass = null): int {
|
protected function userAddOrSetPassword(string $method, string $user, string $password = null, string $oldpass = null): int {
|
||||||
$passwd = Arsse::$user->$method(...array_slice(func_get_args(), 1));
|
$passwd = Arsse::$user->$method(...array_slice(func_get_args(), 1));
|
||||||
|
|
|
@ -57,7 +57,7 @@ abstract class AbstractImportExport {
|
||||||
}
|
}
|
||||||
if (!isset($folderMap[$id])) {
|
if (!isset($folderMap[$id])) {
|
||||||
// if no existing folder exists, add one
|
// if no existing folder exists, add one
|
||||||
$folderMap[$id] = Arsse::$db->folderAdd($user, ['name' => $f['name'], 'parent' -> $parent]);
|
$folderMap[$id] = Arsse::$db->folderAdd($user, ['name' => $f['name'], 'parent' => $parent]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// process newsfeed subscriptions
|
// process newsfeed subscriptions
|
||||||
|
@ -118,21 +118,21 @@ abstract class AbstractImportExport {
|
||||||
foreach (array_diff(array_column($feedsDb, "id"), $feedMap) as $id) {
|
foreach (array_diff(array_column($feedsDb, "id"), $feedMap) as $id) {
|
||||||
try {
|
try {
|
||||||
Arsse::$db->subscriptionRemove($user, $id);
|
Arsse::$db->subscriptionRemove($user, $id);
|
||||||
} catch (InputException $e) {
|
} catch (InputException $e) { // @codeCoverageIgnore
|
||||||
// ignore errors
|
// ignore errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (array_diff(array_column($foldersDb, "id"), $folderMap) as $id) {
|
foreach (array_diff(array_column($foldersDb, "id"), $folderMap) as $id) {
|
||||||
try {
|
try {
|
||||||
Arsse::$db->folderRemove($user, $id);
|
Arsse::$db->folderRemove($user, $id);
|
||||||
} catch (InputException $e) {
|
} catch (InputException $e) { // @codeCoverageIgnore
|
||||||
// ignore errors
|
// ignore errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (array_diff(array_column($tagsDb, "name"), array_keys($tagMap)) as $id) {
|
foreach (array_diff(array_column($tagsDb, "name"), array_keys($tagMap)) as $id) {
|
||||||
try {
|
try {
|
||||||
Arsse::$db->tagRemove($user, $id, true);
|
Arsse::$db->tagRemove($user, $id, true);
|
||||||
} catch (InputException $e) {
|
} catch (InputException $e) { // @codeCoverageIgnore
|
||||||
// ignore errors
|
// ignore errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,8 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
// indexed arrays
|
// indexed arrays
|
||||||
$p->appendChild($this->makeXMLIndexed($v, $d->createElement($k), substr($k, 0, strlen($k) - 1)));
|
$p->appendChild($this->makeXMLIndexed($v, $d->createElement($k), substr($k, 0, strlen($k) - 1)));
|
||||||
} else {
|
} else {
|
||||||
$p->appendChild($this->makeXMLAssoc($v, $d->createElement($k)));
|
// this case does not actually occur in a proper Fever response
|
||||||
|
$p->appendChild($this->makeXMLAssoc($v, $d->createElement($k))); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $p;
|
return $p;
|
||||||
|
|
|
@ -212,11 +212,13 @@ class TestImportExport extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
['id' => 4, 'name' => "Politics", 'parent' => 0],
|
['id' => 4, 'name' => "Politics", 'parent' => 0],
|
||||||
['id' => 5, 'name' => "Local", 'parent' => 4],
|
['id' => 5, 'name' => "Local", 'parent' => 4],
|
||||||
['id' => 6, 'name' => "National", 'parent' => 4],
|
['id' => 6, 'name' => "National", 'parent' => 4],
|
||||||
|
['id' => 7, 'name' => "Nature", 'parent' => 0], // new folder
|
||||||
]];
|
]];
|
||||||
\Phake::when($this->proc)->parse->thenReturn($in);
|
\Phake::when($this->proc)->parse->thenReturn($in);
|
||||||
$this->proc->import("john.doe@example.com", "", false, true);
|
$this->proc->import("john.doe@example.com", "", false, true);
|
||||||
$exp = $this->primeExpectations($this->data, $this->checkTables);
|
$exp = $this->primeExpectations($this->data, $this->checkTables);
|
||||||
$exp['arsse_subscriptions']['rows'][3] = [4, "john.doe@example.com", null, 4, "CBC"];
|
$exp['arsse_subscriptions']['rows'][3] = [4, "john.doe@example.com", null, 4, "CBC"];
|
||||||
|
$exp['arsse_folders']['rows'][] = [7, "john.doe@example.com", null, "Nature"];
|
||||||
$this->compareExpectations($this->drv, $exp);
|
$this->compareExpectations($this->drv, $exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace JKingWeb\Arsse\Test\Lang;
|
||||||
use JKingWeb\Arsse\Lang;
|
use JKingWeb\Arsse\Lang;
|
||||||
use JKingWeb\Arsse\Arsse;
|
use JKingWeb\Arsse\Arsse;
|
||||||
use org\bovigo\vfs\vfsStream;
|
use org\bovigo\vfs\vfsStream;
|
||||||
|
use Webmozart\Glob\Glob;
|
||||||
|
|
||||||
trait Setup {
|
trait Setup {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
@ -36,7 +37,10 @@ trait Setup {
|
||||||
// set up a file without read access
|
// set up a file without read access
|
||||||
chmod($this->path."ru.php", 0000);
|
chmod($this->path."ru.php", 0000);
|
||||||
// make the test Lang class use the vfs files
|
// make the test Lang class use the vfs files
|
||||||
$this->l = new TestLang($this->path);
|
$this->l = \Phake::partialMock(Lang::class, $this->path);
|
||||||
|
\Phake::when($this->l)->globFiles->thenReturnCallback(function(string $path): array {
|
||||||
|
return Glob::glob($this->path."*.php");
|
||||||
|
});
|
||||||
// create a mock Lang object so as not to create a dependency loop
|
// create a mock Lang object so as not to create a dependency loop
|
||||||
self::clearData(false);
|
self::clearData(false);
|
||||||
Arsse::$lang = \Phake::mock(Lang::class);
|
Arsse::$lang = \Phake::mock(Lang::class);
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
<?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\Test\Lang;
|
|
||||||
|
|
||||||
use Webmozart\Glob\Glob;
|
|
||||||
|
|
||||||
class TestLang extends \JKingWeb\Arsse\Lang {
|
|
||||||
protected function globFiles(string $path): array {
|
|
||||||
return Glob::glob($this->path."*.php");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue