ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
BaseToastSetUp.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28use PHPUnit\Framework\TestCase;
31
32require_once('./vendor/composer/vendor/autoload.php');
33require_once(__DIR__ . "/../../../UI/tests/Base.php");
34
35abstract class BaseToastSetUp extends TestCase
36{
37 private array $toasts = [];
40
44 protected function setUp(): void
45 {
46 parent::setUp();
47
48 $ui_mock = $this->createMock(UIServices::class);
49 $this->provider = $this->createMock(ToastProvider::class);
50 $this->provider->method('getProviderNameForPresentation')->willReturn('Provider');
51 $this->factory = (new ToastServices($ui_mock))->factory();
52 }
53
54 public function getDIC(): Container
55 {
56 $mocks = [
57 'ui' => $this->createMock(UIServices::class),
58 'ui.factory' => $this->createMock(Factory::class),
59 'provider_factory' => $this->createMock(ProviderFactory::class),
60 ];
61 return new class ($mocks) extends Container {
62 public function globalScreen(): Services
63 {
64 return new Services($this['provider_factory'], $this['ui']);
65 }
66 };
67 }
68
70 {
71 $dic = $this->getDIC();
72 $provider = new class ($dic) extends AbstractToastProvider {
73 public array $toasts;
74 public function getToasts(): array
75 {
76 return $this->toasts;
77 }
78 };
79 $provider->toasts = $toasts;
80 return $provider;
81 }
82}
factory()
setUp()
@inheritDoc
ToastFactory $factory
ToastProvider $provider
getDummyToastProviderWithToasts(array $toasts)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
$dic
Definition: ltiresult.php:33