mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Additional service tests
This commit is contained in:
parent
bad86cedb3
commit
728eecfbb5
4 changed files with 26 additions and 1 deletions
|
@ -264,6 +264,7 @@ class Conf {
|
|||
$type |= Value::M_NULL;
|
||||
}
|
||||
} else {
|
||||
// catch-all for custom properties
|
||||
$type = Value::T_MIXED; // @codeCoverageIgnore
|
||||
}
|
||||
$out[$p->name] = ['name' => $match[0], 'const' => $type];
|
||||
|
@ -286,6 +287,7 @@ class Conf {
|
|||
}
|
||||
switch (self::EXPECTED_TYPES[$key] ?? gettype($this->$key)) {
|
||||
case "integer":
|
||||
// no properties are currently typed as integers
|
||||
return Value::normalize($value, Value::T_INT | $mode); // @codeCoverageIgnore
|
||||
case "double":
|
||||
return Value::normalize($value, Value::T_FLOAT | $mode);
|
||||
|
@ -293,6 +295,7 @@ class Conf {
|
|||
case "object":
|
||||
return $value;
|
||||
default:
|
||||
// this should never occur
|
||||
throw new Conf\Exception("ambiguousDefault", ['param' => $key]); // @codeCoverageIgnore
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
|||
// indexed arrays
|
||||
$p->appendChild($this->makeXMLIndexed($v, $d->createElement($k), substr($k, 0, strlen($k) - 1)));
|
||||
} else {
|
||||
// this case does not actually occur in a proper Fever response
|
||||
// this case is never encountered with Fever's output
|
||||
$p->appendChild($this->makeXMLAssoc($v, $d->createElement($k))); // @codeCoverageIgnore
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,11 +40,13 @@ class Service {
|
|||
}
|
||||
static::cleanupPost();
|
||||
$t->add($this->interval);
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($loop) {
|
||||
do {
|
||||
@time_sleep_until($t->getTimestamp());
|
||||
} while ($t->getTimestamp() > time());
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
} while ($loop);
|
||||
return $t;
|
||||
}
|
||||
|
|
|
@ -39,4 +39,24 @@ class TestService extends \JKingWeb\Arsse\Test\AbstractTest {
|
|||
$this->assertTrue(Service::hasCheckedIn());
|
||||
$this->assertFalse(Service::hasCheckedIn());
|
||||
}
|
||||
|
||||
public function testPerformPreCleanup() {
|
||||
$this->assertTrue(Service::cleanupPre());
|
||||
\Phake::verify(Arsse::$db)->feedCleanup();
|
||||
\Phake::verify(Arsse::$db)->sessionCleanup();
|
||||
}
|
||||
|
||||
public function testPerformShortPostCleanup() {
|
||||
\Phake::when(Arsse::$db)->articleCleanup()->thenReturn(0);
|
||||
$this->assertTrue(Service::cleanupPost());
|
||||
\Phake::verify(Arsse::$db)->articleCleanup();
|
||||
\Phake::verify(Arsse::$db, \Phake::times(0))->driverMaintenance();
|
||||
}
|
||||
|
||||
public function testPerformFullPostCleanup() {
|
||||
\Phake::when(Arsse::$db)->articleCleanup()->thenReturn(1);
|
||||
$this->assertTrue(Service::cleanupPost());
|
||||
\Phake::verify(Arsse::$db)->articleCleanup();
|
||||
\Phake::verify(Arsse::$db)->driverMaintenance();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue