Problem/Motivation

Setting error reporting level to E_ALL & ~E_NOTICE causes ThemeHandlerTest to fail.

$ php ./vendor/phpunit/phpunit/phpunit.php --filter ThemeHandlerTest
PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from /vagrant/repos/d8/core/phpunit.xml.dist

.EE.....

Time: 48 seconds, Memory: 36.00Mb

There were 2 errors:

1) Drupal\Tests\Core\Extension\ThemeHandlerTest::testEnableSingleTheme
Invalid argument supplied for foreach()

/vagrant/repos/d8/core/lib/Drupal/Core/Extension/ThemeHandler.php:204
/vagrant/repos/d8/core/lib/Drupal/Core/Extension/ThemeHandler.php:238
/vagrant/repos/d8/core/lib/Drupal/Core/Extension/ThemeHandler.php:148
/vagrant/repos/d8/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php:167

2) Drupal\Tests\Core\Extension\ThemeHandlerTest::testEnableAndListInfo
Invalid argument supplied for foreach()

/vagrant/repos/d8/core/lib/Drupal/Core/Extension/ThemeHandler.php:204
/vagrant/repos/d8/core/lib/Drupal/Core/Extension/ThemeHandler.php:238
/vagrant/repos/d8/core/lib/Drupal/Core/Extension/ThemeHandler.php:148
/vagrant/repos/d8/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php:193

Proposed resolution

$this->systemList is not set in TestThemeHandler::systemThemeList() but an exception is not thrown with error reporting set to E_ALL & ~E_NOTICE - This means $themes is set to NULL, but should be an array.

With error reporting set to E_ALL, an exception is thrown and then caught in \Drupal\Core\Extension\ThemeHandler::listInfo() which then rebuilds the theme data.

Remaining tasks

Fix ThemeHandlerTest so that it works correctly with error reporting set to E_ALL & ~E_NOTICE

Comments

davidgrayston’s picture

Issue tags: +LSDHACK
dawehner’s picture

I would consider it as a feature that the test fails without notices. Note: You as a developer and you as a testing system wants to ensure that you actually catch notices.

But yeah maybe you are right, though I don't really know how to chance those.

sun’s picture

Status: Active » Closed (cannot reproduce)

phpunit.xml.dist is explicitly configured to set error reporting to E_ALL, so this works as designed.

However, it's possible that I misunderstood the purpose of this issue (due to the issue summary focusing on error reporting). If that is the case, feel free to re-open this issue, but when doing so, please rewrite the issue summary to focus on the functional bug (if any) instead of error reporting.