nimut/testing-framework
最新稳定版本:6.0.1
Composer 安装命令:
composer require --dev nimut/testing-framework
包简介
TYPO3 testing framework that provides base classes and configuration for PHPUnit tests
关键字:
README 文档
README
There are no plans to support nimut/testing-framework for versions above TYPO3 v11. You are advised to switch to the typo3/testing-framework for TYPO3 v12 and above. The typo3/testing-framework has improved support for testing more than one version of the core. Further information and an introduction can be found in the official TYPO3 documentation:
ℹ️ Show docs for TYPO3 9.5 up to 11.5
The aim of the testing framework is to provide a good way to write and run unit and functional tests for multiple versions of the TYPO3 CMS. Currently TYPO3 CMS 9.5 up to 11.5 are tested and supported.
Installation
Use Composer to install the testing framework.
composer require --dev nimut/testing-framework
Composer will add the package as a dev requirement to your composer.json and install PHPUnit and vfsStream as its dependencies.
Usage
Unit Tests
Inherit your test class from \Nimut\TestingFramework\TestCase\UnitTestCase.
To execute the unit tests of your extension run
vendor/bin/phpunit -c vendor/nimut/testing-framework/res/Configuration/UnitTests.xml \ typo3conf/ext/example_extension/Tests/Unit
ViewHelper
For an easy way to test your Fluid ViewHelper you can inherit the test class from \Nimut\TestingFramework\TestCase\ViewHelperBaseTestcase.
You should setup your subject class in your setUp() method of the test class:
/** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $viewHelper; protected function setUp() { parent::setUp(); $this->viewHelper = $this->getMockBuilder(RenderChildrenViewHelper::class)->setMethods(['renderChildren'])->getMock(); $this->injectDependenciesIntoViewHelper($this->viewHelper); $this->viewHelper->initializeArguments(); }
Functional Tests
Inherit your test class from \Nimut\TestingFramework\TestCase\FunctionalTestCase.
To execute the functional tests of your extension run
vendor/bin/phpunit -c vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml \ typo3conf/ext/example_extension/Tests/Functional
Extension preparation
You can add a script section to your composer.json file to symlink your extension to the proper root-dir/web-dir.
"scripts": { "post-autoload-dump": [ "@prepare-extension-test-structure" ], "prepare-extension-test-structure": [ "Nimut\\TestingFramework\\Composer\\ExtensionTestEnvironment::prepare" ] }
Database abstraction
To be able to test against TYPO3 CMS 8 and later, nimut/testing-framework provides an own database abstraction layer.
In your FunctionalTestCase call $this->getDatabaseConnection() to get an instance of \Nimut\TestingFramework\Database\DatabaseInterface.
Following database functions are built in the nimut/testing-framework database interface:
- select
- selectSingleRow
- selectCount
- insertArray
- lastInsertId
- updateArray
- delete
- getDatabaseInstance
If you need own database requests you can get the proper database instance of the current TYPO3 version by using $this->getDatabaseConnection()->getDatabaseInstance(). You have to check weather this instance is a \TYPO3\CMS\Core\Database\Query\QueryBuilder (TYPO3 CMS 8 and above) or an instance of \TYPO3\CMS\Core\Database\DatabaseConnection (TYPO3 CMS 7).
Database fixtures
The nimut/testing-framework ships database fixtures for several TYPO3 CMS core database tables:
- pages
- pages_language_overlay
- sys_file_storage
- sys_language
- tt_content
To use the database fixtures you can trigger an import in your test file
$this->importDataSet('ntf://Database/pages.xml');
Frontend requests
The nimut/testing-framework ships an own TypoScript file for supporting frontend requests out of the box.
// First import some page records $this->importDataSet('ntf://Database/pages.xml'); // Import tt_content record that should be shown on your home page $this->importDataSet('ntf://Database/tt_content.xml'); // Setup the page with uid 1 and include the TypoScript as sys_template record $this->setUpFrontendRootPage(1, array('ntf://TypoScript/JsonRenderer.ts')); // Fetch the frontend response $response = $this->getFrontendResponse(1); // Assert no error has occured $this->assertSame('success', $response->getStatus()); // Get the first section from the response $sections = $response->getResponseSections(); $defaultSection = array_shift($sections); // Get the section structure $structure = $defaultSection->getStructure(); // Make assertions for the structure $this->assertTrue(is_array($structure['pages:1']['__contents']['tt_content:1']));
Structure
The returned structure of a frontend request is an array with some information about your page and its children.
[ // Page for your request 'pages:1' => [ 'uid' => '1', 'pid' => '0', 'sorting' => '0', 'title' => 'Root', // Array with subpages '__pages' => [ 'pages:2' => [ 'uid' => '2', 'pid' => '1', 'sorting' => '0', 'title' => 'Dummy 1-2', ], 'pages:5' => [ 'uid' => '5', 'pid' => '1', 'sorting' => '0', 'title' => 'Dummy 1-5', ], ], // Array with content elements '__contents' => [ 'tt_content:1' => [ 'uid' => '1', 'pid' => '1', 'sorting' => '0', 'header' => 'Test content', 'sys_language_uid' => '0', 'categories' => '0', ], ], ], ]
If you need additional information about a record, you can provide additional TypoScript with the needed configuration.
// Setup the page with uid 1 and include ntf and own TypoScript $this->setUpFrontendRootPage( 1, array( 'ntf://TypoScript/JsonRenderer.ts', 'EXT:example_extension/Tests/Functional/Fixtures/TypoScript/Config.ts' ) );
Content of the TypoScript file Config.ts
config.watcher.tableFields.tt_content = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,header,categories,CType,subheader,bodytext Additional information
Following links provide documentation and additional information about TYPO3 CMS extension testing
- Unit tests for dummies
- How to write functional test
- Functional tests with TYPO3
- Functional tests for dummies
Last but not least you may ask for further support in the Slack channel "#cig-testing".
nimut/testing-framework 适用场景与选型建议
nimut/testing-framework 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.36M 次下载、GitHub Stars 达 53, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「testing」 「phpunit」 「TYPO3 CMS」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nimut/testing-framework 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nimut/testing-framework 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nimut/testing-framework 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HiDev plugin for PHPUnit
Testing Suite For Lumen like Laravel does.
A cli tool which generates unit tests.
Set Links with a specific language parameter
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
The PHP SDK for Checkmango
统计信息
- 总下载量: 1.36M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 55
- 点击次数: 13
- 依赖项目数: 188
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-01-04