diff --git a/.gitignore b/.gitignore index 8924c80..85eb384 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ composer.lock /vendor/ -/.idea/ \ No newline at end of file +/.idea/ diff --git a/.travis.yml b/.travis.yml index 9dfd00c..ee02d0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,9 @@ services: before_install: - docker-compose up -d +- sleep 60 before_script: composer install script: -- vendor/bin/phpunit --configuration phpunit.xml \ No newline at end of file +- vendor/bin/phpunit diff --git a/composer.json b/composer.json index 7c15998..ecc8663 100755 --- a/composer.json +++ b/composer.json @@ -13,11 +13,14 @@ "autoload": { "psr-4": {"Appwrite\\ClamAV\\": "src/ClamAV"} }, + "autoload-dev": { + "psr-4": {"Utopia\\Tests\\": "tests/ClamAV"} + }, "require": { "php": ">=7.1" }, "require-dev": { "phpunit/phpunit": "^7.0" }, - "minimum-stability": "dev" + "minimum-stability": "stable" } diff --git a/docker-compose.yml b/docker-compose.yml index 9f729b6..d2f4fad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,9 @@ version: '3' services: clamav: - image: appwrite/clamav:v1.0.2 + image: appwrite/clamav:v1.0.3 restart: unless-stopped ports: - "3310:3310" volumes: - - ./tests/data:/home:rw \ No newline at end of file + - ./tests/data:/home:rw diff --git a/phpunit.xml b/phpunit.xml index ec39a7e..c08eec6 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,5 @@ - + - ./tests/ + ./tests/ - \ No newline at end of file + + + >./src + + + diff --git a/src/ClamAV/ClamAV.php b/src/ClamAV/ClamAV.php index ffd624e..c2b1086 100644 --- a/src/ClamAV/ClamAV.php +++ b/src/ClamAV/ClamAV.php @@ -41,7 +41,7 @@ private function sendCommand($command) public function ping() { $return = $this->sendCommand('PING'); - return strcmp($return, 'PONG') ? true : false; + return trim($return) === 'PONG'; } /** @@ -101,11 +101,11 @@ public function fileScan(string $file) */ public function continueScan(string $file) { - $return = array(); + $return = []; foreach(explode("\n", trim($this->sendCommand('CONTSCAN ' . $file))) as $results ) { list($file, $stats) = explode(':', $results); - array_push($return, array( 'file' => $file, 'stats' => trim($stats) )); + array_push($return, [ 'file' => $file, 'stats' => trim($stats) ]); } return $return; diff --git a/src/ClamAV/Network.php b/src/ClamAV/Network.php index d92715d..76ca0ed 100644 --- a/src/ClamAV/Network.php +++ b/src/ClamAV/Network.php @@ -45,4 +45,4 @@ protected function getSocket() } return $socket; } -} \ No newline at end of file +} diff --git a/src/ClamAV/Pipe.php b/src/ClamAV/Pipe.php index f755d53..5da4dc4 100644 --- a/src/ClamAV/Pipe.php +++ b/src/ClamAV/Pipe.php @@ -33,4 +33,4 @@ protected function getSocket() socket_connect($socket, $this->pip); return $socket; } -} \ No newline at end of file +} diff --git a/tests/ClamAV/ClamAVTest.php b/tests/ClamAV/ClamAVTest.php index 2f98bd2..accdf9e 100755 --- a/tests/ClamAV/ClamAVTest.php +++ b/tests/ClamAV/ClamAVTest.php @@ -29,13 +29,13 @@ class ClamAVTest extends TestCase */ protected $pipe = null; - public function setUp() + protected function setUp(): void { $this->network = new Network('localhost', 3310); $this->pipe = new Pipe(); } - public function tearDown() + protected function tearDown(): void { $this->network = null; $this->pipe= null; @@ -48,12 +48,12 @@ public function testVersion() public function testPing() { - $this->assertEquals(true, $this->network->ping()); + $this->assertTrue($this->network->ping()); } public function testFileScan() { - $this->assertEquals(true, $this->network->fileScan('/home/NoVirus.txt')); - $this->assertEquals(false, $this->network->fileScan('/home/Virus.txt')); + $this->assertTrue($this->network->fileScan('/home/NoVirus.txt')); + $this->assertFalse($this->network->fileScan('/home/Virus.txt')); } -} \ No newline at end of file +}