ILIAS  release_8 Revision v8.24
XSendfileTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
8use Mockery;
9use PHPUnit\Framework\TestCase;
10use Psr\Http\Message\ResponseInterface;
11
12/******************************************************************************
13 *
14 * This file is part of ILIAS, a powerful learning management system.
15 *
16 * ILIAS is licensed with the GPL-3.0, you should have received a copy
17 * of said license along with the source code.
18 *
19 * If this is not the case or you just want to try ILIAS, you'll find
20 * us at:
21 * https://www.ilias.de
22 * https://github.com/ILIAS-eLearning
23 *
24 *****************************************************************************/
25
36class XSendfileTest extends TestCase
37{
42
46 protected function setUp(): void
47 {
48 $this->httpServiceMock = $this->getMockBuilder(Services::class)
49 ->disableOriginalConstructor()
50 ->getMock();
51 }
52
57 {
58 $expectedHeader = 'X-Sendfile';
59 $filePath = __FILE__;
60
61 $response = $this->getMockBuilder(ResponseInterface::class)
62 ->disableOriginalConstructor()
63 ->getMock();
64
65 $response->expects($this->once())
66 ->method('withHeader')
67 ->with($expectedHeader, $filePath)
68 ->willReturnSelf();
69
70 $this->httpServiceMock->expects($this->once())
71 ->method('response')
72 ->willReturn($response);
73
74 $this->httpServiceMock->expects($this->once())
75 ->method('saveResponse')
76 ->with($response);
77
78 $this->httpServiceMock->expects($this->once())
79 ->method('sendResponse');
80
81 $fileDeliveryType = new XSendfile($this->httpServiceMock);
82 $fileDeliveryType->deliver($filePath, false);
83 }
84}
Class Services.
Definition: Services.php:38
$response