41 #[\PHPUnit\Framework\Attributes\BackupGlobals(false)] 42 #[\PHPUnit\Framework\Attributes\BackupStaticProperties(false)] 43 #[\PHPUnit\Framework\Attributes\PreserveGlobalState(false)] 44 #[\PHPUnit\Framework\Attributes\RunClassInSeparateProcess] 70 protected function setUp(): void
73 $this->mockRequestFactory = $this->getMockBuilder(RequestFactory::class)->getMock();
75 $this->mockResponseFactory = $this->getMockBuilder(ResponseFactory::class)->getMock();
77 $this->mockSenderStrategy = $this->getMockBuilder(ResponseSenderStrategy::class)->getMock();
79 $this->mockCookieJarFactory = $this->getMockBuilder(CookieJarFactory::class)->getMock();
81 $this->mockDurationFactory = $this->createMock(DurationFactory::class);
83 $this->httpState =
new RawHTTPServices($this->mockSenderStrategy, $this->mockCookieJarFactory, $this->mockRequestFactory, $this->mockResponseFactory, $this->mockDurationFactory);
87 #[\PHPUnit\Framework\Attributes\Test] 90 $expectedRequest = $this->getMockBuilder(ServerRequestInterface::class)->getMock();
91 $wrongRequest = $this->getMockBuilder(ServerRequestInterface::class)->getMock();
93 $this->mockRequestFactory->expects($this->once())
95 ->willReturn($expectedRequest, $wrongRequest);
100 $request1 = $this->httpState->request();
103 $request2 = $this->httpState->request();
106 $this->assertEquals($expectedRequest, $request1);
107 $this->assertEquals($expectedRequest, $request2);
111 #[\PHPUnit\Framework\Attributes\Test] 114 $expectedResponse = $this->getMockBuilder(ResponseInterface::class)->getMock();
115 $wrongResponse = $this->getMockBuilder(ResponseInterface::class)->getMock();
117 $this->mockResponseFactory->expects($this->once())
119 ->willReturn($expectedResponse, $wrongResponse);
124 $response1 = $this->httpState->response();
127 $response2 = $this->httpState->response();
130 $this->assertEquals($expectedResponse, $response1);
131 $this->assertEquals($expectedResponse, $response2);
testRequestWhichShouldGenerateANewRequestOnce()
ResponseSenderStrategy $mockSenderStrategy
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testResponseWhichShouldGenerateANewResponseOnce()
GlobalHttpState $httpState
DurationFactory $mockDurationFactory
RequestFactory $mockRequestFactory
CookieJarFactory $mockCookieJarFactory
ResponseFactory $mockResponseFactory