ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\ResourceStorage\Flavours\AccessTokenTest Class Reference

Class FlavourMachineTest. More...

+ Inheritance diagram for ILIAS\ResourceStorage\Flavours\AccessTokenTest:
+ Collaboration diagram for ILIAS\ResourceStorage\Flavours\AccessTokenTest:

Public Member Functions

 testMemoryStream ()
 
 testRealStream ()
 
 testStreamAccessInfoWrongDirectory ()
 
 testStreamAccessInfoOutsideDirectory ()
 
- Public Member Functions inherited from ILIAS\ResourceStorage\AbstractBaseTest
 getDummyStream ()
 

Private Attributes

const TEST_SVG = 'test.svg'
 
const INSIDE = __DIR__ . '/files/inside/'
 
const OUTSIDE = __DIR__ . '/files/outside/'
 
const INSIDE_FILE = self::INSIDE . self::TEST_SVG
 
const OUTSIDE_FILE = self::OUTSIDE . self::TEST_SVG
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\ResourceStorage\AbstractBaseTest
 setUp ()
 
 getDummyUploadResult (string $file_name, string $mime_type, int $size)
 
 getDummyFileRevision (ResourceIdentification $id)
 
- Protected Attributes inherited from ILIAS\ResourceStorage\AbstractBaseTest
ILIAS ResourceStorage DummyIDGenerator $id_generator
 
 $db_mock
 

Detailed Description

Class FlavourMachineTest.

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 32 of file AccessTokenTest.php.

Member Function Documentation

◆ testMemoryStream()

ILIAS\ResourceStorage\Flavours\AccessTokenTest::testMemoryStream ( )

Definition at line 40 of file AccessTokenTest.php.

References $token, and ILIAS\Filesystem\Stream\Streams\ofString().

40  : void
41  {
42  $tof = new TokenFactory(__DIR__);
43 
44  $file_stream = Streams::ofString('test');
45  $token = $tof->lease($file_stream);
46 
47  $this->assertFalse($token->hasStreamableStream());
48  $this->assertTrue($token->hasInMemoryStream());
49 
50  $token_stream = $token->resolveStream();
51 
52  $this->assertFalse($token->hasStreamableStream());
53 
54  $this->assertTrue($token_stream->isReadable());
55  $this->assertFalse($token_stream->isWritable());
56  $this->assertEquals('application/x-empty', $token_stream->getMimeType());
57  }
$token
Definition: xapitoken.php:70
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
+ Here is the call graph for this function:

◆ testRealStream()

ILIAS\ResourceStorage\Flavours\AccessTokenTest::testRealStream ( )

Definition at line 59 of file AccessTokenTest.php.

References $token, and ILIAS\Filesystem\Stream\Streams\ofResource().

59  : void
60  {
61  $tof = new TokenFactory(__DIR__);
62 
63  $file_stream = Streams::ofResource(fopen(self::INSIDE_FILE, 'rb'));
64 
65  $token = $tof->lease($file_stream);
66  $this->assertFalse($token->hasStreamableStream());
67  $this->assertFalse($token->hasInMemoryStream());
68 
69  $token_stream = $token->resolveStream();
70 
71  $this->assertTrue($token->hasStreamableStream());
72  $this->assertFalse($token->hasInMemoryStream());
73 
74  $this->assertTrue($token_stream->isReadable());
75  $this->assertFalse($token_stream->isWritable());
76  $this->assertEquals('image/svg+xml', $token_stream->getMimeType());
77 
78  $token2 = $tof->lease($file_stream, true);
79  $this->assertTrue($token->hasStreamableStream());
80  $this->assertFalse($token->hasInMemoryStream());
81  }
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:65
$token
Definition: xapitoken.php:70
+ Here is the call graph for this function:

◆ testStreamAccessInfoOutsideDirectory()

ILIAS\ResourceStorage\Flavours\AccessTokenTest::testStreamAccessInfoOutsideDirectory ( )

Definition at line 91 of file AccessTokenTest.php.

References ILIAS\Filesystem\Stream\Streams\ofResource().

91  : void
92  {
93  $tof = new TokenFactory(self::INSIDE);
94  $file_stream_outside = Streams::ofResource(fopen(self::OUTSIDE_FILE, 'rb'));
95  $file_stream_inside = Streams::ofResource(fopen(self::INSIDE_FILE, 'rb'));
96  $this->assertInstanceOf(Token::class, $tof->lease($file_stream_inside));
97  $this->expectException(\InvalidArgumentException::class);
98  $tof->lease($file_stream_outside);
99  }
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:65
+ Here is the call graph for this function:

◆ testStreamAccessInfoWrongDirectory()

ILIAS\ResourceStorage\Flavours\AccessTokenTest::testStreamAccessInfoWrongDirectory ( )

Definition at line 84 of file AccessTokenTest.php.

84  : void
85  {
86  $this->expectException(\InvalidArgumentException::class);
87  $sif = new TokenFactory('/loremipsum/');
88  $sif->check('loremipsum');
89  }

Field Documentation

◆ INSIDE

const ILIAS\ResourceStorage\Flavours\AccessTokenTest::INSIDE = __DIR__ . '/files/inside/'
private

Definition at line 35 of file AccessTokenTest.php.

◆ INSIDE_FILE

const ILIAS\ResourceStorage\Flavours\AccessTokenTest::INSIDE_FILE = self::INSIDE . self::TEST_SVG
private

Definition at line 37 of file AccessTokenTest.php.

◆ OUTSIDE

const ILIAS\ResourceStorage\Flavours\AccessTokenTest::OUTSIDE = __DIR__ . '/files/outside/'
private

Definition at line 36 of file AccessTokenTest.php.

◆ OUTSIDE_FILE

const ILIAS\ResourceStorage\Flavours\AccessTokenTest::OUTSIDE_FILE = self::OUTSIDE . self::TEST_SVG
private

Definition at line 38 of file AccessTokenTest.php.

◆ TEST_SVG

const ILIAS\ResourceStorage\Flavours\AccessTokenTest::TEST_SVG = 'test.svg'
private

Definition at line 34 of file AccessTokenTest.php.


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