Skip to content

Commit

Permalink
Replaced obsolete execute with invoking + corrected imploding of rece…
Browse files Browse the repository at this point in the history
…ived lines.
  • Loading branch information
robinvdvleuten committed Dec 2, 2016
1 parent 99c47e1 commit 9bb6101
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Command/ArticleCommand.php
Expand Up @@ -52,7 +52,7 @@ public function __invoke()
*/
public function onArticleFollows(MultiLineResponse $response)
{
return implode("\r\n", $response->getLines()->toArray());
return implode("\r\n", $response->getLines());
}

public function onNoNewsGroupCurrentSelected(Response $response)
Expand Down
2 changes: 1 addition & 1 deletion src/Command/BodyCommand.php
Expand Up @@ -52,7 +52,7 @@ public function __invoke()
*/
public function onBodyFollows(MultiLineResponse $response)
{
return implode("\r\n", $response->getLines()->toArray());
return implode("\r\n", $response->getLines());
}

public function onNoNewsGroupCurrentSelected(Response $response)
Expand Down
7 changes: 2 additions & 5 deletions src/Connection/Connection.php
Expand Up @@ -113,7 +113,7 @@ public function sendCommand(CommandInterface $command)

public function sendArticle(CommandInterface $command)
{
$commandString = $command->execute();
$commandString = $command();

if (strlen($commandString."\r\n.\r\n") !== $this->socket->write($commandString."\r\n.\r\n")) {
throw new RuntimeException('Failed to write to socket');
Expand Down Expand Up @@ -208,10 +208,7 @@ private function getCompressedResponse(Response $response)
array_pop($lines);
}

$lines = array_filter($lines);
$lines = \SplFixedArray::fromArray($lines);

return new MultiLineResponse($response, $lines);
return new MultiLineResponse($response, array_filter($lines));
}

private function callCommandHandlerForResponse(CommandInterface $command, ResponseInterface $response)
Expand Down
4 changes: 2 additions & 2 deletions tests/Command/ArticleCommandTest.php
Expand Up @@ -46,13 +46,13 @@ public function testItReceivesAResultWhenArticleFollowsResponse()
->disableOriginalConstructor()
->getMock();

$lines = \SplFixedArray::fromArray(['Lorem ipsum dolor sit amet, ', 'consectetur adipiscing elit. ', 'Sed volutpat sit amet leo sit amet sagittis.']);
$lines = ['Lorem ipsum dolor sit amet, ', 'consectetur adipiscing elit. ', 'Sed volutpat sit amet leo sit amet sagittis.'];

$response->expects($this->once())
->method('getLines')
->will($this->returnValue($lines));

$this->assertEquals(implode("\r\n", $lines->toArray()), $command->onArticleFollows($response));
$this->assertEquals(implode("\r\n", $lines), $command->onArticleFollows($response));
}

public function testItErrorsWhenGroupNotSelectedResponse()
Expand Down
4 changes: 2 additions & 2 deletions tests/Command/BodyCommandTest.php
Expand Up @@ -46,13 +46,13 @@ public function testItReceivesAResultWhenBodyFollowsResponse()
->disableOriginalConstructor()
->getMock();

$lines = \SplFixedArray::fromArray(['Lorem ipsum dolor sit amet, ', 'consectetur adipiscing elit. ', 'Sed volutpat sit amet leo sit amet sagittis.']);
$lines = ['Lorem ipsum dolor sit amet, ', 'consectetur adipiscing elit. ', 'Sed volutpat sit amet leo sit amet sagittis.'];

$response->expects($this->once())
->method('getLines')
->will($this->returnValue($lines));

$this->assertEquals(implode("\r\n", $lines->toArray()), $command->onBodyFollows($response));
$this->assertEquals(implode("\r\n", $lines), $command->onBodyFollows($response));
}

public function testItErrorsWhenGroupNotSelectedResponse()
Expand Down

0 comments on commit 9bb6101

Please sign in to comment.