2019-10-19 22:51:01 +00:00
|
|
|
<?php
|
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2021-04-14 15:17:01 +00:00
|
|
|
|
2019-10-19 22:51:01 +00:00
|
|
|
namespace JKingWeb\Arsse\TestCase\Service;
|
|
|
|
|
|
|
|
use JKingWeb\Arsse\Arsse;
|
|
|
|
use JKingWeb\Arsse\Service\Driver as DriverInterface;
|
|
|
|
use JKingWeb\Arsse\Service\Subprocess\Driver;
|
|
|
|
|
|
|
|
/** @covers \JKingWeb\Arsse\Service\Subprocess\Driver */
|
|
|
|
class TestSubprocess extends \JKingWeb\Arsse\Test\AbstractTest {
|
2019-11-14 17:05:10 +00:00
|
|
|
public function setUp(): void {
|
2021-02-27 20:24:02 +00:00
|
|
|
parent::setUp();
|
2019-10-19 22:51:01 +00:00
|
|
|
self::setConf();
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testConstruct(): void {
|
2019-10-19 22:51:01 +00:00
|
|
|
$this->assertTrue(Driver::requirementsMet());
|
|
|
|
$this->assertInstanceOf(DriverInterface::class, new Driver);
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testFetchDriverName(): void {
|
2019-10-19 22:51:01 +00:00
|
|
|
$this->assertTrue(strlen(Driver::driverName()) > 0);
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testEnqueueFeeds(): void {
|
2019-10-19 22:51:01 +00:00
|
|
|
$d = new Driver;
|
|
|
|
$this->assertSame(3, $d->queue(1, 2, 3));
|
|
|
|
$this->assertSame(5, $d->queue(4, 5));
|
|
|
|
$this->assertSame(5, $d->clean());
|
|
|
|
$this->assertSame(1, $d->queue(5));
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRefreshFeeds(): void {
|
2021-03-01 23:01:25 +00:00
|
|
|
$dMock = $this->partialMock(Driver::class);
|
|
|
|
$dMock->execCmd->does(function(string $cmd) {
|
2019-10-19 22:51:01 +00:00
|
|
|
// FIXME: Does this work in Windows?
|
|
|
|
return popen("echo ".escapeshellarg($cmd), "r");
|
|
|
|
});
|
2021-03-01 23:01:25 +00:00
|
|
|
$d = $dMock->get();
|
2019-10-19 22:51:01 +00:00
|
|
|
$this->assertSame(3, $d->queue(1, 4, 3));
|
|
|
|
$this->assertSame(Arsse::$conf->serviceQueueWidth, $d->exec());
|
2021-03-01 23:01:25 +00:00
|
|
|
$dMock->execCmd->times(3)->called();
|
2019-10-19 22:51:01 +00:00
|
|
|
}
|
|
|
|
}
|