2017 © Pedro Peláez
 

library testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

image

nimut/testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  • Friday, June 22, 2018
  • by helhum
  • Repository
  • 6 Watchers
  • 29 Stars
  • 97,886 Installations
  • PHP
  • 153 Dependents
  • 0 Suggesters
  • 10 Forks
  • 5 Open issues
  • 44 Versions
  • 23 % Grown

The README.md

Testing Framework for TYPO3 CMS Extensions

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:, (*1)

ℹ️ Show docs for TYPO3 9.5 up to 11.5
, (*2)

Latest Stable Version Build Status StyleCI, (*3)

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., (*4)

Installation

Use Composer to install the testing framework., (*5)

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., (*6)

Usage

Unit Tests

Inherit your test class from \Nimut\TestingFramework\TestCase\UnitTestCase., (*7)

To execute the unit tests of your extension run, (*8)

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., (*9)

You should setup your subject class in your setUp() method of the test class:, (*10)

/**
 * @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., (*11)

To execute the functional tests of your extension run, (*12)

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., (*13)

"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., (*14)

In your FunctionalTestCase call $this->getDatabaseConnection() to get an instance of \Nimut\TestingFramework\Database\DatabaseInterface., (*15)

Following database functions are built in the nimut/testing-framework database interface:, (*16)

  • 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)., (*17)

Database fixtures

The nimut/testing-framework ships database fixtures for several TYPO3 CMS core database tables:, (*18)

  • 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, (*19)

$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., (*20)

// 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., (*21)

[
    // 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., (*22)

// 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, (*23)

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, (*24)

Last but not least you may ask for further support in the Slack channel "#cig-testing"., (*25)

, (*26)

The Versions

22/06 2018

dev-master

9999999-dev https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+ GPL-2.0-or-later

The Requires

 

The Development Requires

phpunit testing typo3 cms

22/06 2018

dev-pre-merge

dev-pre-merge https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+ GPL-2.0-or-later

The Requires

 

The Development Requires

phpunit testing typo3 cms

22/06 2018
14/03 2018

3.0.5

3.0.5.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

phpunit testing typo3 cms

09/03 2018

3.0.4

3.0.4.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

phpunit testing typo3 cms

09/03 2018

dev-fix-database-name-case

dev-fix-database-name-case https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

phpunit testing typo3 cms

28/02 2018

2.x-dev

2.9999999.9999999.9999999-dev https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+ GPL-2.0-or-later

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

28/02 2018

2.0.3

2.0.3.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

28/02 2018

3.0.3

3.0.3.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

phpunit testing typo3 cms

23/02 2018

dev-allow-db-override

dev-allow-db-override https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

phpunit testing typo3 cms

02/02 2018

3.0.2

3.0.2.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

phpunit testing typo3 cms

30/01 2018

3.0.1

3.0.1.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

phpunit testing typo3 cms

13/01 2018

3.0.0

3.0.0.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

17/12 2017

dev-travis-ci-enhancements

dev-travis-ci-enhancements https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

14/12 2017

2.0.2

2.0.2.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

15/11 2017

2.0.1

2.0.1.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

03/09 2017

dev-check-database-import

dev-check-database-import https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

03/09 2017

2.0.0

2.0.0.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

02/09 2017

1.x-dev

1.9999999.9999999.9999999-dev https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

30/08 2017

1.1.9

1.1.9.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

09/08 2017

dev-raise-phpunit

dev-raise-phpunit https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

09/08 2017

dev-namespace-change

dev-namespace-change https://github.com/IchHabRecht/testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • ichhaberecht/testing-framework-testbase @dev

phpunit testing typo3 cms

24/05 2017

1.1.8

1.1.8.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

14/05 2017

1.1.7

1.1.7.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

13/05 2017

1.1.6

1.1.6.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

19/04 2017

1.1.5

1.1.5.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

30/03 2017

1.1.4

1.1.4.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

12/03 2017

1.1.3

1.1.3.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

  • nimut/testing-framework-testbase @dev

phpunit testing typo3 cms

05/03 2017

1.1.2

1.1.2.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

03/03 2017

1.1.1

1.1.1.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

03/03 2017

1.1.0

1.1.0.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

24/02 2017

1.0.1

1.0.1.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

23/02 2017

1.0.0

1.0.0.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

23/02 2017

0.4.1

0.4.1.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

23/02 2017

0.4.0

0.4.0.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

22/02 2017

0.3.1

0.3.1.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

22/02 2017

0.3.0

0.3.0.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

21/02 2017

0.2.1

0.2.1.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

20/02 2017

0.2.0

0.2.0.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

16/02 2017

0.1.1

0.1.1.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms

16/02 2017

0.1.0

0.1.0.0 https://github.com/Nimut/TYPO3-testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

phpunit testing typo3 cms