golden hour
/opt/PHP-Antimalware-Scanner/tests/Integration
⬆️ Go Up
Upload
File/Folder
Size
Actions
CLITestCase.php
3.79 KB
Del
OK
DefaultScanTest.php
2.59 KB
Del
OK
PathControlsTest.php
1.94 KB
Del
OK
ReportModeTest.php
3.29 KB
Del
OK
ScanModesTest.php
3.14 KB
Del
OK
Edit: DefaultScanTest.php
<?php /** * PHP Antimalware Scanner. * * @author Marco Cesarato <cesarato.developer@gmail.com> * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License * * @see https://github.com/marcocesarato/PHP-Antimalware-Scanner */ namespace AMWScan\Tests\Integration; /** * Test default scanning behavior and exit codes. */ class DefaultScanTest extends CLITestCase { public function testScanCleanDirectoryExitsWithZero() { $result = $this->runScanner( $this->fixturesPath . '/clean', ['--report', '--auto-skip'] ); $this->assertEquals(0, $result['exitCode'], 'Clean directory should exit with code 0'); $this->assertStringContainsString('scanned', strtolower($result['output'])); } public function testScanMalwareDirectoryExitsWithOne() { $result = $this->runScanner( $this->fixturesPath . '/malware', ['--report', '--auto-skip'] ); $this->assertEquals(1, $result['exitCode'], 'Malware directory should exit with code 1'); $this->assertStringContainsString('detected', strtolower($result['output'])); } public function testScanDisplaysVersionInformation() { $result = $this->runScanner( $this->fixturesPath . '/clean', ['--report', '--auto-skip'] ); $this->assertStringContainsString('PHP Antimalware Scanner', $result['output']); } public function testScanCountsFilesScanned() { $cleanDir = $this->fixturesPath . '/clean'; $result = $this->runScanner( $cleanDir, ['--report', '--auto-skip'] ); // Count actual files in clean directory and verify it matches output $fileCount = count(array_diff(scandir($cleanDir), ['.', '..'])); preg_match('/Files scanned:\s*(\d+)/i', $result['output'], $matches); $this->assertNotEmpty($matches, 'Should find "Files scanned:" in output'); $this->assertEquals($fileCount, (int)$matches[1], 'Scanned file count should match actual files in directory'); } public function testScanDetectsMalwarePatterns() { $result = $this->runScanner( $this->fixturesPath . '/malware', ['--report', '--auto-skip'] ); $output = strtolower($result['output']); // Should detect dangerous patterns $this->assertTrue( strpos($output, 'eval') !== false || strpos($output, 'execution') !== false || strpos($output, 'exploit') !== false, 'Should detect eval or execution patterns' ); } }
Save