ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
FactoryImplTest.php
Go to the documentation of this file.
1<?php
2
4
12use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
13use PHPUnit\Framework\TestCase;
14use ReflectionClass;
15use ReflectionMethod;
16
17require_once('./libs/composer/vendor/autoload.php');
18
24class FactoryImplTest extends TestCase
25{
26 use MockeryPHPUnitIntegration;
30 protected $id;
34 protected $provider;
38 protected $identification;
42 protected $factory;
43
44
48 protected function setUp()
49 {
50 parent::setUp();
51
52 $this->identification = new IdentificationFactory(new NullProviderFactory());
53 $this->provider = \Mockery::mock(StaticMainMenuProvider::class);
54 $this->provider->shouldReceive('getProviderNameForPresentation')->andReturn('Provider');
55
56 $this->id = $this->identification->core($this->provider)->identifier('dummy');
57
58 $this->factory = new MainMenuItemFactory();
59 }
60
61
62 public function testAvailableMethods()
63 {
64 $r = new ReflectionClass($this->factory);
65
66 $methods = [];
67 foreach ($r->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
68 $methods[] = $method->getName();
69 }
70 sort($methods);
71 $this->assertEquals(
72 $methods,
73 [
74 0 => 'complex',
75 1 => 'custom',
76 2 => 'link',
77 3 => 'linkList',
78 4 => 'repositoryLink',
79 5 => 'separator',
80 6 => 'topLinkItem',
81 7 => 'topParentItem',
82 ]
83 );
84 }
85
86
87 public function testTopItemConstraints()
88 {
89 $this->assertInstanceOf(isTopItem::class, $this->factory->topLinkItem($this->id));
90 $this->assertInstanceOf(isTopItem::class, $this->factory->topParentItem($this->id));
91 $this->assertNotInstanceOf(isTopItem::class, $this->factory->complex($this->id));
92 $this->assertNotInstanceOf(isTopItem::class, $this->factory->link($this->id));
93 $this->assertNotInstanceOf(isTopItem::class, $this->factory->repositoryLink($this->id));
94 $this->assertNotInstanceOf(isTopItem::class, $this->factory->separator($this->id));
95 }
96
97
98 public function testChildConstraints()
99 {
100 $this->assertNotInstanceOf(isChild::class, $this->factory->topLinkItem($this->id));
101 $this->assertNotInstanceOf(isChild::class, $this->factory->topParentItem($this->id));
102 $this->assertInstanceOf(isChild::class, $this->factory->complex($this->id));
103 $this->assertInstanceOf(isChild::class, $this->factory->link($this->id));
104 $this->assertInstanceOf(isChild::class, $this->factory->repositoryLink($this->id));
105 $this->assertInstanceOf(isChild::class, $this->factory->separator($this->id));
106 }
107}
An exception for terminatinating execution or to throw for unit testing.
$r
Definition: example_031.php:79