mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Basic path resolution tests
This commit is contained in:
parent
bab64add9b
commit
dfaf44ac68
1 changed files with 22 additions and 2 deletions
|
@ -30,7 +30,27 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
$this->daemon = $this->partialMock(Daemon::class);
|
$this->daemon = $this->partialMock(Daemon::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @dataProvider providePidChecks */
|
/** @dataProvider providePathResolutions */
|
||||||
|
public function testResolveRelativePaths(string $path, $cwd, $exp): void {
|
||||||
|
// set up mock daemon class
|
||||||
|
$this->daemon->cwd->returns($cwd);
|
||||||
|
$daemon = $this->daemon->get();
|
||||||
|
// perform the test
|
||||||
|
$this->AssertSame($exp, $daemon->resolveRelativePath($path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function providePathResolutions(): iterable {
|
||||||
|
return [
|
||||||
|
["/", "/home/me", "/"],
|
||||||
|
["/.", "/home/me", "/"],
|
||||||
|
["/..", "/home/me", "/"],
|
||||||
|
["/run", "/home/me", "/run"],
|
||||||
|
["/./run", "/home/me", "/run"],
|
||||||
|
["/../run", "/home/me", "/run"],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @dataProvider providePidFileChecks */
|
||||||
public function testCheckPidFiles(string $file, bool $accessible, $exp): void {
|
public function testCheckPidFiles(string $file, bool $accessible, $exp): void {
|
||||||
$vfs = vfsStream::setup("pidtest", 0777, $this->pidfiles);
|
$vfs = vfsStream::setup("pidtest", 0777, $this->pidfiles);
|
||||||
$path = $vfs->url()."/";
|
$path = $vfs->url()."/";
|
||||||
|
@ -51,7 +71,7 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function providePidChecks(): iterable {
|
public function providePidFileChecks(): iterable {
|
||||||
return [
|
return [
|
||||||
["ok/file", false, new Exception("pidDirUnresolvable")],
|
["ok/file", false, new Exception("pidDirUnresolvable")],
|
||||||
["not/found", true, new Exception("pidDirMissing")],
|
["not/found", true, new Exception("pidDirMissing")],
|
||||||
|
|
Loading…
Reference in a new issue