ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
InitCtrlServiceTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 
32 final class InitCtrlServiceTest extends TestCase
33 {
35  {
36  $dic = new Container();
37  // $dic['ilDB'] = $this->createMock(ilDBInterface::class);
38  $dic['http'] = $this->createMock(HttpService::class);
39 
40  $this->expectException(ilCtrlException::class);
41  $this->expectExceptionMessage("Cannot initialize ilCtrl if Refinery Factory is not yet available.");
42  (new InitCtrlService())->init($dic);
43  }
44 
46  {
47  $dic = new Container();
48  // $dic['ilDB'] = $this->createMock(ilDBInterface::class);
49  $dic['refinery'] = $this->createMock(Refinery::class);
50 
51  $this->expectException(ilCtrlException::class);
52  $this->expectExceptionMessage("Cannot initialize ilCtrl if HTTP Services are not yet available.");
53  (new InitCtrlService())->init($dic);
54  }
55 
56  // public function testCtrlServiceInitializationWithoutDatabase() : void
57  // {
58  // $dic = new Container();
59  // $dic['refinery'] = $this->createMock(Refinery::class);
60  // $dic['http'] = $this->createMock(HttpService::class);
61  //
62  // $this->expectException(ilCtrlException::class);
63  // $this->expectExceptionMessage("Cannot initialize ilCtrl if Database is not yet available.");
64  // (new InitCtrlService())->init($dic);
65  // }
66 
67  public function testCtrlServiceInitializationSuccess(): void
68  {
69  $dic = new Container();
70  $dic['refinery'] = $this->createMock(Refinery::class);
71  // $dic['ilDB'] = $this->createMock(ilDBInterface::class);
72  $dic['http.response_sender_strategy'] = $this->createMock(DefaultResponseSenderStrategy::class);
73  $dic['http'] = $this->createMock(HttpService::class);
74  $dic['http']
75  ->method('request')
76  ->willReturn(
77  $this->createMock(ServerRequestInterface::class)
78  );
79  $dic['component.factory'] = $this->createMock(ilComponentFactory::class);
80 
81  $this->assertFalse(isset($dic['ilCtrl']));
82 
83  (new InitCtrlService())->init($dic);
84 
85  $this->assertTrue(isset($dic['ilCtrl']));
86  $this->assertInstanceOf(
87  ilCtrlInterface::class,
88  $dic->ctrl()
89  );
90  }
91 }
Class InitCtrlService wraps the initialization of ilCtrl.
Class InitCtrlServiceTest.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
$dic
Definition: result.php:31