‪TYPO3CMS  10.4
TextExtractorRegistryTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪TextExtractorRegistryTest extends UnitTestCase
27 {
34  protected function ‪getTextExtractorRegistry(array $createsTextExtractorInstances = [])
35  {
36  ‪$textExtractorRegistry = $this->getMockBuilder(TextExtractorRegistry::class)
37  ->setMethods(['createTextExtractorInstance'])
38  ->getMock();
39 
40  if (!empty($createsTextExtractorInstances)) {
41  ‪$textExtractorRegistry->expects(self::any())
42  ->method('createTextExtractorInstance')
43  ->willReturnMap($createsTextExtractorInstances);
44  }
45 
47  }
48 
53  {
54  $textExtractorClass = ‪StringUtility::getUniqueId('myTextExtractor');
55  $textExtractorInstance = $this->getMockBuilder(TextExtractorInterface::class)
56  ->setMockClassName($textExtractorClass)
57  ->getMock();
58 
59  ‪$textExtractorRegistry = $this->‪getTextExtractorRegistry([[$textExtractorClass, $textExtractorInstance]]);
60 
61  ‪$textExtractorRegistry->registerTextExtractor($textExtractorClass);
62  self::assertContains($textExtractorInstance, ‪$textExtractorRegistry->getTextExtractorInstances());
63  }
64 
69  {
70  $this->expectException(\InvalidArgumentException::class);
71  $this->expectExceptionCode(1422906893);
72 
75  }
76 
81  {
82  $this->expectException(\InvalidArgumentException::class);
83  $this->expectExceptionCode(1422771427);
84 
86  ‪$textExtractorRegistry->registerTextExtractor(__CLASS__);
87  }
88 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction\TextExtractorRegistryTest\registerTextExtractorThrowsExceptionIfClassDoesNotImplementRightInterface
‪registerTextExtractorThrowsExceptionIfClassDoesNotImplementRightInterface()
Definition: TextExtractorRegistryTest.php:80
‪TYPO3\CMS\Core\Resource\TextExtraction\TextExtractorInterface
Definition: TextExtractorInterface.php:24
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction\TextExtractorRegistryTest
Definition: TextExtractorRegistryTest.php:27
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction\TextExtractorRegistryTest\getTextExtractorRegistry
‪PHPUnit Framework MockObject MockObject TextExtractorRegistry getTextExtractorRegistry(array $createsTextExtractorInstances=[])
Definition: TextExtractorRegistryTest.php:34
‪TYPO3\CMS\Core\Resource\TextExtraction\TextExtractorRegistry
Definition: TextExtractorRegistry.php:26
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction\TextExtractorRegistryTest\registeredTextExtractorClassCanBeRetrieved
‪registeredTextExtractorClassCanBeRetrieved()
Definition: TextExtractorRegistryTest.php:52
‪$textExtractorRegistry
‪$textExtractorRegistry
Definition: ext_localconf.php:26
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction
Definition: PlainTextExtractorTest.php:16
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:92
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction\TextExtractorRegistryTest\registerTextExtractorThrowsExceptionIfClassDoesNotExist
‪registerTextExtractorThrowsExceptionIfClassDoesNotExist()
Definition: TextExtractorRegistryTest.php:68