Skip to content

Commit 1159549

Browse files
authored
Merge pull request #1 from open-source-contributions/test_enhancement
Test enhancement
2 parents 9298a2d + 03e3697 commit 1159549

File tree

9 files changed

+29
-21
lines changed

9 files changed

+29
-21
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
composer.lock
22
/vendor/
3-
/.idea/
3+
/.idea/

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ services:
1414

1515
before_install:
1616
- docker-compose up -d
17+
- sleep 60
1718

1819
before_script: composer install
1920

2021
script:
21-
- vendor/bin/phpunit --configuration phpunit.xml
22+
- vendor/bin/phpunit

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
"autoload": {
1414
"psr-4": {"Appwrite\\ClamAV\\": "src/ClamAV"}
1515
},
16+
"autoload-dev": {
17+
"psr-4": {"Utopia\\Tests\\": "tests/ClamAV"}
18+
},
1619
"require": {
1720
"php": ">=7.1"
1821
},
1922
"require-dev": {
2023
"phpunit/phpunit": "^7.0"
2124
},
22-
"minimum-stability": "dev"
25+
"minimum-stability": "stable"
2326
}

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ version: '3'
22

33
services:
44
clamav:
5-
image: appwrite/clamav:v1.0.2
5+
image: appwrite/clamav:v1.0.3
66
restart: unless-stopped
77
ports:
88
- "3310:3310"
99
volumes:
10-
- ./tests/data:/home:rw
10+
- ./tests/data:/home:rw

phpunit.xml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
<phpunit backupGlobals="false"
2-
backupStaticAttributes="false"
3-
bootstrap="vendor/autoload.php"
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<phpunit bootstrap="vendor/autoload.php"
43
colors="true"
54
convertErrorsToExceptions="true"
65
convertNoticesToExceptions="true"
@@ -10,7 +9,12 @@
109
>
1110
<testsuites>
1211
<testsuite name="Application Test Suite">
13-
<directory>./tests/</directory>
12+
<directory suffix="Test.php">./tests/</directory>
1413
</testsuite>
1514
</testsuites>
16-
</phpunit>
15+
<filter>
16+
<whitelist processUncoveredFilesFromWhitelist="true">
17+
<directory suffix=".php">>./src</directory>
18+
</whitelist>
19+
</filter>
20+
</phpunit>

src/ClamAV/ClamAV.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private function sendCommand($command)
4141
public function ping()
4242
{
4343
$return = $this->sendCommand('PING');
44-
return strcmp($return, 'PONG') ? true : false;
44+
return trim($return) === 'PONG';
4545
}
4646

4747
/**
@@ -101,11 +101,11 @@ public function fileScan(string $file)
101101
*/
102102
public function continueScan(string $file)
103103
{
104-
$return = array();
104+
$return = [];
105105

106106
foreach(explode("\n", trim($this->sendCommand('CONTSCAN ' . $file))) as $results ) {
107107
list($file, $stats) = explode(':', $results);
108-
array_push($return, array( 'file' => $file, 'stats' => trim($stats) ));
108+
array_push($return, [ 'file' => $file, 'stats' => trim($stats) ]);
109109
}
110110

111111
return $return;

src/ClamAV/Network.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ protected function getSocket()
4545
}
4646
return $socket;
4747
}
48-
}
48+
}

src/ClamAV/Pipe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ protected function getSocket()
3333
socket_connect($socket, $this->pip);
3434
return $socket;
3535
}
36-
}
36+
}

tests/ClamAV/ClamAVTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class ClamAVTest extends TestCase
2929
*/
3030
protected $pipe = null;
3131

32-
public function setUp()
32+
protected function setUp(): void
3333
{
3434
$this->network = new Network('localhost', 3310);
3535
$this->pipe = new Pipe();
3636
}
3737

38-
public function tearDown()
38+
protected function tearDown(): void
3939
{
4040
$this->network = null;
4141
$this->pipe= null;
@@ -48,12 +48,12 @@ public function testVersion()
4848

4949
public function testPing()
5050
{
51-
$this->assertEquals(true, $this->network->ping());
51+
$this->assertTrue($this->network->ping());
5252
}
5353

5454
public function testFileScan()
5555
{
56-
$this->assertEquals(true, $this->network->fileScan('/home/NoVirus.txt'));
57-
$this->assertEquals(false, $this->network->fileScan('/home/Virus.txt'));
56+
$this->assertTrue($this->network->fileScan('/home/NoVirus.txt'));
57+
$this->assertFalse($this->network->fileScan('/home/Virus.txt'));
5858
}
59-
}
59+
}

0 commit comments

Comments
 (0)