From 351f97251273fe14b859caac6a938a355f9ea384 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 13 Nov 2020 21:41:27 -0500 Subject: [PATCH] Tests for internal user driver --- tests/cases/User/TestInternal.php | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/cases/User/TestInternal.php b/tests/cases/User/TestInternal.php index 21587f3..cd231a0 100644 --- a/tests/cases/User/TestInternal.php +++ b/tests/cases/User/TestInternal.php @@ -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); + } + } }