mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-10 04:56:12 +01:00

[TASK] Switch to the core testing framework (#361)

The TYPO3 core testing framework has more person-power for maintenance
behind it compared to the nimut testing framework. So we should use that.
This commit is contained in:
Oliver Klee 2022-02-20 15:18:46 +01:00 committed by GitHub
parent 05a7e61208
commit 4f2c813d7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 39 deletions

View file

@ -29,27 +29,6 @@ namespace PHPSTORM_META {
) )
); );
// Nimut testing framework
// The accesible mock will be of type `self` as well as `MockObject` and `AccessibleMockObjectInterface`.
override(
\Nimut\TestingFramework\TestCase\AbstractTestCase::getAccessibleMock(0),
map(
[
'' => '@|\\PHPUnit\\Framework\\MockObject\\MockObject'
. '|\\Nimut\\TestingFramework\\MockObject\\AccessibleMockObjectInterface',
]
)
);
override(
\Nimut\TestingFramework\TestCase\AbstractTestCase::getAccessibleMockForAbstractClass(0),
map(
[
'' => '@|\\PHPUnit\\Framework\\MockObject\\MockObject'
. '|\\Nimut\TestingFramework\\MockObject\\AccessibleMockObjectInterface',
]
)
);
// Contexts // Contexts
// @see https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/9.4/Feature-85389-ContextAPIForConsistentDataHandling.html // @see https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/9.4/Feature-85389-ContextAPIForConsistentDataHandling.html
expectedArguments( expectedArguments(

View file

@ -181,7 +181,7 @@ settings so this configuration can serve as a template:
- Directory: use the `Tests/Unit` directory in your project - Directory: use the `Tests/Unit` directory in your project
- (*) Use alternative configuration file - (*) Use alternative configuration file
- use `.Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml` - use `.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml`
in your project folder in your project folder
- add the following environment variables: - add the following environment variables:
- typo3DatabaseUsername - typo3DatabaseUsername
@ -204,7 +204,7 @@ settings:
- Directory: use the `Tests/Functional` directory in your project - Directory: use the `Tests/Functional` directory in your project
- (*) Use alternative configuration file - (*) Use alternative configuration file
- use - use
`.Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml` `.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml`
## Running the acceptance tests ## Running the acceptance tests

View file

@ -4,13 +4,13 @@ declare(strict_types=1);
namespace TTN\Tea\Tests\Functional\Domain\Repository\Product; namespace TTN\Tea\Tests\Functional\Domain\Repository\Product;
use Nimut\TestingFramework\TestCase\FunctionalTestCase;
use TTN\Tea\Domain\Model\Product\Tea; use TTN\Tea\Domain\Model\Product\Tea;
use TTN\Tea\Domain\Repository\Product\TeaRepository; use TTN\Tea\Domain\Repository\Product\TeaRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/** /**
* @covers \TTN\Tea\Domain\Repository\Product\TeaRepository * @covers \TTN\Tea\Domain\Repository\Product\TeaRepository
@ -18,7 +18,7 @@ use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
class TeaRepositoryTest extends FunctionalTestCase class TeaRepositoryTest extends FunctionalTestCase
{ {
/** /**
* @var string[] * @var array<int, string>
*/ */
protected $testExtensionsToLoad = ['typo3conf/ext/tea']; protected $testExtensionsToLoad = ['typo3conf/ext/tea'];
@ -122,11 +122,11 @@ class TeaRepositoryTest extends FunctionalTestCase
$this->subject->add($model); $this->subject->add($model);
$this->persistenceManager->persistAll(); $this->persistenceManager->persistAll();
$databaseRow = $this->getDatabaseConnection()->selectSingleRow( $connection = $this->getConnectionPool()
'*', ->getConnectionForTable('tx_tea_domain_model_product_tea');
'tx_tea_domain_model_product_tea', $databaseRow = $connection->select(['*'], 'tx_tea_domain_model_product_tea', ['uid' => $model->getUid()])
'uid = ' . $model->getUid() ->fetchAssociative();
);
self::assertSame($title, $databaseRow['title']); self::assertSame($title, $databaseRow['title']);
} }
} }

View file

@ -4,7 +4,6 @@ declare(strict_types=1);
namespace TTN\Tea\Tests\Unit\Controller; namespace TTN\Tea\Tests\Unit\Controller;
use Nimut\TestingFramework\TestCase\UnitTestCase;
use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophecy\ObjectProphecy;
use Prophecy\Prophecy\ProphecySubjectInterface; use Prophecy\Prophecy\ProphecySubjectInterface;
use TTN\Tea\Controller\TeaController; use TTN\Tea\Controller\TeaController;
@ -13,6 +12,7 @@ use TTN\Tea\Domain\Repository\Product\TeaRepository;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Fluid\View\TemplateView; use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/** /**
* @covers \TTN\Tea\Controller\TeaController * @covers \TTN\Tea\Controller\TeaController
@ -36,11 +36,14 @@ class TeaControllerTest extends UnitTestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->subject = new TeaController(); parent::setUp();
// We need to create an accessible mock in order to be able to set the protected `view`.
$this->subject = $this->getAccessibleMock(TeaController::class, ['redirect', 'forward']);
$this->viewProphecy = $this->prophesize(TemplateView::class); $this->viewProphecy = $this->prophesize(TemplateView::class);
$view = $this->viewProphecy->reveal(); $view = $this->viewProphecy->reveal();
$this->inject($this->subject, 'view', $view); $this->subject->_set('view', $view);
$this->teaRepositoryProphecy = $this->prophesize(TeaRepository::class); $this->teaRepositoryProphecy = $this->prophesize(TeaRepository::class);
/** @var TeaRepository&ProphecySubjectInterface $teaRepository */ /** @var TeaRepository&ProphecySubjectInterface $teaRepository */

View file

@ -4,10 +4,10 @@ declare(strict_types=1);
namespace TTN\Tea\Tests\Unit\Domain\Model\Product; namespace TTN\Tea\Tests\Unit\Domain\Model\Product;
use Nimut\TestingFramework\TestCase\UnitTestCase;
use TTN\Tea\Domain\Model\Product\Tea; use TTN\Tea\Domain\Model\Product\Tea;
use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/** /**
* @covers \TTN\Tea\Domain\Model\Product\Tea * @covers \TTN\Tea\Domain\Model\Product\Tea
@ -21,6 +21,8 @@ class TeaTest extends UnitTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$this->subject = new Tea(); $this->subject = new Tea();
} }

View file

@ -4,10 +4,10 @@ declare(strict_types=1);
namespace TTN\Tea\Tests\Unit\Domain\Repository\Product; namespace TTN\Tea\Tests\Unit\Domain\Repository\Product;
use Nimut\TestingFramework\TestCase\UnitTestCase;
use TTN\Tea\Domain\Repository\Product\TeaRepository; use TTN\Tea\Domain\Repository\Product\TeaRepository;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/** /**
* @covers \TTN\Tea\Domain\Repository\Product\TeaRepository * @covers \TTN\Tea\Domain\Repository\Product\TeaRepository
@ -26,6 +26,8 @@ class TeaRepositoryTest extends UnitTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$this->objectManager = $this->prophesize(ObjectManagerInterface::class)->reveal(); $this->objectManager = $this->prophesize(ObjectManagerInterface::class)->reveal();
$this->subject = new TeaRepository($this->objectManager); $this->subject = new TeaRepository($this->objectManager);
} }

View file

@ -33,11 +33,11 @@
}, },
"require-dev": { "require-dev": {
"codeception/codeception": "^4.1.27", "codeception/codeception": "^4.1.27",
"doctrine/dbal": "^2.13.5",
"ergebnis/composer-normalize": "^2.18.0", "ergebnis/composer-normalize": "^2.18.0",
"friendsofphp/php-cs-fixer": "^3.4.0", "friendsofphp/php-cs-fixer": "^3.4.0",
"helmich/typo3-typoscript-lint": "^2.5.2", "helmich/typo3-typoscript-lint": "^2.5.2",
"jangregor/phpstan-prophecy": "^1.0.0", "jangregor/phpstan-prophecy": "^1.0.0",
"nimut/testing-framework": "^6.0.0",
"phpstan/extension-installer": "^1.1.0", "phpstan/extension-installer": "^1.1.0",
"phpstan/phpstan": "^1.2.0", "phpstan/phpstan": "^1.2.0",
"phpstan/phpstan-phpunit": "^1.0.0", "phpstan/phpstan-phpunit": "^1.0.0",
@ -47,7 +47,8 @@
"squizlabs/php_codesniffer": "^3.6.2", "squizlabs/php_codesniffer": "^3.6.2",
"symfony/yaml": "^4.4.29 || ^5.3.6 || ^6.0", "symfony/yaml": "^4.4.29 || ^5.3.6 || ^6.0",
"typo3/cms-fluid-styled-content": "^10.4 || ^11.5.2", "typo3/cms-fluid-styled-content": "^10.4 || ^11.5.2",
"typo3/coding-standards": "^0.5.0" "typo3/coding-standards": "^0.5.0",
"typo3/testing-framework": "^6.15.3"
}, },
"replace": { "replace": {
"typo3-ter/tea": "self.version" "typo3-ter/tea": "self.version"
@ -137,8 +138,8 @@
"@ci:tests:unit", "@ci:tests:unit",
"@ci:tests:functional" "@ci:tests:functional"
], ],
"ci:tests:functional": "find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running functional test suite {}\"; .Build/vendor/bin/phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml {}';", "ci:tests:functional": "find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running functional test suite {}\"; .Build/vendor/bin/phpunit -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml {}';",
"ci:tests:unit": ".Build/vendor/bin/phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml Tests/Unit", "ci:tests:unit": ".Build/vendor/bin/phpunit -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit",
"ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript", "ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript",
"ci:yaml:lint": "find . ! -path '*.Build/*' ! -path '*Resources/Private/node_modules/*' -name '*.yml' | xargs -r php ./.Build/vendor/bin/yaml-lint", "ci:yaml:lint": "find . ! -path '*.Build/*' ! -path '*Resources/Private/node_modules/*' -name '*.yml' | xargs -r php ./.Build/vendor/bin/yaml-lint",
"docs:generate": [ "docs:generate": [