-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: return a fresh scanner instance
Signed-off-by: Daniel Kesselberg <[email protected]>
- Loading branch information
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace Scanner; | ||
|
||
use OCA\Files_Antivirus\AppConfig; | ||
use OCA\Files_Antivirus\Scanner\ScannerFactory; | ||
use OCP\IConfig; | ||
use OCP\IRequest; | ||
use Test\TestCase; | ||
|
||
/** | ||
* @group DB | ||
*/ | ||
class ScannerFactoryTest extends TestCase { | ||
private IConfig $config; | ||
private AppConfig $appConfig; | ||
private IRequest $request; | ||
private ScannerFactory $scannerFactory; | ||
|
||
public function setUp(): void { | ||
$this->config = $this->createMock(IConfig::class); | ||
$this->config->method('getAppValue') | ||
->with('files_antivirus', 'av_mode', 'executable') | ||
->willReturn('daemon'); | ||
|
||
$this->appConfig = new AppConfig($this->config); | ||
|
||
$this->request = $this->createMock(IRequest::class); | ||
|
||
$this->scannerFactory = new ScannerFactory( | ||
$this->appConfig, | ||
\OC::$server, | ||
$this->request, | ||
); | ||
} | ||
|
||
public function testGetScanner() { | ||
$instanceA = $this->scannerFactory->getScanner('/dev/null'); | ||
$instanceB = $this->scannerFactory->getScanner('/dev/null'); | ||
|
||
$this->assertNotSame($instanceA, $instanceB); | ||
} | ||
|
||
} |