Skip to content

Commit

Permalink
Ignoring unexpected server responses
Browse files Browse the repository at this point in the history
  • Loading branch information
raoul committed Jul 25, 2018
1 parent 2dd14a4 commit 4c7485b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/Smtp/AsyncSmtpConnectionWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ private function processDataResponse(string $data): void
$this->dataProcessingPromise = new \React\Promise\Deferred();

$this->logger->debug('RECEIVED DATA: ' . $data);

if (count($this->expectedResponses) === 0) {
throw new \AsyncConnection\Smtp\AsyncSmtpConnectionException(sprintf('Received unexpected data from server: %s.', $data));
return;
}

[$deferred, $expectedCodes, $message, $messageToReplace] = array_shift($this->expectedResponses);
Expand Down
9 changes: 0 additions & 9 deletions tests/Smtp/AsyncSmtpConnectionWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ public function testInvalidStreamThrowsException(): void
new AsyncSmtpConnectionWriter($connectionMock, $this->logger);
}

public function testUnexpectedDataThrowException(): void
{
$this->expectException(\AsyncConnection\Smtp\AsyncSmtpConnectionException::class);
$this->expectExceptionMessage('Received unexpected data from server: 333 unexpectedServerResponse.');

new AsyncSmtpConnectionWriter($this->createConnectionMock(), $this->logger);
$this->runFailedTest('333 unexpectedServerResponse');
}

public function testUnexpectedConnectionEndFromServer(): void
{
$writer = new AsyncSmtpConnectionWriter($this->createConnectionMock(), $this->logger);
Expand Down

0 comments on commit 4c7485b

Please sign in to comment.