|
1
|
|
|
<?php |
|
2
|
|
|
declare( strict_types = 1 ); |
|
3
|
|
|
// backward compatibility |
|
4
|
|
|
if (!class_exists('\PHPUnit\Framework\TestCase')) { |
|
5
|
|
|
class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); |
|
6
|
|
|
} |
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
|
8
|
|
|
|
|
9
|
|
|
final class ModuleTest extends TestCase { |
|
10
|
|
|
public function testAddModuleWrongTypeInput() { |
|
11
|
|
|
$this->expectException(JException::class); |
|
12
|
|
|
$module = new Module(); |
|
13
|
|
|
$module->addModule(123); |
|
14
|
|
|
} |
|
15
|
|
|
public function testAddModuleWrongClassInput() { |
|
16
|
|
|
$this->expectException(JException::class); |
|
17
|
|
|
$module = new Module(); |
|
18
|
|
|
$module->addModule((object)[1,2,3]); |
|
19
|
|
|
} |
|
20
|
|
|
public function testAddModuleCorrectClassInput() { |
|
21
|
|
|
$module = new Module(); |
|
22
|
|
|
$module->addModule(new ModuleForTest()); |
|
23
|
|
|
$this->assertEquals(1, count($module->modules)); |
|
24
|
|
|
} |
|
25
|
|
|
public function testAddModulesWrongTypeInput() { |
|
26
|
|
|
$this->expectException(JException::class); |
|
27
|
|
|
$module = new Module(); |
|
28
|
|
|
$module->addModules(123); |
|
29
|
|
|
} |
|
30
|
|
|
public function testAddModulesWrongClassInput() { |
|
31
|
|
|
$this->expectException(JException::class); |
|
32
|
|
|
$module = new Module(); |
|
33
|
|
|
$module->addModules([(object)[1,2,3]]); |
|
34
|
|
|
} |
|
35
|
|
|
public function testAddModulesCorrectClassInput() { |
|
36
|
|
|
$module = new Module(); |
|
37
|
|
|
$module->addModules([new ModuleForTest()]); |
|
38
|
|
|
$this->assertEquals(1, count($module->modules)); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
class ModuleForTest extends Module {} |
|
43
|
|
|
?> |
|
44
|
|
|
|