ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 46 of file HTTPServicesTest.php.

Member Function Documentation

◆ setUp()

ILIAS\DI\HTTPServicesTest::setUp ( )
protected

Definition at line 71 of file HTTPServicesTest.php.

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

◆ testRequestWhichShouldGenerateANewRequestOnce()

ILIAS\DI\HTTPServicesTest::testRequestWhichShouldGenerateANewRequestOnce ( )

Definition at line 91 of file HTTPServicesTest.php.

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

◆ testResponseWhichShouldGenerateANewResponseOnce()

ILIAS\DI\HTTPServicesTest::testResponseWhichShouldGenerateANewResponseOnce ( )

Definition at line 117 of file HTTPServicesTest.php.

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

Field Documentation

◆ $httpState

GlobalHttpState ILIAS\DI\HTTPServicesTest::$httpState
private

Definition at line 68 of file HTTPServicesTest.php.

◆ $mockCookieJarFactory

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

Definition at line 59 of file HTTPServicesTest.php.

◆ $mockDurationFactory

DurationFactory ILIAS\DI\HTTPServicesTest::$mockDurationFactory
private

Definition at line 67 of file HTTPServicesTest.php.

◆ $mockRequestFactory

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

Definition at line 51 of file HTTPServicesTest.php.

◆ $mockResponseFactory

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

Definition at line 55 of file HTTPServicesTest.php.

◆ $mockSenderStrategy

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

Definition at line 63 of file HTTPServicesTest.php.


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