ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ILIAS\DI\HTTPServicesTest Class Reference
+ Inheritance diagram for ILIAS\DI\HTTPServicesTest:
+ Collaboration diagram for ILIAS\DI\HTTPServicesTest:

Public Member Functions

 testRequestWhichShouldGenerateANewRequestOnce ()
 @Test More...
 
 testResponseWhichShouldGenerateANewResponseOnce ()
 @Test More...
 

Protected Member Functions

 setUp ()
 

Private Attributes

 $mockRequestFactory
 
 $mockResponseFactory
 
 $mockCookieJarFactory
 
 $mockSenderStrategy
 
 $httpState
 

Detailed Description

Definition at line 30 of file HTTPServicesTest.php.

Member Function Documentation

◆ setUp()

ILIAS\DI\HTTPServicesTest::setUp ( )
protected

Definition at line 55 of file HTTPServicesTest.php.

55 : void
56 {
57 parent::setUp();
58 // $this->mockRequestFactory = \Mockery::mock('alias:' . RequestFactory::class);
59 $this->mockRequestFactory = $this->getMockBuilder(RequestFactory::class)->setMethods(['create'])->getMock();
60
61 // $this->mockResponseFactory = \Mockery::mock('alias:' . ResponseFactory::class);
62 $this->mockResponseFactory = $this->getMockBuilder(ResponseFactory::class)->setMethods(['create'])->getMock();
63
64 // $this->mockSenderStrategy = \Mockery::mock('alias:' . ResponseSenderStrategy::class);
65 $this->mockSenderStrategy = $this->getMockBuilder(ResponseSenderStrategy::class)->getMock();
66
67 // $this->mockCookieJarFactory = \Mockery::mock('alias:' . CookieJarFactory::class);
68 $this->mockCookieJarFactory = $this->getMockBuilder(CookieJarFactory::class)->getMock();
69
70 //setup http state
71 $this->httpState = new HTTPServices($this->mockSenderStrategy, $this->mockCookieJarFactory, $this->mockRequestFactory, $this->mockResponseFactory);
72 }

◆ testRequestWhichShouldGenerateANewRequestOnce()

ILIAS\DI\HTTPServicesTest::testRequestWhichShouldGenerateANewRequestOnce ( )

@Test

Definition at line 78 of file HTTPServicesTest.php.

79 {
80 $expectedRequest = $this->getMockBuilder(ServerRequestInterface::class)->getMock();
81 $wrongRequest = $this->getMockBuilder(ServerRequestInterface::class)->getMock();
82
83 $this->mockRequestFactory->expects($this->once())
84 ->method('create')
85 ->willReturn($expectedRequest, $wrongRequest);
86
87 //test method
88
89 //this call should call the expectedRequest factory
90 $request1 = $this->httpState->request();
91
92 //this call should not call the factory
93 $request2 = $this->httpState->request();
94
95 //make sure that all requests are the same.
96 $this->assertEquals($expectedRequest, $request1);
97 $this->assertEquals($expectedRequest, $request2);
98 }

◆ testResponseWhichShouldGenerateANewResponseOnce()

ILIAS\DI\HTTPServicesTest::testResponseWhichShouldGenerateANewResponseOnce ( )

@Test

Definition at line 104 of file HTTPServicesTest.php.

105 {
106 $expectedResponse = $this->getMockBuilder(ResponseInterface::class)->getMock();
107 $wrongResponse = $this->getMockBuilder(ResponseInterface::class)->getMock();
108
109 $this->mockResponseFactory->expects($this->once())
110 ->method('create')
111 ->willReturn($expectedResponse, $wrongResponse);
112
113 //test method
114
115 //this call should call the expectedResponse factory
116 $response1 = $this->httpState->response();
117
118 //this call should not call the factory
119 $response2 = $this->httpState->response();
120
121 //make sure that all requests are the same.
122 $this->assertEquals($expectedResponse, $response1);
123 $this->assertEquals($expectedResponse, $response2);
124 }

Field Documentation

◆ $httpState

GlobalHttpState ILIAS\DI\HTTPServicesTest::$httpState
private

Definition at line 52 of file HTTPServicesTest.php.

◆ $mockCookieJarFactory

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

Definition at line 44 of file HTTPServicesTest.php.

◆ $mockRequestFactory

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

Definition at line 36 of file HTTPServicesTest.php.

◆ $mockResponseFactory

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

Definition at line 40 of file HTTPServicesTest.php.

◆ $mockSenderStrategy

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

Definition at line 48 of file HTTPServicesTest.php.


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