ILIAS  release_7 Revision v7.30-3-g800a261c036
BaseNotificationSetUp.php
Go to the documentation of this file.
1<?php
2
25use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
29
30use PHPUnit\Framework\TestCase;
33
34require_once('./libs/composer/vendor/autoload.php');
35require_once(__DIR__ . "/../../UI/Base.php");
36
42abstract class BaseNotificationSetUp extends TestCase
43{
44 use MockeryPHPUnitIntegration;
45
49 protected $id;
53 protected $provider;
57 protected $identification;
61 protected $factory;
62
63
67 protected function setUp() : void
68 {
69 parent::setUp();
70
71 $this->identification = new IdentificationFactory(new NullProviderFactory());
72 $this->provider = \Mockery::mock(NotificationProvider::class);
73 $this->provider->shouldReceive('getProviderNameForPresentation')->andReturn('Provider');
74
75 $this->id = $this->identification->core($this->provider)->identifier('dummy');
76
77 $this->factory = new NotificationFactory();
78 }
79
80 public function getUIFactory() : NoUIFactory
81 {
82 $factory = new class() extends NoUIFactory {
83 public function item() : ILIAS\UI\Component\Item\Factory
84 {
85 return new I\Item\Factory();
86 }
87 public function symbol() : ILIAS\UI\Component\Symbol\Factory
88 {
89 return new I\Symbol\Factory(
90 new I\Symbol\Icon\Factory(),
91 new I\Symbol\Glyph\Factory(),
92 new I\Symbol\Avatar\Factory()
93 );
94 }
95 public function mainControls() : C\MainControls\Factory
96 {
97 return new I\MainControls\Factory(
98 $this->sig_gen,
99 new I\MainControls\Slate\Factory(
100 $this->sig_gen,
101 new Factory(),
102 new I\Symbol\Factory(
103 new I\Symbol\Icon\Factory(),
104 new I\Symbol\Glyph\Factory(),
105 new I\Symbol\Avatar\Factory()
106 )
107 )
108 );
109 }
110 };
111
112 $factory->sig_gen = Mockery::mock(I\SignalGeneratorInterface::class);
113 $factory->sig_gen->shouldReceive("create")->andReturn(new I\Signal("id"));
114 return $factory;
115 }
116
117 public function getDIC() : ILIAS\DI\Container
118 {
119 $mocks = [
120 'ui' => $this->createMock(\ILIAS\DI\UIServices::class),
121 'ui.factory' => $this->createMock(\ILIAS\UI\Factory::class),
122 'provider_factory' => $this->createMock(ProviderFactory::class),
123 ];
124 return new class($mocks) extends ILIAS\DI\Container {
125 public function globalScreen() : Services
126 {
127 return new Services($this['provider_factory']);
128 }
129 };
130 }
131
133 {
134 $dic = $this->getDIC();
135 $provider = new class($dic) extends AbstractNotificationProvider {
136 public function getNotifications() : array
137 {
138 return $this->notifications;
139 }
140 };
141 $provider->notifications = $notifications;
142 return $provider;
143 }
144}
Class BaseNotificationSetUp.
getDummyNotificationsProviderWithNotifications($notifications)
An exception for terminatinating execution or to throw for unit testing.
Builds a Color from either hex- or rgb values.
Definition: Factory.php:14
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
Class HTTPServicesTest.
Class ChatMainBarProvider \MainMenu\Provider.
Class ilAsqQuestionAuthoringFactory.
Class Factory.
$dic
Definition: result.php:13