diff --git a/Listener/VirusScannerListener.php b/Listener/VirusScannerListener.php index 47c0e81f368aa397fc90379e204553d611bcfdd7..db6b612232ca1990ddf30b11c83bb956dd312c8d 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 31d95547a9ad120d899b30377368d00f231a3f6c..61496e7d663bb59229f555bae85771d678eaa76f 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); } - }