Browse Source

Style fixes

rpm
J. King 3 years ago
parent
commit
ad32bf3340
  1. 4
      CHANGELOG
  2. 12
      RoboFile.php
  3. 3
      composer.json
  4. 2
      lib/REST/Miniflux/Token.php
  5. 12
      lib/Service.php
  6. 12
      lib/Service/Daemon.php
  7. 2
      tests/cases/CLI/TestCLI.php
  8. 4
      tests/cases/Database/SeriesSubscription.php
  9. 2
      tests/cases/Db/SQLite3/TestCreation.php
  10. 1
      tests/cases/ImportExport/TestOPML.php
  11. 1
      tests/cases/Misc/TestValueInfo.php
  12. 1
      tests/cases/REST/Fever/TestAPI.php
  13. 2
      tests/cases/REST/Fever/TestUser.php
  14. 2
      tests/cases/REST/TestREST.php
  15. 3
      tests/cases/REST/TinyTinyRSS/TestAPI.php
  16. 2
      tests/cases/Service/TestDaemon.php
  17. 1
      tests/cases/Service/TestService.php
  18. 12
      tests/cases/User/TestUser.php
  19. 2
      tests/lib/AbstractTest.php

4
CHANGELOG

@ -1,8 +1,10 @@
Version 0.9.3 (2021-??-??) Version 0.10.0 (2021-??-??)
========================== ==========================
New features: New features:
- Complete UNIX manual page - Complete UNIX manual page
- Support for running service as a forking daemon
- Respond to TERM and HUP signals when possible
Version 0.9.2 (2021-05-25) Version 0.9.2 (2021-05-25)
========================== ==========================

12
RoboFile.php

@ -328,8 +328,8 @@ class RoboFile extends \Robo\Tasks {
} }
/** Generates the "arsse" command's manual page (UNIX man page) /** Generates the "arsse" command's manual page (UNIX man page)
* *
* This requires that the Pandoc document converter be installed and * This requires that the Pandoc document converter be installed and
* available in $PATH. * available in $PATH.
*/ */
public function manpage(): Result { public function manpage(): Result {
@ -337,7 +337,7 @@ class RoboFile extends \Robo\Tasks {
$man = [ $man = [
'en' => "man1/arsse.1", 'en' => "man1/arsse.1",
]; ];
foreach($man as $src => $out) { foreach ($man as $src => $out) {
$src = BASE."manpages/$src.md"; $src = BASE."manpages/$src.md";
$out = BASE."dist/man/$out"; $out = BASE."dist/man/$out";
$t->addTask($this->taskFilesystemStack()->mkdir(dirname($out), 0755)); $t->addTask($this->taskFilesystemStack()->mkdir(dirname($out), 0755));
@ -371,7 +371,7 @@ class RoboFile extends \Robo\Tasks {
} }
if ($entry) { if ($entry) {
$out[] = $entry; $out[] = $entry;
} }
$entry = ['version' => $version, 'date' => $date, 'features' => [], 'fixes' => [], 'changes' => []]; $entry = ['version' => $version, 'date' => $date, 'features' => [], 'fixes' => [], 'changes' => []];
$expected = ["separator"]; $expected = ["separator"];
} elseif (in_array("separator", $expected) && preg_match('/^=+/', $l)) { } elseif (in_array("separator", $expected) && preg_match('/^=+/', $l)) {
@ -422,7 +422,7 @@ class RoboFile extends \Robo\Tasks {
$out[] = $entry; $out[] = $entry;
return $out; return $out;
} }
protected function changelogDebian(array $log, string $targetVersion): string { protected function changelogDebian(array $log, string $targetVersion): string {
$latest = $log[0]['version']; $latest = $log[0]['version'];
$baseVersion = preg_replace('/^(\d+(?:\.\d+)*).*/', "$1", $targetVersion); $baseVersion = preg_replace('/^(\d+(?:\.\d+)*).*/', "$1", $targetVersion);
@ -481,6 +481,6 @@ class RoboFile extends \Robo\Tasks {
// change the user reference in the executable file // change the user reference in the executable file
$t->addTask($this->taskFilesystemStack()->mkdir($dir."dist/debian/bin")); $t->addTask($this->taskFilesystemStack()->mkdir($dir."dist/debian/bin"));
$t->addTask($this->taskFilesystemStack()->copy($dir."dist/arsse", $dir."dist/debian/bin/arsse")); $t->addTask($this->taskFilesystemStack()->copy($dir."dist/arsse", $dir."dist/debian/bin/arsse"));
$t->addTask($this->taskReplaceInFile($dir."dist/debian/bin/arsse")->from('posix_getpwnam("arsse"')->to('posix_getpwnam("www-data"')); $t->addTask($this->taskReplaceInFile($dir."dist/debian/bin/arsse")->from('posix_getpwnam("arsse"')->to('posix_getpwnam("www-data"'));
} }
} }

3
composer.json

@ -34,6 +34,9 @@
"require-dev": { "require-dev": {
"bamarni/composer-bin-plugin": "*" "bamarni/composer-bin-plugin": "*"
}, },
"suggest": {
"ext-pcntl": "To respond to signals, particular to reload configuration via SIGHUP"
},
"config": { "config": {
"platform": { "platform": {
"php": "7.1.33" "php": "7.1.33"

2
lib/REST/Miniflux/Token.php

@ -28,4 +28,4 @@ class Token {
} }
return $out; return $out;
} }
} }

12
lib/Service.php

@ -44,9 +44,11 @@ class Service {
if ($this->loop) { if ($this->loop) {
do { do {
sleep((int) max(0, $t->getTimestamp() - time())); sleep((int) max(0, $t->getTimestamp() - time()));
pcntl_signal_dispatch(); if (function_exists("pcntl_signal_dispatch")) {
if ($this->reload) { pcntl_signal_dispatch();
$this->reload(); if ($this->reload) {
$this->reload();
}
} }
} while ($this->loop && $t->getTimestamp() > time()); } while ($this->loop && $t->getTimestamp() > time());
} }
@ -117,14 +119,14 @@ class Service {
} }
/** Changes the condition for the service loop upon receiving a termination signal /** Changes the condition for the service loop upon receiving a termination signal
* *
* @codeCoverageIgnore */ * @codeCoverageIgnore */
protected function sigTerm(int $signo): void { protected function sigTerm(int $signo): void {
$this->loop = false; $this->loop = false;
} }
/** Changes the condition for the service loop upon receiving a hangup signal /** Changes the condition for the service loop upon receiving a hangup signal
* *
* @codeCoverageIgnore */ * @codeCoverageIgnore */
protected function sigHup(int $signo): void { protected function sigHup(int $signo): void {
$this->reload = true; $this->reload = true;

12
lib/Service/Daemon.php

@ -18,7 +18,7 @@ class Daemon {
} }
/** Daemonizes the process via the traditional sysvinit double-fork procedure /** Daemonizes the process via the traditional sysvinit double-fork procedure
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function fork(string $pidfile): void { public function fork(string $pidfile): void {
@ -144,7 +144,7 @@ class Daemon {
} }
/** Wrapper around posix_kill (with signal 0) to facilitation testing /** Wrapper around posix_kill (with signal 0) to facilitation testing
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
protected function processExists(int $pid): bool { protected function processExists(int $pid): bool {
@ -182,14 +182,14 @@ class Daemon {
} }
/** Resolves paths with relative components /** Resolves paths with relative components
* *
* This method has fewer filesystem access requirements than the native * This method has fewer filesystem access requirements than the native
* realpath() function. The current working directory most be resolvable * realpath() function. The current working directory most be resolvable
* for a relative path, but for absolute paths with relativelu components * for a relative path, but for absolute paths with relativelu components
* the filesystem is not involved at all. * the filesystem is not involved at all.
* *
* Consequently symbolic links are not resolved. * Consequently symbolic links are not resolved.
* *
* @return string|false * @return string|false
*/ */
public function resolveRelativePath(string $path) { public function resolveRelativePath(string $path) {
@ -216,7 +216,7 @@ class Daemon {
} }
/** Wrapper around posix_getcwd to facilitate testing /** Wrapper around posix_getcwd to facilitate testing
* *
* @return string|false * @return string|false
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

2
tests/cases/CLI/TestCLI.php

@ -102,7 +102,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
$this->objMock->get->with(Daemon::class)->returns($daemon->get()); $this->objMock->get->with(Daemon::class)->returns($daemon->get());
$this->assertConsole("arsse.php daemon --fork=arsse.pid", 10809); $this->assertConsole("arsse.php daemon --fork=arsse.pid", 10809);
$daemon->checkPIDFilePath->calledWith("arsse.pid"); $daemon->checkPIDFilePath->calledWith("arsse.pid");
$daemon->fork->never()->called(); $daemon->fork->never()->called();
$this->cli->loadConf->never()->called(); $this->cli->loadConf->never()->called();
$srv->watch->never()->called(); $srv->watch->never()->called();
} }

4
tests/cases/Database/SeriesSubscription.php

@ -45,8 +45,8 @@ trait SeriesSubscription {
], ],
'arsse_icons' => [ 'arsse_icons' => [
'columns' => [ 'columns' => [
'id' => "int", 'id' => "int",
'url' => "str", 'url' => "str",
'data' => "blob", 'data' => "blob",
], ],
'rows' => [ 'rows' => [

2
tests/cases/Db/SQLite3/TestCreation.php

@ -196,6 +196,6 @@ class TestCreation extends \JKingWeb\Arsse\Test\AbstractTest {
// check the mode // check the mode
clearstatcache(); clearstatcache();
$mode = base_convert((string) stat($f)['mode'], 10, 8); $mode = base_convert((string) stat($f)['mode'], 10, 8);
$this->assertMatchesRegularExpression("/640$/", $mode); $this->assertMatchesRegularExpression("/640$/", $mode);
} }
} }

1
tests/cases/ImportExport/TestOPML.php

@ -11,7 +11,6 @@ use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\Test\Result; use JKingWeb\Arsse\Test\Result;
use JKingWeb\Arsse\ImportExport\OPML; use JKingWeb\Arsse\ImportExport\OPML;
use JKingWeb\Arsse\ImportExport\Exception; use JKingWeb\Arsse\ImportExport\Exception;
use ReflectionMethod;
/** @covers \JKingWeb\Arsse\ImportExport\OPML<extended> */ /** @covers \JKingWeb\Arsse\ImportExport\OPML<extended> */
class TestOPML extends \JKingWeb\Arsse\Test\AbstractTest { class TestOPML extends \JKingWeb\Arsse\Test\AbstractTest {

1
tests/cases/Misc/TestValueInfo.php

@ -12,7 +12,6 @@ use JKingWeb\Arsse\Test\Result;
/** @covers \JKingWeb\Arsse\Misc\ValueInfo */ /** @covers \JKingWeb\Arsse\Misc\ValueInfo */
class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest { class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
public function testGetIntegerInfo(): void { public function testGetIntegerInfo(): void {
$tests = [ $tests = [
[null, I::NULL], [null, I::NULL],

1
tests/cases/REST/Fever/TestAPI.php

@ -15,7 +15,6 @@ use JKingWeb\Arsse\Db\ExceptionInput;
use JKingWeb\Arsse\Db\Transaction; use JKingWeb\Arsse\Db\Transaction;
use JKingWeb\Arsse\REST\Fever\API; use JKingWeb\Arsse\REST\Fever\API;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Laminas\Diactoros\ServerRequest;
use Laminas\Diactoros\Response\JsonResponse; use Laminas\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\XmlResponse; use Laminas\Diactoros\Response\XmlResponse;
use Laminas\Diactoros\Response\EmptyResponse; use Laminas\Diactoros\Response\EmptyResponse;

2
tests/cases/REST/Fever/TestUser.php

@ -34,7 +34,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
Arsse::$db = $this->dbMock->get(); Arsse::$db = $this->dbMock->get();
// instantiate the handler // instantiate the handler
return new FeverUser; return new FeverUser;
} }
/** @dataProvider providePasswordCreations */ /** @dataProvider providePasswordCreations */
public function testRegisterAUserPassword(string $user, string $password = null, $exp): void { public function testRegisterAUserPassword(string $user, string $password = null, $exp): void {

2
tests/cases/REST/TestREST.php

@ -306,7 +306,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
if ($called) { if ($called) {
$rMock->authenticateRequest->called(); $rMock->authenticateRequest->called();
$hMock->dispatch->once()->called(); $hMock->dispatch->once()->called();
$in = $hMock->dispatch->firstCall()->argument();; $in = $hMock->dispatch->firstCall()->argument();
$this->assertSame($method, $in->getMethod()); $this->assertSame($method, $in->getMethod());
$this->assertSame($target, $in->getRequestTarget()); $this->assertSame($target, $in->getRequestTarget());
} else { } else {

3
tests/cases/REST/TinyTinyRSS/TestAPI.php

@ -899,7 +899,7 @@ LONG_STRING;
[['caption' => " "], [$this->userId, ['name' => " "]], new ExceptionInput("typeViolation"), null, null, $this->respErr("INCORRECT_USAGE")], [['caption' => " "], [$this->userId, ['name' => " "]], new ExceptionInput("typeViolation"), null, null, $this->respErr("INCORRECT_USAGE")],
]; ];
} }
/** @dataProvider provideLabelRemovals */ /** @dataProvider provideLabelRemovals */
public function testRemoveALabel(array $in, ?array $data, $out, ResponseInterface $exp): void { public function testRemoveALabel(array $in, ?array $data, $out, ResponseInterface $exp): void {
$in = array_merge(['op' => "removeLabel", 'sid' => "PriestsOfSyrinx"], $in); $in = array_merge(['op' => "removeLabel", 'sid' => "PriestsOfSyrinx"], $in);
@ -1356,7 +1356,6 @@ LONG_STRING;
]; ];
} }
/** @dataProvider provideArticleChanges */ /** @dataProvider provideArticleChanges */
public function testChangeArticles(array $in, ResponseInterface $exp): void { public function testChangeArticles(array $in, ResponseInterface $exp): void {
$in = array_merge(['op' => "updateArticle", 'sid' => "PriestsOfSyrinx"], $in); $in = array_merge(['op' => "updateArticle", 'sid' => "PriestsOfSyrinx"], $in);

2
tests/cases/Service/TestDaemon.php

@ -20,7 +20,7 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
'readwrite' => "can neither be read nor written to", 'readwrite' => "can neither be read nor written to",
], ],
'ok' => [ 'ok' => [
'dir' => [], 'dir' => [],
'file' => "this file can be fully accessed", 'file' => "this file can be fully accessed",
], ],
'pid' => [ 'pid' => [

1
tests/cases/Service/TestService.php

@ -23,7 +23,6 @@ class TestService extends \JKingWeb\Arsse\Test\AbstractTest {
$this->srv = new Service(); $this->srv = new Service();
} }
public function testCheckIn(): void { public function testCheckIn(): void {
$now = time(); $now = time();
$this->srv->checkIn(); $this->srv->checkIn();

12
tests/cases/User/TestUser.php

@ -21,12 +21,12 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
parent::setUp(); parent::setUp();
self::setConf(); self::setConf();
// create a mock database interface // create a mock database interface
$this->dbMock= $this->mock(Database::class); $this->dbMock = $this->mock(Database::class);
$this->dbMock->begin->returns($this->mock(\JKingWeb\Arsse\Db\Transaction::class)); $this->dbMock->begin->returns($this->mock(\JKingWeb\Arsse\Db\Transaction::class));
// create a mock user driver // create a mock user driver
$this->drv = $this->mock(Driver::class); $this->drv = $this->mock(Driver::class);
} }
protected function prepTest(?\Closure $partialMockDef = null): User { protected function prepTest(?\Closure $partialMockDef = null): User {
Arsse::$db = $this->dbMock->get(); Arsse::$db = $this->dbMock->get();
if ($partialMockDef) { if ($partialMockDef) {
@ -189,7 +189,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
$pass = "random password"; $pass = "random password";
$this->drv->userAdd->returns(null)->returns($pass); $this->drv->userAdd->returns(null)->returns($pass);
$this->dbMock->userExists->returns(true); $this->dbMock->userExists->returns(true);
$u = $this->prepTest(function ($u) use ($pass) { $u = $this->prepTest(function($u) use ($pass) {
$u->generatePassword->returns($pass); $u->generatePassword->returns($pass);
}); });
$this->assertSame($pass, $u->add($user)); $this->assertSame($pass, $u->add($user));
@ -330,7 +330,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
$this->drv->userPasswordSet->returns(null)->returns($pass); $this->drv->userPasswordSet->returns(null)->returns($pass);
$this->dbMock->userPasswordSet->returns($pass); $this->dbMock->userPasswordSet->returns($pass);
$this->dbMock->userExists->returns(true); $this->dbMock->userExists->returns(true);
$u = $this->prepTest(function ($u) use ($pass) { $u = $this->prepTest(function($u) use ($pass) {
$u->generatePassword->returns($pass); $u->generatePassword->returns($pass);
}); });
$this->assertSame($pass, $u->passwordSet($user, null)); $this->assertSame($pass, $u->passwordSet($user, null));
@ -360,7 +360,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
$this->drv->userPasswordSet->returns(null)->returns($pass); $this->drv->userPasswordSet->returns(null)->returns($pass);
$this->dbMock->userPasswordSet->returns($pass); $this->dbMock->userPasswordSet->returns($pass);
$this->dbMock->userExists->returns(false); $this->dbMock->userExists->returns(false);
$u = $this->prepTest(function ($u) use ($pass) { $u = $this->prepTest(function($u) use ($pass) {
$u->generatePassword->returns($pass); $u->generatePassword->returns($pass);
}); });
$this->assertSame($pass, $u->passwordSet($user, null)); $this->assertSame($pass, $u->passwordSet($user, null));
@ -374,7 +374,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$pass = "random password"; $pass = "random password";
$this->drv->userPasswordSet->throws(new ExceptionConflict("doesNotExist")); $this->drv->userPasswordSet->throws(new ExceptionConflict("doesNotExist"));
$u = $this->prepTest(function ($u) use ($pass) { $u = $this->prepTest(function($u) use ($pass) {
$u->generatePassword->returns($pass); $u->generatePassword->returns($pass);
}); });
$this->assertException("doesNotExist", "User", "ExceptionConflict"); $this->assertException("doesNotExist", "User", "ExceptionConflict");

2
tests/lib/AbstractTest.php

@ -36,7 +36,6 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
protected $langMock; protected $langMock;
protected $dbMock; protected $dbMock;
protected $userMock; protected $userMock;
public function setUp(): void { public function setUp(): void {
self::clearData(); self::clearData();
@ -155,7 +154,6 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
} else { } else {
parent::assertFileNotExists($filename, $message); parent::assertFileNotExists($filename, $message);
} }
} }
public function assertException($msg = "", string $prefix = "", string $type = "Exception"): void { public function assertException($msg = "", string $prefix = "", string $type = "Exception"): void {

Loading…
Cancel
Save