ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
InitCtrlServiceTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22use Psr\Http\Message\ServerRequestInterface;
24use ILIAS\HTTP\Services as HttpService;
25use ILIAS\Refinery\Factory as Refinery;
27
32final 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
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}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Builds data types.
Definition: Factory.php:36
Class Services.
Definition: Services.php:38
Class InitCtrlServiceTest.
Class InitCtrlService wraps the initialization of ilCtrl.
$dic
Definition: ltiresult.php:33