I'm trying to write a test on a settings form. The module uses a queue, and the settings form displays the items in the queue like so:
When I extend the test class from WebTestBase
I get:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mskcc_local_d8.test73723996queue' doesn't exist: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {queue} q WHERE name = :db_condition_placeholder_0) subquery; Array ( [:db_condition_placeholder_0] => google_analytics_counter_worker ) in Drupal\google_analytics_counter\GoogleAnalyticsCounterManager->getCount() (line 635 of modules/contrib/google_analytics_counter/src/GoogleAnalyticsCounterManager.php).
Drupal\Core\Database\Statement->execute(Array, Array) (Line: 625)
Drupal\Core\Database\Connection->query('SELECT COUNT(*) AS expression
FROM
(SELECT 1 AS expression
FROM
{queue} q
WHERE name = :db_condition_placeholder_0) subquery', Array, Array) (Line: 87)
Drupal\Core\Database\Driver\mysql\Connection->query('SELECT COUNT(*) AS expression
FROM
(SELECT 1 AS expression
FROM
{queue} q
WHERE name = :db_condition_placeholder_0) subquery', Array, Array) (Line: 510)
Drupal\Core\Database\Query\Select->execute() (Line: 635)
Drupal\google_analytics_counter\GoogleAnalyticsCounterManager->getCount('queue') (Line: 134)
Drupal\google_analytics_counter\Form\GoogleAnalyticsCounterSettingsForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('google_analytics_counter_admin_settings', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm('google_analytics_counter_admin_settings', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 664)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
which tells me that the queue
table is missing from the automated test environment.
But when I extend the test class from KernelTestBase
and add
// These additional tables are necessary because $this->cron->run() calls
// system_cron().
$this->installSchema('system', ['key_value_expire']);
$this->connection = Database::getConnection();
$this->cron = \Drupal::service('cron');
to setup(), I assume my automated testing environment will contain a queue table (still to be determined). But the methods I regularly use to test a form, like $this->drupalGet
and $this->assertResponse
will now be not found.
How can I test a settings form that displays the contents of the queue table?
Thanks