19declare(strict_types=1);
28use PHPUnit\Framework\Attributes\BackupGlobals;
29use PHPUnit\Framework\Attributes\BackupStaticProperties;
30use PHPUnit\Framework\Attributes\PreserveGlobalState;
31use PHPUnit\Framework\Attributes\RunInSeparateProcess;
32use PHPUnit\Framework\Attributes\Test;
33use PHPUnit\Framework\MockObject\MockObject;
36use PHPUnit\Framework\TestCase;
37use Psr\Http\Message\ResponseInterface;
45#[BackupGlobals(false)]
46#[BackupStaticProperties(false)]
47#[PreserveGlobalState(false)]
58 protected function setUp(): void
60 $this->httpServiceMock = $this->getMockBuilder(Services::class)
61 ->disableOriginalConstructor()
68 $expectedContentValue =
'';
70 $response = $this->getMockBuilder(ResponseInterface::class)
71 ->disableOriginalConstructor()
75 ->method(
'withHeader')
79 $this->httpServiceMock->expects($this->once())
83 $this->httpServiceMock->expects($this->once())
84 ->method(
'saveResponse')
87 $this->httpServiceMock->expects($this->never())
88 ->method(
'sendResponse');
90 $xAccel =
new XAccel($this->httpServiceMock);
91 $xAccel->prepare(
"this path is never used in this method",
null);
93 $this->assertTrue(
true);
99 $expectedHeader =
'X-Accel-Redirect';
100 $path =
'./normal/path';
102 $response = $this->getMockBuilder(ResponseInterface::class)
103 ->disableOriginalConstructor()
107 ->method(
'withHeader')
108 ->with($expectedHeader,
$path)
111 $this->httpServiceMock->expects($this->once())
115 $this->httpServiceMock->expects($this->once())
116 ->method(
'saveResponse')
119 $this->httpServiceMock->expects($this->once())
120 ->method(
'sendResponse');
123 $xAccel =
new XAccel($this->httpServiceMock);
124 $xAccel->deliver(
$path,
false);
130 $expectedHeader =
'X-Accel-Redirect';
131 $path =
'./data/path/to/what/ever';
132 $expectedPath =
'/secured-data/path/to/what/ever';
134 $response = $this->getMockBuilder(ResponseInterface::class)
135 ->disableOriginalConstructor()
139 ->method(
'withHeader')
140 ->with($expectedHeader, $expectedPath)
143 $this->httpServiceMock->expects($this->once())
147 $this->httpServiceMock->expects($this->once())
148 ->method(
'saveResponse')
151 $this->httpServiceMock->expects($this->once())
152 ->method(
'sendResponse');
154 $xAccel =
new XAccel($this->httpServiceMock);
155 $xAccel->deliver(
$path,
false);
Services $httpServiceMock
testPrepareWhichShouldSucceed()
testDeliverWithDataPathWhichShouldSucceed()
testDeliverWithNormalPathWhichShouldSucceed()