19declare(strict_types=1);
23use PHPUnit\Framework\Attributes\BackupGlobals;
24use PHPUnit\Framework\Attributes\BackupStaticProperties;
25use PHPUnit\Framework\Attributes\PreserveGlobalState;
26use PHPUnit\Framework\Attributes\RunInSeparateProcess;
27use PHPUnit\Framework\Attributes\Test;
28use PHPUnit\Framework\MockObject\MockObject;
30use PHPUnit\Framework\TestCase;
31use Psr\Http\Message\ResponseInterface;
39#[BackupGlobals(false)]
40#[BackupStaticProperties(false)]
41#[PreserveGlobalState(false)]
52 protected function setUp(): void
54 $this->httpServiceMock = $this->getMockBuilder(Services::class)
55 ->disableOriginalConstructor()
62 $expectedHeader =
'X-Sendfile';
65 $response = $this->getMockBuilder(ResponseInterface::class)
66 ->disableOriginalConstructor()
70 ->method(
'withHeader')
71 ->with($expectedHeader, $filePath)
74 $this->httpServiceMock->expects($this->once())
78 $this->httpServiceMock->expects($this->once())
79 ->method(
'saveResponse')
82 $this->httpServiceMock->expects($this->once())
83 ->method(
'sendResponse');
85 $fileDeliveryType =
new XSendfile($this->httpServiceMock);
86 $fileDeliveryType->deliver($filePath,
false);
Services $httpServiceMock
testSendFileWithXSendHeaderWhichShouldSucceed()