5 require_once(
'./libs/composer/vendor/autoload.php');
58 $processorMock = \Mockery::mock(PreProcessor::class);
59 $this->prePorcessorManagerMock->shouldReceive(
'with')
61 ->with($processorMock);
63 $this->subject->register($processorMock);
72 $processorMock = \Mockery::mock(PreProcessor::class);
74 $this->globalHttpStateMock->shouldReceive(
'request->getUploadedFiles')
78 $this->expectException(IllegalStateException::class);
79 $this->expectExceptionMessage(
'Can not register processor after the upload was processed.');
81 $this->subject->process();
82 $this->subject->register($processorMock);
94 ->shouldReceive(
'getClientFilename')
96 ->andReturn(
'hello.txt')
98 ->shouldReceive(
'getSize')
102 ->shouldReceive(
'getClientMediaType')
104 ->andReturn(
'text/plain')
106 ->shouldReceive(
'getError')
108 ->andReturn(UPLOAD_ERR_OK)
110 ->shouldReceive(
'getStream')
118 $this->prePorcessorManagerMock->shouldReceive(
'process')
121 ->andReturn($processingResult);
123 $this->globalHttpStateMock->shouldReceive(
'request->getUploadedFiles')
125 ->andReturn($uploadedFiles);
127 $this->subject->process();
138 ->shouldReceive(
'getClientFilename')
140 ->andReturn(
'hello.txt')
142 ->shouldReceive(
'getSize')
146 ->shouldReceive(
'getClientMediaType')
148 ->andReturn(
'text/plain')
150 ->shouldReceive(
'getError')
152 ->andReturn(UPLOAD_ERR_PARTIAL)
154 ->shouldReceive(
'getStream')
162 $this->globalHttpStateMock->shouldReceive(
'request->getUploadedFiles')
164 ->andReturn($uploadedFiles);
166 $this->subject->process();
168 $result = $this->subject->getResults()[0];
180 $this->globalHttpStateMock->shouldReceive(
'request->getUploadedFiles')
183 $this->assertFalse($this->subject->hasUploads());
194 $this->globalHttpStateMock->shouldReceive(
'request->getUploadedFiles')
198 $this->assertTrue($this->subject->hasUploads());
208 for (
$i = 0;
$i < 10;
$i++) {
209 $files[] = Mockery::mock(UploadedFileInterface::class);
212 $this->globalHttpStateMock->shouldReceive(
'request->getUploadedFiles')
216 $this->assertTrue($this->subject->hasUploads());
227 $this->prePorcessorManagerMock = \Mockery::mock(PreProcessorManager::class);
228 $this->filesystemsMock = \Mockery::mock(Filesystems::class);
229 $this->globalHttpStateMock = \Mockery::mock(GlobalHttpState::class);
231 $this->subject =
new FileUploadImpl($this->prePorcessorManagerMock, $this->filesystemsMock, $this->globalHttpStateMock);
const REJECTED
Upload got rejected by a processor.
testRegisterWithProcessedFilesWhichShouldFail()
testHasUploadsWithSingleUploadedFile()
testRegisterWhichShouldSucceed()
static ofString($string)
Creates a new stream with an initial value.
testProcessWhichShouldSucceed()
testHasUploadsWithMultipleUploadedFile()
testProcessWithFailedUploadWhichShouldGetRejected()
testHasUploadsWithoutUploadedFiles()
Class FileUploadImplTest.