Browse Source

update unit tests

Olivier Massot 1 year ago
parent
commit
59a25728ea

File diff suppressed because it is too large
+ 0 - 0
ot_core/Tests/Build/.phpunit.result.cache


+ 6 - 5
ot_core/Tests/Unit/Controller/SelectedSiteControllerTest.php

@@ -9,7 +9,7 @@ use Opentalent\OtCore\Website\OtWebsiteRepository;
 use PHPUnit\Framework\MockObject\MockObject;
 use Psr\Http\Message\ResponseInterface;
 use TYPO3\CMS\Extbase\Mvc\RequestInterface;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
 class TestableSelectedSiteController extends SelectedSiteController {
     public $currentWebsite;
@@ -26,7 +26,7 @@ class TestableSelectedSiteController extends SelectedSiteController {
     }
 }
 
-class SelectedSiteControllerTest extends UnitTestCase
+class SelectedSiteControllerTest extends OtUnitTestCase
 {
     protected MockObject | OtPageRepository $otPageRepository;
     protected MockObject | OtWebsiteRepository $otWebsiteRepository;
@@ -46,9 +46,10 @@ class SelectedSiteControllerTest extends UnitTestCase
 
     public function getMockForMethod(string $methodName): MockObject | TestableSelectedSiteController
     {
-        $controller = $this->getMockBuilder(TestableSelectedSiteController::class)
-            ->setMethodsExcept([$methodName, 'injectOtPageRepository', 'injectOtWebsiteRepository'])
-            ->getMock();
+        $controller = $this->getMockForMethods(
+            TestableSelectedSiteController::class,
+            [$methodName, 'injectOtPageRepository', 'injectOtWebsiteRepository']
+        );
 
         $controller->injectOtPageRepository($this->otPageRepository);
         $controller->injectOtWebsiteRepository($this->otWebsiteRepository);

+ 2 - 2
ot_core/Tests/Unit/Domain/Model/DonorTest.php

@@ -4,9 +4,9 @@ namespace Opentalent\OtCore\Tests\Unit\Domain;
 
 use AssertionError;
 use Opentalent\OtCore\Domain\Model\Donor;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
-class DonorTest extends UnitTestCase
+class DonorTest extends OtUnitTestCase
 {
     /**
      * Object should instantiate correctly, and properties

+ 2 - 2
ot_core/Tests/Unit/Domain/Model/EventTest.php

@@ -5,9 +5,9 @@ namespace Opentalent\OtCore\Tests\Unit\Domain;
 use AssertionError;
 use Opentalent\OtCore\Domain\Model\Event;
 use Opentalent\OtCore\Domain\Model\Organization;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
-class EventTest extends UnitTestCase
+class EventTest extends OtUnitTestCase
 {
     /**
      * Object should instantiate correctly, and properties

+ 2 - 2
ot_core/Tests/Unit/Domain/Model/OrganizationTest.php

@@ -4,9 +4,9 @@ namespace Opentalent\OtCore\Tests\Unit\Domain;
 
 use AssertionError;
 use Opentalent\OtCore\Domain\Model\Organization;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
-class OrganizationTest extends UnitTestCase
+class OrganizationTest extends OtUnitTestCase
 {
     /**
      * Object should instantiate correctly, and properties

+ 2 - 2
ot_core/Tests/Unit/Domain/Repository/AbstractApiRepositoryTestCase.php

@@ -8,14 +8,14 @@ use Opentalent\OtCore\Tests\Unit\Fixtures\ApiResponseFixtures;
 use Prophecy\PhpUnit\ProphecyTrait;
 use ReflectionClass;
 use TYPO3\CMS\Core\Core\ApplicationContext;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
 /**
  * Base class for BaseApiRepositoryTest and its subclasses
  *
  * @package Opentalent\OtCore\Tests\Unit\Repository
  */
-abstract class AbstractApiRepositoryTestCase extends UnitTestCase
+abstract class AbstractApiRepositoryTestCase extends OtUnitTestCase
 {
     use ProphecyTrait;
 

+ 2 - 2
ot_core/Tests/Unit/Domain/Repository/ApiPagedCollectionTest.php

@@ -3,9 +3,9 @@
 namespace Opentalent\OtCore\Tests\Unit\Repository;
 
 use Opentalent\OtCore\Domain\Repository\ApiPagedCollection;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
-class ApiPagedCollectionTest extends UnitTestCase
+class ApiPagedCollectionTest extends OtUnitTestCase
 {
     /**
      * @test

+ 2 - 2
ot_core/Tests/Unit/Exception/ApiRequestExceptionTest.php

@@ -4,9 +4,9 @@ namespace Opentalent\OtCore\Tests\Unit\Exception;
 
 use Exception;
 use Opentalent\OtCore\Exception\ApiRequestException;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
-class ApiRequestExceptionTest extends UnitTestCase
+class ApiRequestExceptionTest extends OtUnitTestCase
 {
     /**
      * Construction from another exception

+ 19 - 0
ot_core/Tests/Unit/OtUnitTestCase.php

@@ -0,0 +1,19 @@
+<?php
+declare(strict_types=1);
+
+namespace Opentalent\OtCore\Tests\Unit;
+
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
+class OtUnitTestCase extends UnitTestCase
+{
+    protected function getMockForMethods($className, $methods): mixed {
+        $mockBuilder = $this->getMockBuilder($className);
+
+        $classMethods = get_class_methods($className);
+        $methodsToMock = array_diff($classMethods, $methods);
+        $mockBuilder->onlyMethods($methodsToMock);
+
+        return $mockBuilder->getMock();
+    }
+}

+ 2 - 2
ot_core/Tests/Unit/Service/OpentalentApiServiceTest.php

@@ -10,9 +10,9 @@ use Opentalent\OtCore\Tests\Unit\Fixtures\ApiResponseFixtures;
 use Prophecy\Argument;
 use Prophecy\PhpUnit\ProphecyTrait;
 use TYPO3\CMS\Core\Core\ApplicationContext;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
-class OpentalentApiServiceTest extends UnitTestCase
+class OpentalentApiServiceTest extends OtUnitTestCase
 {
     use ProphecyTrait;
 

+ 2 - 2
ot_core/Tests/Unit/Service/OpentalentEnvServiceTest.php

@@ -3,9 +3,9 @@
 namespace Opentalent\OtCore\Tests\Unit\Service;
 
 use Opentalent\OtCore\Service\OpentalentEnvService;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
-class OpentalentEnvServiceTest extends UnitTestCase
+class OpentalentEnvServiceTest extends OtUnitTestCase
 {
     /**
      * get should return the requested variable default value,

+ 2 - 2
ot_core/Tests/Unit/Website/OtPageRepositoryTest.php

@@ -9,10 +9,10 @@ use Opentalent\OtCore\Tests\Unit\QueryBuilderProphet;
 use Prophecy\PhpUnit\ProphecyTrait;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Domain\Repository\PageRepository;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
 
-class OtPageRepositoryTest extends UnitTestCase
+class OtPageRepositoryTest extends OtUnitTestCase
 {
     use ProphecyTrait;
 

+ 2 - 2
ot_core/Tests/Unit/Website/OtWebsiteRepositoryTest.php

@@ -12,9 +12,9 @@ use Opentalent\OtCore\Tests\Unit\QueryBuilderProphet;
 use Opentalent\OtCore\Website\OtWebsiteRepository;
 use Prophecy\PhpUnit\ProphecyTrait;
 use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+use Opentalent\OtCore\Tests\Unit\OtUnitTestCase;
 
-class OtWebsiteRepositoryTest extends UnitTestCase
+class OtWebsiteRepositoryTest extends OtUnitTestCase
 {
     use ProphecyTrait;
 

Some files were not shown because too many files changed in this diff