From 38e33e0fddf8c337343ad817cf4abf7f4917a71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Perr=C3=A9al?= <guillaume.perreal@irstea.fr> Date: Thu, 19 Oct 2017 18:16:16 +0200 Subject: [PATCH] CS. --- Listener/VirusScannerListener.php | 9 ++++----- Tests/Listener/VirusScannerListenerTest.php | 17 +++++++---------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Listener/VirusScannerListener.php b/Listener/VirusScannerListener.php index 47c0e81f..db6b6122 100644 --- a/Listener/VirusScannerListener.php +++ b/Listener/VirusScannerListener.php @@ -6,9 +6,9 @@ namespace Irstea\FileUploadBundle\Listener; -use Xenolope\Quahog\Client; use Irstea\FileUploadBundle\Event\FileUploadCompleteEvent; use Irstea\FileUploadBundle\Exception\RejectedFileException; +use Xenolope\Quahog\Client; use Xenolope\Quahog\Exception\ConnectionException; /** @@ -21,7 +21,6 @@ class VirusScannerListener */ private $client; - /** * @param Client $client */ @@ -30,7 +29,6 @@ class VirusScannerListener $this->client = $client; } - /** * @param FileUploadCompleteEvent $event */ @@ -60,16 +58,17 @@ class VirusScannerListener } /** - * @return Client * @throws ConnectionException + * + * @return Client */ private function getClient(): Client { try { // Check clamd server's state $this->client->ping(); - return $this->client; + return $this->client; } catch (ConnectionException $connectionException) { throw $connectionException; } diff --git a/Tests/Listener/VirusScannerListenerTest.php b/Tests/Listener/VirusScannerListenerTest.php index 31d95547..61496e7d 100644 --- a/Tests/Listener/VirusScannerListenerTest.php +++ b/Tests/Listener/VirusScannerListenerTest.php @@ -8,9 +8,9 @@ namespace Irstea\FileUploadBundle\Tests\Listener; use Irstea\FileUploadBundle\Event\FileUploadCompleteEvent; use Irstea\FileUploadBundle\Listener\VirusScannerListener; +use Irstea\FileUploadBundle\Model\UploadedFileInterface; use PHPUnit_Framework_MockObject_MockObject; use PHPUnit_Framework_TestCase; -use Irstea\FileUploadBundle\Model\UploadedFileInterface; use Xenolope\Quahog\Client; use Xenolope\Quahog\Exception\ConnectionException; @@ -55,13 +55,12 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase $this->listener = new VirusScannerListener($this->client); } - public function testOnFileUploadCompletedResultOk() { $result = [ 'filename' => 'footpath', - 'reason' => null, - 'status' => Client::RESULT_OK + 'reason' => null, + 'status' => Client::RESULT_OK, ]; $this->client->expects($this->any())->method('scanFile')->with('foopath')->willReturn($result); @@ -77,11 +76,11 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase { $result = [ 'filename' => 'footpath', - 'reason' => 'Terrible virus', - 'status' => Client::RESULT_FOUND + 'reason' => 'Terrible virus', + 'status' => Client::RESULT_FOUND, ]; - $this->client->expects($this->any()) + $this->client->expects($this->any()) ->method('scanFile') ->with('foopath') ->willReturn($result); @@ -94,7 +93,7 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase } /** - * @expectedException Xenolope\Quahog\Exception\ConnectionException + * @expectedException \Xenolope\Quahog\Exception\ConnectionException */ public function testGetClientFailed() { @@ -102,11 +101,9 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase $this->listener->onFileUploadCompleted($this->event); } - public function testGetClientSucceed() { $this->client->expects($this->any())->method('ping')->willReturn(true); $this->listener->onFileUploadCompleted($this->event); } - } -- GitLab