PDOException: Base table or view not found
You may see something like the following.
There was 1 error:
1) Drupal\Tests\mymodule\Kernel\AuthorizationServiceTest::testSuccessfulLogin
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mysite.test20951378key_value_expire' doesn't exist: SELECT name, value FROM {key_value_expire} WHERE expire > :now AND name IN ( :keys__0 ) AND collection = :collection; Array
(
[:now] => 1588704859
[:collection] => user.private_tempstore.mymodule
[:keys__0] => HSmqBoYuyRW4B_bMnh2JoeHftpOGVpinMJ3PlbmifNk:crmToken
)
Caused by
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mysite.test20951378key_value_expire' doesn't exist
This indicates that you need to include schema in your test. In the setUp() method you can include schemas like the following.
protected function setUp() {
parent::setUp();
$this->installSchema('system', ['key_value_expire']);
}
Finding the particular schema needed can be a little difficult if it's not something you have included before. The easiest way to discover the proper way to include the necessary schema is to search the Drupal code base for the table name indicated in the error. The table name will be listed something like mysite.test20951378key_value_expire. You want the portion following the test hash.