Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
composer.lock
/vendor/
/.idea/
/.idea/
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ services:

before_install:
- docker-compose up -d
- sleep 60

before_script: composer install

script:
- vendor/bin/phpunit --configuration phpunit.xml
- vendor/bin/phpunit
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- ./tests/data:/home:rw
14 changes: 9 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand All @@ -10,7 +9,12 @@
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">>./src</directory>
</whitelist>
</filter>
</phpunit>
6 changes: 3 additions & 3 deletions src/ClamAV/ClamAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

/**
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ClamAV/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ protected function getSocket()
}
return $socket;
}
}
}
2 changes: 1 addition & 1 deletion src/ClamAV/Pipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ protected function getSocket()
socket_connect($socket, $this->pip);
return $socket;
}
}
}
12 changes: 6 additions & 6 deletions tests/ClamAV/ClamAVTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'));
}
}
}