ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\DI\HTTPServicesTest Class Reference
+ Inheritance diagram for ILIAS\DI\HTTPServicesTest:
+ Collaboration diagram for ILIAS\DI\HTTPServicesTest:

Public Member Functions

 testRequestWhichShouldGenerateANewRequestOnce ()
 
 testResponseWhichShouldGenerateANewResponseOnce ()
 

Protected Member Functions

 setUp ()
 

Private Attributes

RequestFactory $mockRequestFactory
 
ResponseFactory $mockResponseFactory
 
CookieJarFactory $mockCookieJarFactory
 
ResponseSenderStrategy $mockSenderStrategy
 
DurationFactory $mockDurationFactory
 
GlobalHttpState $httpState
 

Detailed Description

Definition at line 45 of file HTTPServicesTest.php.

Member Function Documentation

◆ setUp()

ILIAS\DI\HTTPServicesTest::setUp ( )
protected

Definition at line 70 of file HTTPServicesTest.php.

70 : void
71 {
72 parent::setUp();
73 $this->mockRequestFactory = $this->getMockBuilder(RequestFactory::class)->getMock();
74
75 $this->mockResponseFactory = $this->getMockBuilder(ResponseFactory::class)->getMock();
76
77 $this->mockSenderStrategy = $this->getMockBuilder(ResponseSenderStrategy::class)->getMock();
78
79 $this->mockCookieJarFactory = $this->getMockBuilder(CookieJarFactory::class)->getMock();
80
81 $this->mockDurationFactory = $this->createMock(DurationFactory::class);
82
83 $this->httpState = new RawHTTPServices($this->mockSenderStrategy, $this->mockCookieJarFactory, $this->mockRequestFactory, $this->mockResponseFactory, $this->mockDurationFactory);
84 }

◆ testRequestWhichShouldGenerateANewRequestOnce()

ILIAS\DI\HTTPServicesTest::testRequestWhichShouldGenerateANewRequestOnce ( )

Definition at line 88 of file HTTPServicesTest.php.

88 : void
89 {
90 $expectedRequest = $this->getMockBuilder(ServerRequestInterface::class)->getMock();
91 $wrongRequest = $this->getMockBuilder(ServerRequestInterface::class)->getMock();
92
93 $this->mockRequestFactory->expects($this->once())
94 ->method('create')
95 ->willReturn($expectedRequest, $wrongRequest);
96
97 //test method
98
99 //this call should call the expectedRequest factory
100 $request1 = $this->httpState->request();
101
102 //this call should not call the factory
103 $request2 = $this->httpState->request();
104
105 //make sure that all requests are the same.
106 $this->assertEquals($expectedRequest, $request1);
107 $this->assertEquals($expectedRequest, $request2);
108 }

◆ testResponseWhichShouldGenerateANewResponseOnce()

ILIAS\DI\HTTPServicesTest::testResponseWhichShouldGenerateANewResponseOnce ( )

Definition at line 112 of file HTTPServicesTest.php.

112 : void
113 {
114 $expectedResponse = $this->getMockBuilder(ResponseInterface::class)->getMock();
115 $wrongResponse = $this->getMockBuilder(ResponseInterface::class)->getMock();
116
117 $this->mockResponseFactory->expects($this->once())
118 ->method('create')
119 ->willReturn($expectedResponse, $wrongResponse);
120
121 //test method
122
123 //this call should call the expectedResponse factory
124 $response1 = $this->httpState->response();
125
126 //this call should not call the factory
127 $response2 = $this->httpState->response();
128
129 //make sure that all requests are the same.
130 $this->assertEquals($expectedResponse, $response1);
131 $this->assertEquals($expectedResponse, $response2);
132 }

Field Documentation

◆ $httpState

GlobalHttpState ILIAS\DI\HTTPServicesTest::$httpState
private

Definition at line 67 of file HTTPServicesTest.php.

◆ $mockCookieJarFactory

CookieJarFactory MockObject ILIAS\DI\HTTPServicesTest::$mockCookieJarFactory
private

Definition at line 58 of file HTTPServicesTest.php.

◆ $mockDurationFactory

DurationFactory ILIAS\DI\HTTPServicesTest::$mockDurationFactory
private

Definition at line 66 of file HTTPServicesTest.php.

◆ $mockRequestFactory

RequestFactory MockObject ILIAS\DI\HTTPServicesTest::$mockRequestFactory
private

Definition at line 50 of file HTTPServicesTest.php.

◆ $mockResponseFactory

ResponseFactory MockObject ILIAS\DI\HTTPServicesTest::$mockResponseFactory
private

Definition at line 54 of file HTTPServicesTest.php.

◆ $mockSenderStrategy

DurationFactory MockObject ILIAS\DI\HTTPServicesTest::$mockSenderStrategy
private

Definition at line 62 of file HTTPServicesTest.php.


The documentation for this class was generated from the following file: