i am trying to write a functional test for my module that ships a views display extender but it already fails at installing my module.
in my module.install file i have these lines that will add my display extender to views.settings config:
function my_module_install() {
// Enable display extender.
$config = \Drupal::service('config.factory')->getEditable('views.settings');
$display_extenders = $config->get('display_extenders') ?: [];
$display_extenders[] = 'my_display_extender';
$config->set('display_extenders', $display_extenders);
$config->save();
}
And i have this simple test that extends ViewsTestBase
<?php
namespace Drupal\Tests\my_module\Functional;
use Drupal\Tests\views\Functional\ViewTestBase;
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
use Drupal\Tests\node\Traits\NodeCreationTrait;
/**
* Test description.
*
* @group my_module
*/
class MyModuleTests extends ViewTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'olivero';
/**
* {@inheritdoc}
*/
protected static $modules = [
'views',
'my_module',
'my_module_tests',
];
/**
* {@inheritdoc}
*/
public static $testViews = [
'my_module_test_content',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE, $modules = ['views_test_config']): void {
parent::setUp($import_test_views, ['my_module_tests']);
//$this->configImporter();
$account = $this->drupalCreateUser(['access content']);
$this->drupalLogin($account);
// ...
}
/**
* Assert that the my_module installed correctly.
*/
public function testModuleInstalls() {
// If we get here, then the module was successfully installed during the
// setUp phase without throwing any Exceptions. Assert that TRUE is true,
// so at least one assertion runs, and then exit.
$this->assertTrue(TRUE, 'Module installed correctly.');
}
}
But the test fails at the install hook
Drupal\Tests\my_module\Functional\MyModuleTests::testModuleInstalls web\modules\custom\my_module\my_module.install:20
Drupal\Core\Config\Schema\SchemaIncompleteException: No schema for views.settings
And i am having a hard time trying to fix it or even understand why, the schema for views.settings is existent at core/modules/views/config/schema/views.schema.yml
Why is it that i get the error? Shouldnt the "views" module be enabled as well?
What do i have to do in order to make it work?
my_module.install
doing? I'm assuming something with Views but might be useful to see$config->save()
from the lines i posted in the question