ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
BaseNotificationSetUpTBD.php
Go to the documentation of this file.
1<?php
2
27use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
30use PHPUnit\Framework\TestCase;
33
34require_once('./vendor/composer/vendor/autoload.php');
35require_once(__DIR__ . "/../../../UI/tests/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
66 protected function setUp(): void
67 {
68 parent::setUp();
69
70 $this->identification = new IdentificationFactory(new NullProviderFactory());
71 $this->provider = \Mockery::mock(NotificationProvider::class);
72 $this->provider->shouldReceive('getProviderNameForPresentation')->andReturn('Provider');
73
74 $this->id = $this->identification->core($this->provider)->identifier('dummy');
75
76 $this->factory = new NotificationFactory();
77 }
78
79 public function getUIFactory(): NoUIFactory
80 {
81 $factory = new class () extends NoUIFactory {
82 public function item(): I\Item\Factory
83 {
84 return new I\Item\Factory();
85 }
86
87 public function symbol(): I\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
96 public function mainControls(): I\MainControls\Factory
97 {
98 return new I\MainControls\Factory(
99 $this->sig_gen,
100 new I\MainControls\Slate\Factory(
101 $this->sig_gen,
102 new Factory(),
103 new I\Symbol\Factory(
104 new I\Symbol\Icon\Factory(),
105 new I\Symbol\Glyph\Factory(),
106 new I\Symbol\Avatar\Factory()
107 )
108 )
109 );
110 }
111 };
112
113 $factory->sig_gen = Mockery::mock(I\SignalGeneratorInterface::class);
114 $factory->sig_gen->shouldReceive("create")->andReturn(new I\Signal("id"));
115 return $factory;
116 }
117
118 public function getDIC(): Container
119 {
120 $mocks = [
121 'ui' => $this->createMock(UIServices::class),
122 'ui.factory' => $this->createMock(\ILIAS\UI\Factory::class),
123 'provider_factory' => $this->createMock(ProviderFactory::class),
124 ];
125 return new class ($mocks) extends Container {
126 public function globalScreen(): Services
127 {
128 return new Services($this['provider_factory'], $this['ui']);
129 }
130 };
131 }
132
134 {
135 $dic = $this->getDIC();
136 $provider = new class ($dic) extends AbstractNotificationProvider {
137 public array $notifications = [];
138
139 public function getNotifications(): array
140 {
141 return $this->notifications;
142 }
143 };
144 $provider->notifications = $notifications;
145 return $provider;
146 }
147}
factory()
Class BaseNotificationSetUp.
getDummyNotificationsProviderWithNotifications($notifications)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
$dic
Definition: ltiresult.php:33
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.