ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
XSendfileTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
38 class XSendfileTest extends TestCase
39 {
44 
48  protected function setUp(): void
49  {
50  $this->httpServiceMock = $this->getMockBuilder(Services::class)
51  ->disableOriginalConstructor()
52  ->getMock();
53  }
54 
59  {
60  $expectedHeader = 'X-Sendfile';
61  $filePath = __FILE__;
62 
63  $response = $this->getMockBuilder(ResponseInterface::class)
64  ->disableOriginalConstructor()
65  ->getMock();
66 
67  $response->expects($this->once())
68  ->method('withHeader')
69  ->with($expectedHeader, $filePath)
70  ->willReturnSelf();
71 
72  $this->httpServiceMock->expects($this->once())
73  ->method('response')
74  ->willReturn($response);
75 
76  $this->httpServiceMock->expects($this->once())
77  ->method('saveResponse')
78  ->with($response);
79 
80  $this->httpServiceMock->expects($this->once())
81  ->method('sendResponse');
82 
83  $fileDeliveryType = new XSendfile($this->httpServiceMock);
84  $fileDeliveryType->deliver($filePath, false);
85  }
86 }
$response
Definition: xapitoken.php:90