21use PHPUnit\Framework\Attributes\BackupGlobals;
22use PHPUnit\Framework\Attributes\BackupStaticProperties;
23use PHPUnit\Framework\Attributes\PreserveGlobalState;
24use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
25use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
26use PHPUnit\Framework\Attributes\Test;
27use PHPUnit\Framework\Attributes\Small;
29require_once(
'./vendor/composer/vendor/autoload.php');
35use PHPUnit\Framework\TestCase;
42#[BackupGlobals(false)]
43#[BackupStaticProperties(false)]
44#[PreserveGlobalState(false)]
45#[RunTestsInSeparateProcesses]
48 use MockeryPHPUnitIntegration;
59 protected function setUp(): void
71 $metadata =
new Metadata(
'test.txt', 4500,
'text/plain');
73 $processor = Mockery::mock(PreProcessor::class);
74 $processor->shouldReceive(
'process')
79 $stream = Mockery::mock(FileStream::class);
80 $stream->shouldReceive(
'rewind')
84 $this->subject->with($processor);
85 $this->subject->with($processor);
86 $this->subject->with($processor);
88 $result = $this->subject->process($stream, $metadata);
91 $this->assertSame(
'All green!', $result->getMessage());
99 $metadata =
new Metadata(
'test.txt', 4500,
'text/plain');
101 $stream = Mockery::mock(FileStream::class);
103 $result = $this->subject->process($stream, $metadata);
105 $this->assertSame($expectedResponse->getCode(), $result->getCode());
106 $this->assertSame($expectedResponse->getMessage(), $result->getMessage());
116 $metadata =
new Metadata(
'test.txt', 4500,
'text/plain');
118 $processor = Mockery::mock(PreProcessor::class);
119 $processor->shouldReceive(
'process')
122 ->andReturnValues([$responseGood, $responseBad, $responseGood]);
124 $stream = Mockery::mock(FileStream::class);
125 $stream->shouldReceive(
'rewind')
129 $this->subject->with($processor);
130 $this->subject->with($processor);
131 $this->subject->with($processor);
133 $result = $this->subject->process($stream, $metadata);
135 $this->assertSame($responseBad->getCode(), $result->getCode());
136 $this->assertSame($responseBad->getMessage(), $result->getMessage());
145 $metadata =
new Metadata(
'test.txt', 4500,
'text/plain');
147 $processor = Mockery::mock(PreProcessor::class);
148 $processor->shouldReceive(
'process')
151 ->andReturn($responseGood);
153 $processor->shouldReceive(
'process')
156 ->andThrow(\RuntimeException::class,
'Bad stuff happened!');
158 $stream = Mockery::mock(FileStream::class);
159 $stream->shouldReceive(
'rewind')
163 $this->subject->with($processor);
164 $this->subject->with($processor);
165 $this->subject->with($processor);
167 $result = $this->subject->process($stream, $metadata);
170 $this->assertSame(
'Processor failed with exception message "Bad stuff happened!"', $result->getMessage());
Class PreProcessorManagerImplTest.
testProcessValidFileWhichShouldSucceed()
testProcessWithoutProcessorsWhichShouldSucceed()
testProcessValidFileWithFailingProcessorWhichShouldGetRejected()
testProcessInvalidFileWhichShouldGetRejected()
PreProcessorManagerImpl $subject
Class PreProcessorManagerImpl.
The base interface for all filesystem streams.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...