[TASK] Shorten the extend class in all unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Resource / Index / ExtractorRegistryTest.php
index e8c4de8..51b25c0 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource\Index;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\UnitTestCase;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Class ExtractorRegistryTest
@@ -27,9 +27,11 @@ class ExtractorRegistryTest extends UnitTestCase
     public function registeredExtractorClassCanBeRetrieved()
     {
         $extractorClass = 'a9f4d5e4ebb4b03547a2a6094e1170ac';
-        $extractorObject = $this->getMock(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class, array(), array(), $extractorClass);
+        $extractorObject = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class)
+            ->setMockClassName($extractorClass)
+            ->getMock();
 
-        $extractorRegistry = $this->getMockExtractorRegistry(array(array($extractorClass, $extractorObject)));
+        $extractorRegistry = $this->getMockExtractorRegistry([[$extractorClass, $extractorObject]]);
 
         $extractorRegistry->registerExtractionService($extractorClass);
         $this->assertContains($extractorObject, $extractorRegistry->getExtractors(), '', false, false);
@@ -37,11 +39,12 @@ class ExtractorRegistryTest extends UnitTestCase
 
     /**
      * @test
-     * @expectedException \InvalidArgumentException
-     * @expectedExceptionCode 1422705270
      */
     public function registerExtractorClassThrowsExceptionIfClassDoesNotExist()
     {
+        $this->expectException(\InvalidArgumentException::class);
+        $this->expectExceptionCode(1422705270);
+
         $className = 'e1f9aa4e1cd3aa7ff05dcdccb117156a';
         $extractorRegistry = $this->getMockExtractorRegistry();
         $extractorRegistry->registerExtractionService($className);
@@ -49,11 +52,12 @@ class ExtractorRegistryTest extends UnitTestCase
 
     /**
      * @test
-     * @expectedException \InvalidArgumentException
-     * @expectedExceptionCode 1422705271
      */
     public function registerExtractorClassThrowsExceptionIfClassDoesNotImplementRightInterface()
     {
+        $this->expectException(\InvalidArgumentException::class);
+        $this->expectExceptionCode(1422705271);
+
         $className = __CLASS__;
         $extractorRegistry = $this->getMockExtractorRegistry();
         $extractorRegistry->registerExtractionService($className);
@@ -65,22 +69,28 @@ class ExtractorRegistryTest extends UnitTestCase
     public function registerExtractorClassWithHighestPriorityIsFirstInResult()
     {
         $extractorClass1 = 'db76010e5c24658c35ea1605cce2391d';
-        $extractorObject1 = $this->getMock(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class, array(), array(), $extractorClass1);
+        $extractorObject1 = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class)
+            ->setMockClassName($extractorClass1)
+            ->getMock();
         $extractorObject1->expects($this->any())->method('getPriority')->will($this->returnValue(1));
 
         $extractorClass2 = 'ad9195e2487eea33c8a2abd5cf33cba4';
-        $extractorObject2 = $this->getMock(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class, array(), array(), $extractorClass2);
+        $extractorObject2 = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class)
+            ->setMockClassName($extractorClass2)
+            ->getMock();
         $extractorObject2->expects($this->any())->method('getPriority')->will($this->returnValue(10));
 
         $extractorClass3 = 'cef9aa4e1cd3aa7ff05dcdccb117156a';
-        $extractorObject3 = $this->getMock(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class, array(), array(), $extractorClass3);
+        $extractorObject3 = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class)
+            ->setMockClassName($extractorClass3)
+            ->getMock();
         $extractorObject3->expects($this->any())->method('getPriority')->will($this->returnValue(2));
 
-        $createdExtractorInstances = array(
-            array($extractorClass1, $extractorObject1),
-            array($extractorClass2, $extractorObject2),
-            array($extractorClass3, $extractorObject3),
-        );
+        $createdExtractorInstances = [
+            [$extractorClass1, $extractorObject1],
+            [$extractorClass2, $extractorObject2],
+            [$extractorClass3, $extractorObject3],
+        ];
 
         $extractorRegistry = $this->getMockExtractorRegistry($createdExtractorInstances);
         $extractorRegistry->registerExtractionService($extractorClass1);
@@ -100,17 +110,21 @@ class ExtractorRegistryTest extends UnitTestCase
     public function registeredExtractorClassWithSamePriorityAreAllReturned()
     {
         $extractorClass1 = 'b70551b2b2db62b6b15a9bbfcbd50614';
-        $extractorObject1 = $this->getMock(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class, array(), array(), $extractorClass1);
+        $extractorObject1 = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class)
+            ->setMockClassName($extractorClass1)
+            ->getMock();
         $extractorObject1->expects($this->any())->method('getPriority')->will($this->returnValue(1));
 
         $extractorClass2 = 'ac318f1659d278b79b38262f23a78d5d';
-        $extractorObject2 = $this->getMock(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class, array(), array(), $extractorClass2);
+        $extractorObject2 = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\Index\ExtractorInterface::class)
+            ->setMockClassName($extractorClass2)
+            ->getMock();
         $extractorObject2->expects($this->any())->method('getPriority')->will($this->returnValue(1));
 
-        $createdExtractorInstances = array(
-            array($extractorClass1, $extractorObject1),
-            array($extractorClass2, $extractorObject2),
-        );
+        $createdExtractorInstances = [
+            [$extractorClass1, $extractorObject1],
+            [$extractorClass2, $extractorObject2],
+        ];
 
         $extractorRegistry = $this->getMockExtractorRegistry($createdExtractorInstances);
         $extractorRegistry->registerExtractionService($extractorClass1);
@@ -127,10 +141,10 @@ class ExtractorRegistryTest extends UnitTestCase
      * @param array $createsExtractorInstances
      * @return \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Resource\Index\ExtractorRegistry
      */
-    protected function getMockExtractorRegistry(array $createsExtractorInstances = array())
+    protected function getMockExtractorRegistry(array $createsExtractorInstances = [])
     {
         $extractorRegistry = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\Index\ExtractorRegistry::class)
-            ->setMethods(array('createExtractorInstance'))
+            ->setMethods(['createExtractorInstance'])
             ->getMock();
 
         if (!empty($createsExtractorInstances)) {