DEPRECATION WARNING

This documentation is not using the current rendering mechanism and will be deleted by December 31st, 2020. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

Unit testsΒΆ

When creating unit tests for your extension, you might need to create configuration objects. You will need to initialize Configuration Object services to make the extension work with tests.

First, use the trait ConfigurationObjectUnitTestUtility in your test class, then call the function initializeConfigurationObjectTestServices() in the function setUp().

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use TYPO3\CMS\Core\Tests\UnitTestCase;
use Romm\ConfigurationObject\Tests\Unit\ConfigurationObjectUnitTestUtility;

class MyTest extends UnitTestCase
{

    use ConfigurationObjectUnitTestUtility;

    protected function setUp()
    {
        $this->initializeConfigurationObjectTestServices();
    }

    /**
     * @test
     */
    public function myTest()
    {
        $configurationArray = ['...'];

        ConfigurationObjectFactory::getInstance()
                ->get(MyObject::class, $configurationArray);
    }
}