Issue Bug Closed

#63943PHPUnit-Tests fail on Windows

Stephan Großberndt 12/16/14, 23:31 updated 10/02/18, 11:48

Description

Executing the PHPUnit-Tests on Windows is not possible currently:

Fatal error: Cannot redeclare class TYPO3\CMS\Extbase\Tests\Unit\DomainObject\DomainObject_5490aef9162dd in D:\typo3\master\typo3\sysext\extbase\Tests\Unit\DomainObject\AbstractEntityTest.php(89) : eval()'d code on line 4

This is due to

        $domainObjectName = uniqid('DomainObject_');
        $domainObjectNameWithNS = __NAMESPACE__ . '\\' . $domainObjectName;
        eval('namespace ' . __NAMESPACE__ . '; class ' . $domainObjectName . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
            public $foo;
            public $bar;
        }');
        $secondDomainObjectName = uniqid('DomainObject_');
        $secondDomainObjectNameWithNS = __NAMESPACE__ . '\\' . $secondDomainObjectName;
        eval('namespace ' . __NAMESPACE__ . '; class ' . $secondDomainObjectName . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
            public $foo;
            public $bar;
        }');

On windows the calls

        $domainObjectName = uniqid('DomainObject_');
        $secondDomainObjectName = uniqid('DomainObject_');

return the same id, which is related to #59701, #58602 and #59055.

Using

        $domainObjectName = 'DomainObject_' . md5(uniqid(microtime(), true));

solves the issue.

Reviews 2