diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2021-01-19 12:30:48 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-01-30 18:27:06 +0100 |
commit | 023c61b88f3bfdc3829606a17fa3bf9deac600fc (patch) | |
tree | e17552831645e05366089ef1f3373a03415c8b6d /tests/Unit/Command | |
parent | 191860fc7210b51032f3026491ed745508209936 (diff) |
Mappers: Implement item purging
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'tests/Unit/Command')
-rw-r--r-- | tests/Unit/Command/AfterUpdateTest.php | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/tests/Unit/Command/AfterUpdateTest.php b/tests/Unit/Command/AfterUpdateTest.php index fbc327ecc..81fd175cf 100644 --- a/tests/Unit/Command/AfterUpdateTest.php +++ b/tests/Unit/Command/AfterUpdateTest.php @@ -62,17 +62,77 @@ class AfterUpdateTest extends TestCase { $this->consoleInput->expects($this->once()) ->method('getArgument') - ->with('purge_count') + ->with('purge-count') ->willReturn('1'); + $this->consoleInput->expects($this->once()) + ->method('getOption') + ->with('purge-unread') + ->willReturn(false); + + $this->service->expects($this->exactly(1)) + ->method('purgeOverThreshold') + ->with('1', false) + ->willReturn(1); + + $this->consoleOutput->expects($this->exactly(1)) + ->method('writeln') + ->with('Removed 1 item(s)'); + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(0, $result); + } + + /** + * Test a valid call will work + */ + public function testValidEmpty() + { + $this->consoleInput->expects($this->once()) + ->method('getArgument') + ->with('purge-count') + ->willReturn('1'); + $this->consoleInput->expects($this->once()) + ->method('getOption') + ->with('purge-unread') + ->willReturn(false); + + + $this->service->expects($this->exactly(1)) + ->method('purgeOverThreshold') + ->with('1', false) + ->willReturn(null); + + $this->consoleOutput->expects($this->exactly(1)) + ->method('writeln') + ->with('No cleanup needed'); + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(0, $result); + } + + /** + * Test a valid call will work + */ + public function testValidEmptyUnread() + { + $this->consoleInput->expects($this->once()) + ->method('getArgument') + ->with('purge-count') + ->willReturn('1'); + $this->consoleInput->expects($this->once()) + ->method('getOption') + ->with('purge-unread') + ->willReturn(true); + $this->service->expects($this->exactly(1)) ->method('purgeOverThreshold') - ->with('1') - ->willReturn('test'); + ->with('1', true) + ->willReturn(null); $this->consoleOutput->expects($this->exactly(1)) ->method('writeln') - ->with('test'); + ->with('No cleanup needed'); $result = $this->command->run($this->consoleInput, $this->consoleOutput); $this->assertSame(0, $result); |