/** * This test is for an edge case, where there is an issue with the server * during the delete operation * @test */ public function it_should_fail_to_reopen_the_initial_folder_after_deletion() { $imap = $this->getImap(); /** @noinspection PhpMethodParametersCountMismatchInspection */ $this->mailbox->shouldReceive('setFolder')->once()->with('INBOX.Trash'); /** @noinspection PhpMethodParametersCountMismatchInspection */ $this->mailbox->shouldReceive('setFolder')->once()->with('INBOX'); /** @noinspection PhpUndefinedMethodInspection */ $this->mailbox->shouldReceive('getFolder')->andReturn('INBOX'); /** @noinspection PhpUndefinedMethodInspection */ $imap->shouldReceive('deleteMessages')->andReturn(true); /** @noinspection PhpUndefinedMethodInspection */ $imap->shouldReceive('setMessagesForDeletion')->with('1:*')->andReturn(true); /** @noinspection PhpUndefinedMethodInspection */ $imap->shouldReceive('getMailbox')->andReturn($this->mailbox); /** @noinspection PhpUndefinedMethodInspection */ $this->connection->shouldReceive('closeConnection'); /** @noinspection PhpUndefinedMethodInspection */ $this->connection->shouldReceive('refresh')->once()->andReturn(true); /** @noinspection PhpUndefinedMethodInspection */ $this->connection->shouldReceive('refresh')->once()->andReturn(false); $this->setExpectedException('Exception', 'Unable to re-open folder INBOX Connection has been closed'); $mailboxManager = new ImapMailboxService($imap, __DIR__ . '/imap_config/config.php'); $mailboxManager->deleteAllMessages('trash'); }