mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-03 14:32:40 +00:00
Tests for internal user driver
This commit is contained in:
parent
4baf5fa2f9
commit
351f972512
1 changed files with 37 additions and 0 deletions
|
@ -121,4 +121,41 @@ class TestInternal extends \JKingWeb\Arsse\Test\AbstractTest {
|
|||
$this->assertException("doesNotExist", "User");
|
||||
(new Driver)->userPasswordUnset("john.doe@example.com");
|
||||
}
|
||||
|
||||
public function testGetUserProperties(): void {
|
||||
\Phake::when(Arsse::$db)->userExists->thenReturn(true);
|
||||
$this->assertSame([], (new Driver)->userPropertiesGet("john.doe@example.com"));
|
||||
\Phake::verify(Arsse::$db)->userExists("john.doe@example.com");
|
||||
\Phake::verifyNoFurtherInteraction(Arsse::$db);
|
||||
}
|
||||
|
||||
public function testGetPropertiesForAMissingUser(): void {
|
||||
\Phake::when(Arsse::$db)->userExists->thenReturn(false);
|
||||
$this->assertException("doesNotExist", "User");
|
||||
try {
|
||||
(new Driver)->userPropertiesGet("john.doe@example.com");
|
||||
} finally {
|
||||
\Phake::verify(Arsse::$db)->userExists("john.doe@example.com");
|
||||
\Phake::verifyNoFurtherInteraction(Arsse::$db);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetUserProperties(): void {
|
||||
$in = ['admin' => true];
|
||||
\Phake::when(Arsse::$db)->userExists->thenReturn(true);
|
||||
$this->assertSame($in, (new Driver)->userPropertiesSet("john.doe@example.com", $in));
|
||||
\Phake::verify(Arsse::$db)->userExists("john.doe@example.com");
|
||||
\Phake::verifyNoFurtherInteraction(Arsse::$db);
|
||||
}
|
||||
|
||||
public function testSetPropertiesForAMissingUser(): void {
|
||||
\Phake::when(Arsse::$db)->userExists->thenReturn(false);
|
||||
$this->assertException("doesNotExist", "User");
|
||||
try {
|
||||
(new Driver)->userPropertiesSet("john.doe@example.com", ['admin' => true]);
|
||||
} finally {
|
||||
\Phake::verify(Arsse::$db)->userExists("john.doe@example.com");
|
||||
\Phake::verifyNoFurtherInteraction(Arsse::$db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue