‪TYPO3CMS  9.5
TextExtractorRegistryTest.php
Go to the documentation of this file.
1 <?php
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 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪TextExtractorRegistryTest extends UnitTestCase
25 {
32  protected function ‪getTextExtractorRegistry(array $createsTextExtractorInstances = [])
33  {
34  ‪$textExtractorRegistry = $this->getMockBuilder(TextExtractorRegistry::class)
35  ->setMethods(['createTextExtractorInstance'])
36  ->getMock();
37 
38  if (!empty($createsTextExtractorInstances)) {
39  ‪$textExtractorRegistry->expects($this->any())
40  ->method('createTextExtractorInstance')
41  ->will($this->returnValueMap($createsTextExtractorInstances));
42  }
43 
45  }
46 
51  {
52  $textExtractorClass = $this->getUniqueId('myTextExtractor');
53  $textExtractorInstance = $this->getMockBuilder(TextExtractorInterface::class)
54  ->setMockClassName($textExtractorClass)
55  ->getMock();
56 
57  ‪$textExtractorRegistry = $this->‪getTextExtractorRegistry([[$textExtractorClass, $textExtractorInstance]]);
58 
59  ‪$textExtractorRegistry->registerTextExtractor($textExtractorClass);
60  $this->assertContains($textExtractorInstance, ‪$textExtractorRegistry->getTextExtractorInstances(), '', false, false);
61  }
62 
67  {
68  $this->expectException(\InvalidArgumentException::class);
69  $this->expectExceptionCode(1422906893);
70 
72  ‪$textExtractorRegistry->registerTextExtractor($this->getUniqueId());
73  }
74 
79  {
80  $this->expectException(\InvalidArgumentException::class);
81  $this->expectExceptionCode(1422771427);
82 
84  ‪$textExtractorRegistry->registerTextExtractor(__CLASS__);
85  }
86 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction\TextExtractorRegistryTest\registerTextExtractorThrowsExceptionIfClassDoesNotImplementRightInterface
‪registerTextExtractorThrowsExceptionIfClassDoesNotImplementRightInterface()
Definition: TextExtractorRegistryTest.php:78
‪TYPO3\CMS\Core\Resource\TextExtraction\TextExtractorInterface
Definition: TextExtractorInterface.php:23
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction\TextExtractorRegistryTest
Definition: TextExtractorRegistryTest.php:25
‪TYPO3\CMS\Core\Resource\TextExtraction\TextExtractorRegistry
Definition: TextExtractorRegistry.php:25
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction\TextExtractorRegistryTest\registeredTextExtractorClassCanBeRetrieved
‪registeredTextExtractorClassCanBeRetrieved()
Definition: TextExtractorRegistryTest.php:50
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction\TextExtractorRegistryTest\getTextExtractorRegistry
‪PHPUnit_Framework_MockObject_MockObject TextExtractorRegistry getTextExtractorRegistry(array $createsTextExtractorInstances=[])
Definition: TextExtractorRegistryTest.php:32
‪$textExtractorRegistry
‪$textExtractorRegistry
Definition: ext_localconf.php:127
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction
Definition: PlainTextExtractorTest.php:2
‪TYPO3\CMS\Core\Tests\Unit\Resource\TextExtraction\TextExtractorRegistryTest\registerTextExtractorThrowsExceptionIfClassDoesNotExist
‪registerTextExtractorThrowsExceptionIfClassDoesNotExist()
Definition: TextExtractorRegistryTest.php:66