Commit 38e33e0f authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

CS.

parent 016a9968
No related merge requests found
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
Showing with 11 additions and 15 deletions
+11 -15
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
namespace Irstea\FileUploadBundle\Listener; namespace Irstea\FileUploadBundle\Listener;
use Xenolope\Quahog\Client;
use Irstea\FileUploadBundle\Event\FileUploadCompleteEvent; use Irstea\FileUploadBundle\Event\FileUploadCompleteEvent;
use Irstea\FileUploadBundle\Exception\RejectedFileException; use Irstea\FileUploadBundle\Exception\RejectedFileException;
use Xenolope\Quahog\Client;
use Xenolope\Quahog\Exception\ConnectionException; use Xenolope\Quahog\Exception\ConnectionException;
/** /**
...@@ -21,7 +21,6 @@ class VirusScannerListener ...@@ -21,7 +21,6 @@ class VirusScannerListener
*/ */
private $client; private $client;
/** /**
* @param Client $client * @param Client $client
*/ */
...@@ -30,7 +29,6 @@ class VirusScannerListener ...@@ -30,7 +29,6 @@ class VirusScannerListener
$this->client = $client; $this->client = $client;
} }
/** /**
* @param FileUploadCompleteEvent $event * @param FileUploadCompleteEvent $event
*/ */
...@@ -60,16 +58,17 @@ class VirusScannerListener ...@@ -60,16 +58,17 @@ class VirusScannerListener
} }
/** /**
* @return Client
* @throws ConnectionException * @throws ConnectionException
*
* @return Client
*/ */
private function getClient(): Client private function getClient(): Client
{ {
try { try {
// Check clamd server's state // Check clamd server's state
$this->client->ping(); $this->client->ping();
return $this->client;
return $this->client;
} catch (ConnectionException $connectionException) { } catch (ConnectionException $connectionException) {
throw $connectionException; throw $connectionException;
} }
......
...@@ -8,9 +8,9 @@ namespace Irstea\FileUploadBundle\Tests\Listener; ...@@ -8,9 +8,9 @@ namespace Irstea\FileUploadBundle\Tests\Listener;
use Irstea\FileUploadBundle\Event\FileUploadCompleteEvent; use Irstea\FileUploadBundle\Event\FileUploadCompleteEvent;
use Irstea\FileUploadBundle\Listener\VirusScannerListener; use Irstea\FileUploadBundle\Listener\VirusScannerListener;
use Irstea\FileUploadBundle\Model\UploadedFileInterface;
use PHPUnit_Framework_MockObject_MockObject; use PHPUnit_Framework_MockObject_MockObject;
use PHPUnit_Framework_TestCase; use PHPUnit_Framework_TestCase;
use Irstea\FileUploadBundle\Model\UploadedFileInterface;
use Xenolope\Quahog\Client; use Xenolope\Quahog\Client;
use Xenolope\Quahog\Exception\ConnectionException; use Xenolope\Quahog\Exception\ConnectionException;
...@@ -55,13 +55,12 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase ...@@ -55,13 +55,12 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase
$this->listener = new VirusScannerListener($this->client); $this->listener = new VirusScannerListener($this->client);
} }
public function testOnFileUploadCompletedResultOk() public function testOnFileUploadCompletedResultOk()
{ {
$result = [ $result = [
'filename' => 'footpath', 'filename' => 'footpath',
'reason' => null, 'reason' => null,
'status' => Client::RESULT_OK 'status' => Client::RESULT_OK,
]; ];
$this->client->expects($this->any())->method('scanFile')->with('foopath')->willReturn($result); $this->client->expects($this->any())->method('scanFile')->with('foopath')->willReturn($result);
...@@ -77,11 +76,11 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase ...@@ -77,11 +76,11 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase
{ {
$result = [ $result = [
'filename' => 'footpath', 'filename' => 'footpath',
'reason' => 'Terrible virus', 'reason' => 'Terrible virus',
'status' => Client::RESULT_FOUND 'status' => Client::RESULT_FOUND,
]; ];
$this->client->expects($this->any()) $this->client->expects($this->any())
->method('scanFile') ->method('scanFile')
->with('foopath') ->with('foopath')
->willReturn($result); ->willReturn($result);
...@@ -94,7 +93,7 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase ...@@ -94,7 +93,7 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase
} }
/** /**
* @expectedException Xenolope\Quahog\Exception\ConnectionException * @expectedException \Xenolope\Quahog\Exception\ConnectionException
*/ */
public function testGetClientFailed() public function testGetClientFailed()
{ {
...@@ -102,11 +101,9 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase ...@@ -102,11 +101,9 @@ class VirusScannerListenerTest extends PHPUnit_Framework_TestCase
$this->listener->onFileUploadCompleted($this->event); $this->listener->onFileUploadCompleted($this->event);
} }
public function testGetClientSucceed() public function testGetClientSucceed()
{ {
$this->client->expects($this->any())->method('ping')->willReturn(true); $this->client->expects($this->any())->method('ping')->willReturn(true);
$this->listener->onFileUploadCompleted($this->event); $this->listener->onFileUploadCompleted($this->event);
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment