ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest Class Reference

Header based delivery (X-Sendfile, X-Accel) opens the file only after PHP has finished. More...

+ Inheritance diagram for ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest:
+ Collaboration diagram for ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest:

Public Member Functions

 testFileToDeleteIsDeliveredByTheFallback ()
 
 testFileToDeleteIsDeliveredByABuilderSupportingDeletion ()
 
 testFileToKeepIsDeliveredByTheConfiguredBuilder ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Private Member Functions

 assertDeliveredBy (string $expected, bool $supports_deletion, bool $delete_file)
 
 builder (string $name, bool $used, ResponseInterface $response, bool $supports_deletion)
 
 requestTo (string $uri)
 

Private Attributes

string $file = null
 

Detailed Description

Header based delivery (X-Sendfile, X-Accel) opens the file only after PHP has finished.

A file which is deleted after the delivery must be streamed by PHP, see https://mantis.ilias.de/view.php?id=48312

Definition at line 36 of file LegacyDeliveryTest.php.

Member Function Documentation

◆ assertDeliveredBy()

ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest::assertDeliveredBy ( string  $expected,
bool  $supports_deletion,
bool  $delete_file 
)
private

Definition at line 68 of file LegacyDeliveryTest.php.

68 : void
69 {
70 $response = (new MessageFactoryImpl())->response();
71
72 $http = $this->createStub(\ILIAS\HTTP\Services::class);
73 $http->method('request')->willReturn($this->requestTo('https://ilias.example.org/'));
74 $http->method('response')->willReturn($response);
75 // close() is never, the test leaves deliver() by an exception instead
76 $http->method('close')->willThrowException(new \RuntimeException('closed'));
77
78 $configured = $this->builder('configured', $expected === 'configured', $response, $supports_deletion);
79 $fallback = $this->builder('fallback', $expected === 'fallback', $response, true);
80
81 $delivery = new LegacyDelivery($http, $configured, $fallback);
82
83 $this->expectExceptionMessage('closed');
84 $delivery->attached($this->file, 'file.zip', 'application/zip', $delete_file);
85 }
builder(string $name, bool $used, ResponseInterface $response, bool $supports_deletion)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$response
Definition: xapitoken.php:92

References ILIAS\BookingManager\Common\Table\$http, $response, ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest\builder(), and ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest\requestTo().

Referenced by ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest\testFileToDeleteIsDeliveredByABuilderSupportingDeletion(), ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest\testFileToDeleteIsDeliveredByTheFallback(), and ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest\testFileToKeepIsDeliveredByTheConfiguredBuilder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ builder()

ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest::builder ( string  $name,
bool  $used,
ResponseInterface  $response,
bool  $supports_deletion 
)
private

Definition at line 87 of file LegacyDeliveryTest.php.

92 : ResponseBuilder&MockObject {
93 $builder = $this->createMock(ResponseBuilder::class);
94 $builder->method('getName')->willReturn($name);
95 $builder->method('supportFileDeletion')->willReturn($supports_deletion);
96 $builder->expects($used ? $this->once() : $this->never())
97 ->method('buildForStream')
98 ->willReturn($response);
99
100 return $builder;
101 }

Referenced by ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest\assertDeliveredBy().

+ Here is the caller graph for this function:

◆ requestTo()

ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest::requestTo ( string  $uri)
private

Definition at line 103 of file LegacyDeliveryTest.php.

103 : ServerRequestInterface
104 {
105 $request = $this->createStub(ServerRequestInterface::class);
106 $request->method('getUri')->willReturn((new MessageFactoryImpl())->uri($uri));
107
108 return $request;
109 }
$request
@ilCtrl_Calls ilObjLearningSequenceContentGUI: ilObjLearningSequenceConditionsGUI
Definition: ltiauth.php:39

References $request.

Referenced by ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest\assertDeliveredBy().

+ Here is the caller graph for this function:

◆ setUp()

ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest::setUp ( )
protected

Definition at line 40 of file LegacyDeliveryTest.php.

40 : void
41 {
42 $this->file = tempnam(sys_get_temp_dir(), 'legacy');
43 file_put_contents($this->file, 'content');
44 }

◆ tearDown()

ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest::tearDown ( )
protected

Definition at line 46 of file LegacyDeliveryTest.php.

46 : void
47 {
48 if ($this->file !== null && is_file($this->file)) {
49 unlink($this->file);
50 }
51 }

◆ testFileToDeleteIsDeliveredByABuilderSupportingDeletion()

ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest::testFileToDeleteIsDeliveredByABuilderSupportingDeletion ( )

Definition at line 58 of file LegacyDeliveryTest.php.

58 : void
59 {
60 $this->assertDeliveredBy('configured', true, true);
61 }
assertDeliveredBy(string $expected, bool $supports_deletion, bool $delete_file)

References ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest\assertDeliveredBy().

+ Here is the call graph for this function:

◆ testFileToDeleteIsDeliveredByTheFallback()

ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest::testFileToDeleteIsDeliveredByTheFallback ( )

Definition at line 53 of file LegacyDeliveryTest.php.

53 : void
54 {
55 $this->assertDeliveredBy('fallback', false, true);
56 }

References ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest\assertDeliveredBy().

+ Here is the call graph for this function:

◆ testFileToKeepIsDeliveredByTheConfiguredBuilder()

ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest::testFileToKeepIsDeliveredByTheConfiguredBuilder ( )

Definition at line 63 of file LegacyDeliveryTest.php.

63 : void
64 {
65 $this->assertDeliveredBy('configured', false, false);
66 }

References ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest\assertDeliveredBy().

+ Here is the call graph for this function:

Field Documentation

◆ $file

string ILIAS\Tests\FileDelivery\Delivery\LegacyDeliveryTest::$file = null
private

Definition at line 38 of file LegacyDeliveryTest.php.


The documentation for this class was generated from the following file: