ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PreProcessorTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\LegalDocuments\test\ContainerMock;
27use PHPUnit\Framework\TestCase;
29
30require_once __DIR__ . '/../ContainerMock.php';
31
32class PreProcessorTest extends TestCase
33{
34 use ContainerMock;
35
36 public function testConstruct(): void
37 {
38 $this->assertInstanceOf(PreProcessor::class, new PreProcessor($this->fail(...)));
39 }
40
41 public function testProcess(): void
42 {
43 $expected_value = 'Dummty content';
44 $value = null;
45 $instance = new PreProcessor(static function (string $content) use (&$value): void {
46 $value = $content;
47 });
48
49 $result = $instance->process(
50 $this->mockMethod(FileStream::class, 'getContents', [], $expected_value),
51 new Metadata('dummy file name', 1234, 'text/html') // Cannot be mocked because it is final.
52 );
53
54 $this->assertSame($expected_value, $value);
55 $this->assertInstanceOf(ProcessingStatus::class, $result);
56 $this->assertSame(ProcessingStatus::OK, $result->getCode());
57 $this->assertSame('idontcare', $result->getMessage());
58 }
59}
process(FileStream $stream, Metadata $metadata)
This method gets invoked by the file upload service to process the file with the help of the processo...
The base interface for all filesystem streams.
Definition: FileStream.php:32