1

I want to test a custom module, which uses configuration entities, as described in Creating a configuration entity type in Drupal 8. The configuration is during installation of the module populated by multiple entities, as described in this answer.

The module works fine, but when I want to test it, then I receive three (error) messages during installation of the module:

public static $modules = array('example');

If I delete all the yaml files in the directory config/install/, then the test runs through.


The messages:

  1. Warning:

Invalid argument supplied for foreach() in _batch_finished() (line 405 of /www/sites/mysite.dev/htdocs/core/includes/batch.inc) #0 /www/sites/mysite.dev/htdocs/core/includes/bootstrap.inc(552): _drupal_error_handler_real(2, 'Invalid argumen...', '/www/sites/hand...', 405, Array) #1 /www/sites/mysite.dev/htdocs/core/includes/batch.inc(405): _drupal_error_handler(2, 'Invalid argumen...', '/www/sites/hand...', 405, Array) #2 /www/sites/mysite.dev/htdocs/core/includes/batch.inc(333): _batch_finished() #3 /www/sites/mysite.dev/htdocs/core/includes/batch.inc(95): _batch_process() #4 /www/sites/mysite.dev/htdocs/core/includes/batch.inc(77): _batch_do() #5 /www/sites/mysite.dev/htdocs/core/modules/system/src/Controller/BatchController.php(55): _batch_page(Object(Symfony\Component\HttpFoundation\Request)) #6 [internal function]: Drupal\system\Controller\BatchController->batchPage(Object(Symfony\Component\HttpFoundation\Request)) #7 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #8 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() #9 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #10 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #11 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() #12 /www/sites/mysite.dev/vendor/symfony/http-kernel/HttpKernel.php(144): call_user_func_array(Object(Closure), Array) #13 /www/sites/mysite.dev/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #14 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /www/sites/mysite.dev/htdocs/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /www/sites/mysite.dev/htdocs/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /www/sites/mysite.dev/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/DrupalKernel.php(656): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /www/sites/mysite.dev/htdocs/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #23 {main}.

  1. Notice:

Undefined offset: 0 in _simpletest_batch_finished() (line 474 of /www/sites/mysite.dev/htdocs/core/modules/simpletest/simpletest.module) #0 /www/sites/mysite.dev/htdocs/core/includes/bootstrap.inc(552): _drupal_error_handler_real(8, 'Undefined offse...', '/www/sites/hand...', 474, Array) #1 /www/sites/mysite.dev/htdocs/core/modules/simpletest/simpletest.module(474): _drupal_error_handler(8, 'Undefined offse...', '/www/sites/hand...', 474, Array) #2 /www/sites/mysite.dev/htdocs/core/includes/batch.inc(414): _simpletest_batch_finished(false, Array, Array, '1 Sekunde') #3 /www/sites/mysite.dev/htdocs/core/includes/batch.inc(81): _batch_finished() #4 /www/sites/mysite.dev/htdocs/core/modules/system/src/Controller/BatchController.php(55): _batch_page(Object(Symfony\Component\HttpFoundation\Request)) #5 [internal function]: Drupal\system\Controller\BatchController->batchPage(Object(Symfony\Component\HttpFoundation\Request)) #6 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #7 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() #8 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #9 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #10 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() #11 /www/sites/mysite.dev/vendor/symfony/http-kernel/HttpKernel.php(144): call_user_func_array(Object(Closure), Array) #12 /www/sites/mysite.dev/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #13 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #14 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 /www/sites/mysite.dev/htdocs/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /www/sites/mysite.dev/htdocs/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /www/sites/mysite.dev/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/DrupalKernel.php(656): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /www/sites/mysite.dev/htdocs/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #22 {main}.

  1. Error:

InvalidArgumentException: Invalid database prefix: in Drupal\Core\Test\TestDatabase->__construct() (Zeile 81 in /www/sites/mysite.dev/htdocs/core/lib/Drupal/Core/Test/TestDatabase.php).


I have published a test module for testing this issue and also a bug report on Drupal.org.

1 Answer 1

1

It looks like, that simpletests are very sensitive to incorrect types in yaml files. If e.g. in the config/schema/test_module.schema.yml is a a field with type string:

field:
  type: string
  label: 'String'

and in the config/install/test_module.test_module.id1.yml is a number:

field: 1

then the error messages are generated. The error messages are not easy to read, so it is quite complicated to find, why the tests fail.

The solution is to change the type of the field:

field:
  type: integer
  label: 'String'

or to add quotation marks around the number:

field: '1'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.