1
1
Fork 0
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:
J. King 2020-11-13 21:41:27 -05:00
parent 4baf5fa2f9
commit 351f972512

View file

@ -121,4 +121,41 @@ class TestInternal extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertException("doesNotExist", "User"); $this->assertException("doesNotExist", "User");
(new Driver)->userPasswordUnset("john.doe@example.com"); (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);
}
}
} }