{"id":15103786,"url":"https://github.com/nimut/testing-framework","last_synced_at":"2025-09-27T02:32:08.578Z","repository":{"id":17446397,"uuid":"81999184","full_name":"Nimut/testing-framework","owner":"Nimut","description":"TYPO3 testing framework that provides base classes and configuration for PHPUnit tests","archived":true,"fork":false,"pushed_at":"2023-06-30T10:33:47.000Z","size":522,"stargazers_count":52,"open_issues_count":16,"forks_count":25,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-03T14:17:58.535Z","etag":null,"topics":["phpunit","testing","typo3","typo3-cms"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nimut.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-14T23:24:08.000Z","updated_at":"2024-02-12T12:14:35.000Z","dependencies_parsed_at":"2024-06-18T12:27:22.817Z","dependency_job_id":null,"html_url":"https://github.com/Nimut/testing-framework","commit_stats":{"total_commits":322,"total_committers":9,"mean_commits":35.77777777777778,"dds":0.0714285714285714,"last_synced_commit":"afd07e9fd82fb923a76e67579ba81bee9f4f95fb"},"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"purl":"pkg:github/Nimut/testing-framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nimut%2Ftesting-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nimut%2Ftesting-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nimut%2Ftesting-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nimut%2Ftesting-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nimut","download_url":"https://codeload.github.com/Nimut/testing-framework/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nimut%2Ftesting-framework/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277171572,"owners_count":25773245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-27T02:00:08.978Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["phpunit","testing","typo3","typo3-cms"],"created_at":"2024-09-25T19:42:08.347Z","updated_at":"2025-09-27T02:32:08.572Z","avatar_url":"https://github.com/Nimut.png","language":"PHP","readme":"# Testing Framework for TYPO3 CMS Extensions\n\nThere are no plans to support nimut/testing-framework for versions above TYPO3 v11. You are advised to switch to the\ntypo3/testing-framework for TYPO3 v12 and above. The  typo3/testing-framework has improved support for testing more\nthan one version of the core. Further information and an introduction can be found in the official TYPO3 documentation:\n\n* [Testing Extensions](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Testing/ExtensionTesting.html)\n\n\u003cdetails\u003e\n\u003csummary\u003eℹ️ Show docs for TYPO3 9.5 up to 11.5\u003c/summary\u003e\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/nimut/testing-framework.svg)](https://packagist.org/packages/nimut/testing-framework)\n[![Build Status](https://img.shields.io/travis/Nimut/testing-framework/master.svg)](https://travis-ci.org/Nimut/testing-framework)\n[![StyleCI](https://styleci.io/repos/81999184/shield?branch=master)](https://styleci.io/repos/81999184)\n\nThe aim of the testing framework is to provide a good way to write and run unit and functional tests for multiple versions\nof the TYPO3 CMS. Currently **TYPO3 CMS 9.5 up to 11.5** are tested and supported.\n\n## Installation\n\nUse [Composer](https://getcomposer.org/) to install the testing framework.\n\n```bash\ncomposer require --dev nimut/testing-framework\n```\n\nComposer will add the package as a dev requirement to your composer.json and install PHPUnit and vfsStream as its\ndependencies.\n\n## Usage\n\n### Unit Tests\n\nInherit your test class from `\\Nimut\\TestingFramework\\TestCase\\UnitTestCase`.\n\nTo execute the unit tests of your extension run\n\n```bash\nvendor/bin/phpunit -c vendor/nimut/testing-framework/res/Configuration/UnitTests.xml \\\n    typo3conf/ext/example_extension/Tests/Unit\n```\n\n#### ViewHelper\n\nFor an easy way to test your Fluid ViewHelper you can inherit the test class from `\\Nimut\\TestingFramework\\TestCase\\ViewHelperBaseTestcase`.\n\nYou should setup your subject class in your setUp() method of the test class: \n\n```php\n/**\n * @var \\PHPUnit_Framework_MockObject_MockObject\n */\nprotected $viewHelper;\n\nprotected function setUp()\n{\n    parent::setUp();\n    $this-\u003eviewHelper = $this-\u003egetMockBuilder(RenderChildrenViewHelper::class)-\u003esetMethods(['renderChildren'])-\u003egetMock();\n    $this-\u003einjectDependenciesIntoViewHelper($this-\u003eviewHelper);\n    $this-\u003eviewHelper-\u003einitializeArguments();\n}\n```\n\n### Functional Tests\n\nInherit your test class from `\\Nimut\\TestingFramework\\TestCase\\FunctionalTestCase`.\n\nTo execute the functional tests of your extension run\n\n```bash\nvendor/bin/phpunit -c vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml \\\n    typo3conf/ext/example_extension/Tests/Functional\n```\n\n### Extension preparation\n\nYou can add a script section to your `composer.json` file to symlink your extension to the proper root-dir/web-dir.\n\n```json\n\"scripts\": {\n    \"post-autoload-dump\": [\n        \"@prepare-extension-test-structure\"\n    ],\n    \"prepare-extension-test-structure\": [\n        \"Nimut\\\\TestingFramework\\\\Composer\\\\ExtensionTestEnvironment::prepare\"\n    ]\n}\n```\n\n### Database abstraction\n\nTo be able to test against TYPO3 CMS 8 and later, nimut/testing-framework provides an own database abstraction layer.\n\nIn your FunctionalTestCase call `$this-\u003egetDatabaseConnection()` to get an instance of \n`\\Nimut\\TestingFramework\\Database\\DatabaseInterface`.\n\nFollowing database functions are built in the nimut/testing-framework database interface:\n\n- select\n- selectSingleRow\n- selectCount\n- insertArray\n- lastInsertId\n- updateArray\n- delete\n- getDatabaseInstance\n\nIf you need own database requests you can get the proper database instance of the current TYPO3 version by using\n`$this-\u003egetDatabaseConnection()-\u003egetDatabaseInstance()`. You have to check weather this instance is a\n`\\TYPO3\\CMS\\Core\\Database\\Query\\QueryBuilder` (TYPO3 CMS 8 and above) or an instance of \n`\\TYPO3\\CMS\\Core\\Database\\DatabaseConnection` (TYPO3 CMS 7).\n\n#### Database fixtures\n\nThe nimut/testing-framework ships database fixtures for several TYPO3 CMS core database tables:\n\n- pages\n- pages_language_overlay\n- sys_file_storage\n- sys_language\n- tt_content\n\nTo use the database fixtures you can trigger an import in your test file\n\n```php\n$this-\u003eimportDataSet('ntf://Database/pages.xml');\n```\n\n### Frontend requests\n\nThe nimut/testing-framework ships an own TypoScript file for supporting frontend requests out of the box.\n\n```php\n// First import some page records\n$this-\u003eimportDataSet('ntf://Database/pages.xml');\n\n// Import tt_content record that should be shown on your home page\n$this-\u003eimportDataSet('ntf://Database/tt_content.xml');\n\n// Setup the page with uid 1 and include the TypoScript as sys_template record\n$this-\u003esetUpFrontendRootPage(1, array('ntf://TypoScript/JsonRenderer.ts'));\n\n// Fetch the frontend response\n$response = $this-\u003egetFrontendResponse(1);\n\n// Assert no error has occured\n$this-\u003eassertSame('success', $response-\u003egetStatus());\n\n// Get the first section from the response\n$sections = $response-\u003egetResponseSections();\n$defaultSection = array_shift($sections);\n\n// Get the section structure\n$structure = $defaultSection-\u003egetStructure();\n\n// Make assertions for the structure\n$this-\u003eassertTrue(is_array($structure['pages:1']['__contents']['tt_content:1']));\n```\n\n#### Structure\n\nThe returned structure of a frontend request is an array with some information about your page and its children.\n\n```php\n[\n    // Page for your request\n    'pages:1' =\u003e [\n        'uid' =\u003e '1',\n        'pid' =\u003e '0',\n        'sorting' =\u003e '0',\n        'title' =\u003e 'Root',\n        // Array with subpages\n        '__pages' =\u003e [\n            'pages:2' =\u003e [\n                'uid' =\u003e '2',\n                'pid' =\u003e '1',\n                'sorting' =\u003e '0',\n                'title' =\u003e 'Dummy 1-2',\n            ],\n            'pages:5' =\u003e [\n                'uid' =\u003e '5',\n                'pid' =\u003e '1',\n                'sorting' =\u003e '0',\n                'title' =\u003e 'Dummy 1-5',\n            ],\n        ],\n        // Array with content elements\n        '__contents' =\u003e [\n              'tt_content:1' =\u003e [\n                  'uid' =\u003e '1',\n                  'pid' =\u003e '1',\n                  'sorting' =\u003e '0',\n                  'header' =\u003e 'Test content',\n                  'sys_language_uid' =\u003e '0',\n                  'categories' =\u003e '0',\n              ],\n        ],\n    ],\n]\n```\n\nIf you need additional information about a record, you can provide additional TypoScript with the needed configuration.\n\n```php\n// Setup the page with uid 1 and include ntf and own TypoScript\n$this-\u003esetUpFrontendRootPage(\n    1,\n    array(\n        'ntf://TypoScript/JsonRenderer.ts',\n        'EXT:example_extension/Tests/Functional/Fixtures/TypoScript/Config.ts'\n    )\n);\n```\n\nContent of the TypoScript file *Config.ts*\n\n```\nconfig.watcher.tableFields.tt_content = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,header,categories,CType,subheader,bodytext\n```\n## Additional information\n\nFollowing links provide documentation and additional information about TYPO3 CMS extension testing\n\n- [Unit tests for dummies](https://de.slideshare.net/cpsitgmbh/unit-tests-for-dummies)\n- [How to write functional test](https://wiki.typo3.org/Functional_testing#How_to_write_functional_test.3F)\n- [Functional tests with TYPO3](https://de.slideshare.net/cpsitgmbh/functional-tests-with-typo3)\n- [Functional tests for dummies](https://de.slideshare.net/cpsitgmbh/functional-tests-for-dummies-65673214)\n\nLast but not least you may ask for further support in the Slack channel \"[#cig-testing](https://typo3.slack.com/messages/cig-testing)\".\n\n\u003c/details\u003e","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnimut%2Ftesting-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnimut%2Ftesting-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnimut%2Ftesting-framework/lists"}