29 require_once(
'./vendor/composer/vendor/autoload.php');
42 #[BackupGlobals(false)] 43 #[BackupStaticProperties(false)] 44 #[PreserveGlobalState(false)] 45 #[RunTestsInSeparateProcesses] 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());
98 $expectedResponse =
new ProcessingStatus(
ProcessingStatus::OK,
'No processors were registered.');
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());
testProcessValidFileWithFailingProcessorWhichShouldGetRejected()
testProcessWithoutProcessorsWhichShouldSucceed()
testProcessValidFileWhichShouldSucceed()
PreProcessorManagerImpl $subject
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class PreProcessorManagerImpl.
testProcessInvalidFileWhichShouldGetRejected()
Class PreProcessorManagerImplTest.