ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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 90 of file HTTPServicesTest.php.

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

◆ testResponseWhichShouldGenerateANewResponseOnce()

ILIAS\DI\HTTPServicesTest::testResponseWhichShouldGenerateANewResponseOnce ( )

Definition at line 116 of file HTTPServicesTest.php.

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

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: