ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
VirusScannerFactoryTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once __DIR__ . '/bootstrap.php';
22 
28 {
29  public static ilLogger $logger;
30 
31  protected function setUp(): void
32  {
33  parent::setUp();
34 
35  if (!defined('IL_VIRUS_SCAN_COMMAND')) {
36  define("IL_VIRUS_SCAN_COMMAND", 'phpunitscan');
37  }
38 
39  if (!defined('IL_VIRUS_CLEAN_COMMAND')) {
40  define("IL_VIRUS_CLEAN_COMMAND", 'phpunitclean');
41  }
42 
43  $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
44  self::$logger = $logger;
45 
46  $logger_factory = new class () extends ilLoggerFactory {
47  public function __construct()
48  {
49  }
50 
51  public static function getRootLogger(): ilLogger
52  {
54  }
55 
56  public function getComponentLogger(string $a_component_id): ilLogger
57  {
59  }
60  };
61 
62  $this->setGlobalVariable('ilias', $this->getMockBuilder(ILIAS::class)->disableOriginalConstructor()->getMock());
63  $this->setGlobalVariable(
64  'lng',
65  $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock()
66  );
67 
68  $this->setGlobalVariable('ilLoggerFactory', $logger_factory);
69 
70  $this->setGlobalVariable('ilErr', $this->getMockBuilder(ilErrorHandling::class)->disableOriginalConstructor()->getMock());
71  }
72 
74  {
75  define("IL_VIRUS_SCANNER", 'Sophos');
76 
77  self::assertInstanceOf(ilVirusScannerSophos::class, ilVirusScannerFactory::_getInstance());
78  }
79 
81  {
82  define("IL_VIRUS_SCANNER", 'AntiVir');
83 
84  self::assertInstanceOf(ilVirusScannerAntiVir::class, ilVirusScannerFactory::_getInstance());
85  }
86 
88  {
89  define("IL_VIRUS_SCANNER", 'ClamAV');
90 
91  self::assertInstanceOf(ilVirusScannerClamAV::class, ilVirusScannerFactory::_getInstance());
92  }
93 
95  {
96  define("IL_VIRUS_SCANNER", 'icap');
97  define("IL_ICAP_CLIENT", 'phpunit');
98 
99  self::assertInstanceOf(ilVirusScannerICapClient::class, ilVirusScannerFactory::_getInstance());
100  }
101 }
setGlobalVariable(string $name, $value)
__construct(Container $dic, ilPlugin $plugin)