ILIAS  release_7 Revision v7.30-3-g800a261c036
FactoryImplTest.php
Go to the documentation of this file.
1<?php
2
20
27use PHPUnit\Framework\TestCase;
28use ReflectionClass;
29use ReflectionMethod;
30
31require_once('./libs/composer/vendor/autoload.php');
32
38class FactoryImplTest extends TestCase
39{
43 protected $id;
47 protected $provider;
51 protected $identification;
55 protected $factory;
56
57
61 protected function setUp() : void
62 {
63 parent::setUp();
64
65 $this->identification = new IdentificationFactory(new NullProviderFactory());
66 $this->provider = $this->getMockBuilder(StaticMainMenuProvider::class)->getMock();
67
68 $this->id = $this->identification->core($this->provider)->identifier('dummy');
69
70 $this->factory = new MainMenuItemFactory();
71 }
72
73
74 public function testAvailableMethods() : void
75 {
76 $r = new ReflectionClass($this->factory);
77
78 $methods = [];
79 foreach ($r->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
80 $methods[] = $method->getName();
81 }
82 sort($methods);
83 $this->assertEquals(
84 [
85 0 => 'complex',
86 1 => 'custom',
87 2 => 'link',
88 3 => 'linkList',
89 4 => 'repositoryLink',
90 5 => 'separator',
91 6 => 'topLinkItem',
92 7 => 'topParentItem',
93 ],
94 $methods
95 );
96 }
97
98
99 public function testInterchangeableContraints() : void
100 {
101 $this->assertInstanceOf(isInterchangeableItem::class, $this->factory->topLinkItem($this->id));
102 $this->assertNotInstanceOf(isInterchangeableItem::class, $this->factory->topParentItem($this->id));
103 $this->assertInstanceOf(isInterchangeableItem::class, $this->factory->complex($this->id));
104 $this->assertInstanceOf(isInterchangeableItem::class, $this->factory->link($this->id));
105 $this->assertInstanceOf(isInterchangeableItem::class, $this->factory->repositoryLink($this->id));
106 $this->assertNotInstanceOf(isInterchangeableItem::class, $this->factory->separator($this->id));
107 }
108}
An exception for terminatinating execution or to throw for unit testing.
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
Class MainMenuItemFactory This factory provides you all available types for MainMenu GlobalScreen Ite...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...