File tree Expand file tree Collapse file tree 3 files changed +56
-5
lines changed
Expand file tree Collapse file tree 3 files changed +56
-5
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ abstract class AbstractScanStrategyClamdSocket
1212 */
1313 protected $ socket ;
1414
15+ /**
16+ * @param string $filePath
17+ *
18+ * @return ScannedFile
19+ */
1520 public function scan (string $ filePath ): ScannedFile
1621 {
1722 if (!is_file ($ filePath )) {
@@ -23,14 +28,19 @@ public function scan(string $filePath): ScannedFile
2328 return new ScannedFile ($ response );
2429 }
2530
26- public function version ()
31+ /**
32+ * @return string
33+ */
34+ public function version (): string
2735 {
28- // TODO: Implement version() method.
36+ return trim ( $ this -> socket -> sendCommand ( ' VERSION ' ));
2937 }
3038
31- public function ping ()
39+ /**
40+ * @return bool
41+ */
42+ public function ping (): bool
3243 {
33- // TODO: Implement ping() method.
44+ return trim ( $ this -> socket -> sendCommand ( ' PING ' )) === ' PONG ' ;
3445 }
35-
3646}
Original file line number Diff line number Diff line change @@ -29,4 +29,20 @@ public function scan(string $filePath): ScannedFile
2929 {
3030 return $ this ->scanStrategy ->scan ($ filePath );
3131 }
32+
33+ /**
34+ * @return bool
35+ */
36+ public function ping (): bool
37+ {
38+ return $ this ->scanStrategy ->ping ();
39+ }
40+
41+ /**
42+ * @return string
43+ */
44+ public function version (): string
45+ {
46+ return $ this ->scanStrategy ->version ();
47+ }
3248}
Original file line number Diff line number Diff line change 99
1010class ScannerTest extends TestCase
1111{
12+ public function testPingWithClamdUnix ()
13+ {
14+ $ scanner = new Scanner (new ScanStrategyClamdUnix ());
15+ $ this ->assertTrue ($ scanner ->ping ());
16+ }
17+
18+ public function testPingWithClamdNetwork ()
19+ {
20+ $ scanner = new Scanner (new ScanStrategyClamdNetwork ());
21+ $ this ->assertTrue ($ scanner ->ping ());
22+ }
23+
24+ public function testVersionWithClamdUnix ()
25+ {
26+ $ scanner = new Scanner (new ScanStrategyClamdUnix ());
27+ $ this ->assertIsString ($ scanner ->version ());
28+ }
29+
30+ public function testVersionWithClamdNetwork ()
31+ {
32+ $ scanner = new Scanner (new ScanStrategyClamdNetwork ());
33+ $ this ->assertIsString ($ scanner ->version ());
34+ }
35+
36+
1237 /**
1338 * @dataProvider validFilesToCheckProvider
1439 */
You can’t perform that action at this time.
0 commit comments