ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
BaseToastSetUp.php
Go to the documentation of this file.
1 <?php
18 declare(strict_types=1);
19 
30 
31 require_once('./vendor/composer/vendor/autoload.php');
32 require_once(__DIR__ . "/../../../UI/tests/Base.php");
33 
34 abstract class BaseToastSetUp extends TestCase
35 {
36  private array $toasts = [];
37 
41 
45  protected function setUp(): void
46  {
47  parent::setUp();
48 
49  $this->ui_mock = $this->createMock(UIServices::class);
50  $this->provider = $this->createMock(ToastProvider::class);
51  $this->provider->expects($this->any())->method('getProviderNameForPresentation')->willReturn('Provider');
52  $this->factory = (new ToastServices($this->ui_mock))->factory();
53  }
54 
55  public function getDIC(): Container
56  {
57  $mocks = [
58  'ui' => $this->createMock(UIServices::class),
59  'ui.factory' => $this->createMock(Factory::class),
60  'provider_factory' => $this->createMock(ProviderFactory::class),
61  ];
62  return new class ($mocks) extends Container {
63  public function globalScreen(): Services
64  {
65  return new Services($this['provider_factory'], $this['ui']);
66  }
67  };
68  }
69 
71  {
72  $dic = $this->getDIC();
73  $provider = new class ($dic) extends AbstractToastProvider {
74  public array $toasts;
75  public function getToasts(): array
76  {
77  return $this->toasts;
78  }
79  };
80  $provider->toasts = $toasts;
81  return $provider;
82  }
83 }
factory()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
ToastFactory $factory
ToastProvider $provider
getDummyToastProviderWithToasts(array $toasts)
UIServices $ui_mock
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$dic
Definition: result.php:31