[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Resource / Index / IndexerTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Resource\Index;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Resource\File;
18 use TYPO3\CMS\Core\Resource\Index\ExtractorInterface;
19 use TYPO3\CMS\Core\Resource\Index\Indexer;
20
21 /**
22 * Class IndexerTest
23 */
24 class IndexerTest extends \TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase
25 {
26 /**
27 * @test
28 */
29 public function isFileTypeSupportedByExtractorReturnsFalesForFileTypeTextAndExtractorLimitedToFileTypeImage()
30 {
31 $mockStorage = $this->createMock(\TYPO3\CMS\Core\Resource\ResourceStorage::class);
32 $mockFile = $this->createMock(File::class);
33 $mockFile->expects($this->any())->method('getType')->will($this->returnValue(
34 File::FILETYPE_TEXT
35 ));
36
37 $mockExtractor = $this->createMock(ExtractorInterface::class);
38 $mockExtractor->expects($this->any())->method('getFileTypeRestrictions')->will($this->returnValue(
39 [File::FILETYPE_IMAGE]
40 ));
41
42 $method = new \ReflectionMethod(Indexer::class, 'isFileTypeSupportedByExtractor');
43 $method->setAccessible(true);
44 $arguments = [
45 $mockFile,
46 $mockExtractor
47 ];
48
49 $result = $method->invokeArgs(new Indexer($mockStorage), $arguments);
50 $this->assertFalse($result);
51 }
52
53 /**
54 * @test
55 */
56 public function isFileTypeSupportedByExtractorReturnsTrueForFileTypeImageAndExtractorLimitedToFileTypeImage()
57 {
58 $mockStorage = $this->createMock(\TYPO3\CMS\Core\Resource\ResourceStorage::class);
59 $mockFile = $this->createMock(File::class);
60 $mockFile->expects($this->any())->method('getType')->will($this->returnValue(
61 File::FILETYPE_IMAGE
62 ));
63
64 $mockExtractor = $this->createMock(ExtractorInterface::class);
65 $mockExtractor->expects($this->any())->method('getFileTypeRestrictions')->will($this->returnValue(
66 [File::FILETYPE_IMAGE]
67 ));
68
69 $method = new \ReflectionMethod(Indexer::class, 'isFileTypeSupportedByExtractor');
70 $method->setAccessible(true);
71 $arguments = [
72 $mockFile,
73 $mockExtractor
74 ];
75
76 $result = $method->invokeArgs(new Indexer($mockStorage), $arguments);
77 $this->assertTrue($result);
78 }
79
80 /**
81 * @test
82 */
83 public function isFileTypeSupportedByExtractorReturnsTrueForFileTypeTextAndExtractorHasNoFileTypeLimitation()
84 {
85 $mockStorage = $this->createMock(\TYPO3\CMS\Core\Resource\ResourceStorage::class);
86 $mockFile = $this->createMock(File::class);
87 $mockFile->expects($this->any())->method('getType')->will($this->returnValue(
88 File::FILETYPE_TEXT
89 ));
90
91 $mockExtractor = $this->createMock(ExtractorInterface::class);
92 $mockExtractor->expects($this->any())->method('getFileTypeRestrictions')->will($this->returnValue(
93 []
94 ));
95
96 $method = new \ReflectionMethod(Indexer::class, 'isFileTypeSupportedByExtractor');
97 $method->setAccessible(true);
98 $arguments = [
99 $mockFile,
100 $mockExtractor
101 ];
102
103 $result = $method->invokeArgs(new Indexer($mockStorage), $arguments);
104 $this->assertTrue($result);
105 }
106 }