ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
XSendfileTest.php
Go to the documentation of this file.
1<?php
2
4
5require_once('./libs/composer/vendor/autoload.php');
6
9use Mockery;
10use PHPUnit\Framework\TestCase;
12
23class XSendfileTest extends TestCase
24{
25 use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
26
31
32
36 protected function setUp()
37 {
38 parent::setUp();
39
40 $this->httpServiceMock = Mockery::mock(HTTPServices::class);
41 $this->httpServiceMock->shouldIgnoreMissing();
42
43 //set remote address to localhost
44 //$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
45
46 require_once './Services/FileDelivery/classes/FileDeliveryTypes/XSendfile.php';
47 }
48
49
54 {
55 $expectedHeader = 'X-Sendfile';
56 $filePath = __FILE__;
57
58 $response = Mockery::mock(ResponseInterface::class);
59 $response->shouldIgnoreMissing()->shouldReceive("withHeader")->times(1)
60 ->withArgs([ $expectedHeader, $filePath ])->andReturnSelf();
61
62 $this->httpServiceMock->shouldReceive("response")->times(1)->withNoArgs()
63 ->andReturn($response)->getMock()->shouldReceive("saveResponse")
64 ->times(1)->withArgs([ $response ])->getMock()
65 ->shouldReceive("sendResponse")->times(1)->withNoArgs();
66
67 $fileDeliveryType = new XSendfile($this->httpServiceMock);
68 $fileDeliveryOk = $fileDeliveryType->deliver($filePath, false);
69
70 $this->assertTrue($fileDeliveryOk);
71 }
72}
An exception for terminatinating execution or to throw for unit testing.
Provides an interface to the ILIAS HTTP services.
Interface GlobalHttpState.
Representation of an outgoing, server-side response.
$response