mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-31 21:12:41 +00:00
Style fixes
This commit is contained in:
parent
4f34b4ff29
commit
549c7bdc72
11 changed files with 18 additions and 25 deletions
|
@ -1209,7 +1209,7 @@ class Database {
|
||||||
*
|
*
|
||||||
* The result is an associative array whose keys are usernames, values
|
* The result is an associative array whose keys are usernames, values
|
||||||
* being an array in turn with the following keys:
|
* being an array in turn with the following keys:
|
||||||
*
|
*
|
||||||
* - "keep": The "keep" rule as a prepared pattern; any articles which fail to match this rule are hidden
|
* - "keep": The "keep" rule as a prepared pattern; any articles which fail to match this rule are hidden
|
||||||
* - "block": The block rule as a prepared pattern; any articles which match this rule are hidden
|
* - "block": The block rule as a prepared pattern; any articles which match this rule are hidden
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -265,7 +265,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//normalize user-specific input
|
//normalize user-specific input
|
||||||
foreach (self::USER_META_MAP as $k => [,$d,]) {
|
foreach (self::USER_META_MAP as $k => [,$d]) {
|
||||||
$t = gettype($d);
|
$t = gettype($d);
|
||||||
if (!isset($body[$k])) {
|
if (!isset($body[$k])) {
|
||||||
$body[$k] = null;
|
$body[$k] = null;
|
||||||
|
@ -343,7 +343,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
protected function editUser(string $user, array $data): array {
|
protected function editUser(string $user, array $data): array {
|
||||||
// map Miniflux properties to internal metadata properties
|
// map Miniflux properties to internal metadata properties
|
||||||
$in = [];
|
$in = [];
|
||||||
foreach (self::USER_META_MAP as $i => [$o,,]) {
|
foreach (self::USER_META_MAP as $i => [$o,]) {
|
||||||
if (isset($data[$i])) {
|
if (isset($data[$i])) {
|
||||||
if ($i === "entry_sorting_direction") {
|
if ($i === "entry_sorting_direction") {
|
||||||
$in[$o] = $data[$i] === "asc";
|
$in[$o] = $data[$i] === "asc";
|
||||||
|
|
|
@ -7,4 +7,4 @@ declare(strict_types=1);
|
||||||
namespace JKingWeb\Arsse\Rule;
|
namespace JKingWeb\Arsse\Rule;
|
||||||
|
|
||||||
class Exception extends \JKingWeb\Arsse\AbstractException {
|
class Exception extends \JKingWeb\Arsse\AbstractException {
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ abstract class Rule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** applies keep and block rules against the title and categories of an article
|
/** applies keep and block rules against the title and categories of an article
|
||||||
*
|
*
|
||||||
* Returns true if the article is to be kept, and false if it is to be suppressed
|
* Returns true if the article is to be kept, and false if it is to be suppressed
|
||||||
*/
|
*/
|
||||||
public static function apply(string $keepPattern, string $blockPattern, string $title, array $categories = []): bool {
|
public static function apply(string $keepPattern, string $blockPattern, string $title, array $categories = []): bool {
|
||||||
|
|
|
@ -44,12 +44,12 @@ class User {
|
||||||
|
|
||||||
public function begin(): Db\Transaction {
|
public function begin(): Db\Transaction {
|
||||||
/* TODO: A proper implementation of this would return a meta-transaction
|
/* TODO: A proper implementation of this would return a meta-transaction
|
||||||
object which would contain both a user-manager transaction (when
|
object which would contain both a user-manager transaction (when
|
||||||
applicable) and a database transaction, and commit or roll back both
|
applicable) and a database transaction, and commit or roll back both
|
||||||
as the situation calls.
|
as the situation calls.
|
||||||
|
|
||||||
In theory, an external user driver would probably have to implement its
|
In theory, an external user driver would probably have to implement its
|
||||||
own approximation of atomic transactions and rollback. In practice the
|
own approximation of atomic transactions and rollback. In practice the
|
||||||
only driver is the internal one, which is always backed by an ACID
|
only driver is the internal one, which is always backed by an ACID
|
||||||
database; the added complexity is thus being deferred until such time
|
database; the added complexity is thus being deferred until such time
|
||||||
as it is actually needed for a concrete implementation.
|
as it is actually needed for a concrete implementation.
|
||||||
|
@ -106,7 +106,7 @@ class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rename(string $user, string $newName): bool {
|
public function rename(string $user, string $newName): bool {
|
||||||
// ensure the new user name does not contain any U+003A COLON or
|
// ensure the new user name does not contain any U+003A COLON or
|
||||||
// control characters, as this is incompatible with HTTP Basic authentication
|
// control characters, as this is incompatible with HTTP Basic authentication
|
||||||
if (preg_match("/[\x{00}-\x{1F}\x{7F}:]/", $newName, $m)) {
|
if (preg_match("/[\x{00}-\x{1F}\x{7F}:]/", $newName, $m)) {
|
||||||
$c = ord($m[0]);
|
$c = ord($m[0]);
|
||||||
|
|
|
@ -28,10 +28,10 @@ interface Driver {
|
||||||
public function userAdd(string $user, string $password = null): ?string;
|
public function userAdd(string $user, string $password = null): ?string;
|
||||||
|
|
||||||
/** Renames a user
|
/** Renames a user
|
||||||
*
|
*
|
||||||
* The implementation must retain all user metadata as well as the
|
* The implementation must retain all user metadata as well as the
|
||||||
* user's password
|
* user's password
|
||||||
*/
|
*/
|
||||||
public function userRename(string $user, string $newName): bool;
|
public function userRename(string $user, string $newName): bool;
|
||||||
|
|
||||||
/** Removes a user */
|
/** Removes a user */
|
||||||
|
|
|
@ -184,8 +184,8 @@ trait SeriesUser {
|
||||||
public function testRenameAUser(): void {
|
public function testRenameAUser(): void {
|
||||||
$this->assertTrue(Arsse::$db->userRename("john.doe@example.com", "juan.doe@example.com"));
|
$this->assertTrue(Arsse::$db->userRename("john.doe@example.com", "juan.doe@example.com"));
|
||||||
$state = $this->primeExpectations($this->data, [
|
$state = $this->primeExpectations($this->data, [
|
||||||
'arsse_users' => ['id', 'num'],
|
'arsse_users' => ['id', 'num'],
|
||||||
'arsse_user_meta' => ["owner", "key", "value"]
|
'arsse_user_meta' => ["owner", "key", "value"],
|
||||||
]);
|
]);
|
||||||
$state['arsse_users']['rows'][2][0] = "juan.doe@example.com";
|
$state['arsse_users']['rows'][2][0] = "juan.doe@example.com";
|
||||||
$state['arsse_user_meta']['rows'][6][0] = "juan.doe@example.com";
|
$state['arsse_user_meta']['rows'][6][0] = "juan.doe@example.com";
|
||||||
|
|
|
@ -7,7 +7,6 @@ declare(strict_types=1);
|
||||||
namespace JKingWeb\Arsse\TestCase\Misc;
|
namespace JKingWeb\Arsse\TestCase\Misc;
|
||||||
|
|
||||||
use JKingWeb\Arsse\Rule\Rule;
|
use JKingWeb\Arsse\Rule\Rule;
|
||||||
use JKingWeb\Arsse\Rule\Exception;
|
|
||||||
|
|
||||||
/** @covers \JKingWeb\Arsse\Rule\Rule */
|
/** @covers \JKingWeb\Arsse\Rule\Rule */
|
||||||
class TestRule extends \JKingWeb\Arsse\Test\AbstractTest {
|
class TestRule extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
|
@ -32,12 +31,7 @@ class TestRule extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
public function testApplyRules(string $keepRule, string $blockRule, string $title, array $categories, $exp): void {
|
public function testApplyRules(string $keepRule, string $blockRule, string $title, array $categories, $exp): void {
|
||||||
$keepRule = Rule::prep($keepRule);
|
$keepRule = Rule::prep($keepRule);
|
||||||
$blockRule = Rule::prep($blockRule);
|
$blockRule = Rule::prep($blockRule);
|
||||||
if ($exp instanceof \Exception) {
|
$this->assertSame($exp, Rule::apply($keepRule, $blockRule, $title, $categories));
|
||||||
$this->assertException($exp);
|
|
||||||
Rule::apply($keepRule, $blockRule, $title, $categories);
|
|
||||||
} else {
|
|
||||||
$this->assertSame($exp, Rule::apply($keepRule, $blockRule, $title, $categories));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideApplications(): iterable {
|
public function provideApplications(): iterable {
|
||||||
|
|
|
@ -451,7 +451,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
["", new ErrorResponse(["InvalidCategory", 'title' => ""], 422)],
|
["", new ErrorResponse(["InvalidCategory", 'title' => ""], 422)],
|
||||||
[" ", new ErrorResponse(["InvalidCategory", 'title' => " "], 422)],
|
[" ", new ErrorResponse(["InvalidCategory", 'title' => " "], 422)],
|
||||||
[null, new ErrorResponse(["MissingInputValue", 'field' => "title"], 422)],
|
[null, new ErrorResponse(["MissingInputValue", 'field' => "title"], 422)],
|
||||||
[false, new ErrorResponse(["InvalidInputType", 'field' => "title", 'actual' => "boolean", 'expected' => "string"],422)],
|
[false, new ErrorResponse(["InvalidInputType", 'field' => "title", 'actual' => "boolean", 'expected' => "string"], 422)],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ namespace JKingWeb\Arsse\TestCase\User;
|
||||||
use JKingWeb\Arsse\Arsse;
|
use JKingWeb\Arsse\Arsse;
|
||||||
use JKingWeb\Arsse\Database;
|
use JKingWeb\Arsse\Database;
|
||||||
use JKingWeb\Arsse\User\Driver as DriverInterface;
|
use JKingWeb\Arsse\User\Driver as DriverInterface;
|
||||||
use JKingWeb\Arsse\User\ExceptionConflict;
|
|
||||||
use JKingWeb\Arsse\User\Internal\Driver;
|
use JKingWeb\Arsse\User\Internal\Driver;
|
||||||
|
|
||||||
/** @covers \JKingWeb\Arsse\User\Internal\Driver */
|
/** @covers \JKingWeb\Arsse\User\Internal\Driver */
|
||||||
|
|
|
@ -200,7 +200,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
\Phake::when($this->drv)->userRename->thenReturn(true);
|
\Phake::when($this->drv)->userRename->thenReturn(true);
|
||||||
$u = new User($this->drv);
|
$u = new User($this->drv);
|
||||||
$old = "john.doe@example.com";
|
$old = "john.doe@example.com";
|
||||||
$new = "jane.doe@example.com";
|
$new = "jane.doe@example.com";
|
||||||
$this->assertTrue($u->rename($old, $new));
|
$this->assertTrue($u->rename($old, $new));
|
||||||
\Phake::inOrder(
|
\Phake::inOrder(
|
||||||
\Phake::verify($this->drv)->userRename($old, $new),
|
\Phake::verify($this->drv)->userRename($old, $new),
|
||||||
|
@ -222,7 +222,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
\Phake::when($this->drv)->userRename->thenReturn(true);
|
\Phake::when($this->drv)->userRename->thenReturn(true);
|
||||||
$u = new User($this->drv);
|
$u = new User($this->drv);
|
||||||
$old = "john.doe@example.com";
|
$old = "john.doe@example.com";
|
||||||
$new = "jane.doe@example.com";
|
$new = "jane.doe@example.com";
|
||||||
$this->assertTrue($u->rename($old, $new));
|
$this->assertTrue($u->rename($old, $new));
|
||||||
\Phake::inOrder(
|
\Phake::inOrder(
|
||||||
\Phake::verify($this->drv)->userRename($old, $new),
|
\Phake::verify($this->drv)->userRename($old, $new),
|
||||||
|
|
Loading…
Reference in a new issue