function NavigationLogoTest::testSettingsLogoOptionsForm
Tests Navigation logo configuration base options.
File
-
core/
modules/ navigation/ tests/ src/ Functional/ NavigationLogoTest.php, line 74
Class
- NavigationLogoTest
- Tests for <a href="/api/drupal/core%21modules%21navigation%21src%21Form%21SettingsForm.php/class/SettingsForm/11.x" title="Configure Navigation settings for this site." class="local">\Drupal\navigation\Form\SettingsForm</a>.
Namespace
Drupal\Tests\navigation\FunctionalCode
public function testSettingsLogoOptionsForm() : void {
// Navigate to the settings form.
$this->drupalGet('/admin/config/user-interface/navigation/settings');
$this->assertSession()
->statusCodeEquals(200);
// Option 1. Check the default logo provider.
$this->assertSession()
->fieldValueEquals('logo_provider', 'default');
$this->assertSession()
->elementExists('css', 'a.admin-toolbar__logo > svg');
// Option 2: Set the logo provider to hide and check.
$edit = [
'logo_provider' => 'hide',
];
$this->submitForm($edit, t('Save configuration'));
$this->assertSession()
->pageTextContains('The configuration options have been saved.');
$this->assertSession()
->elementNotExists('css', 'a.admin-toolbar__logo');
// Option 3: Set the logo provider to custom and upload a logo.
$logo_file = $this->createFile();
$this->assertNotEmpty($logo_file, 'File entity is not empty.');
// Preset the configuration to verify a custom image is being seen.
$config = $this->configFactory
->getEditable('navigation.settings');
$config->set('logo_provider', 'custom');
$config->set('logo_managed', [
$logo_file->id(),
]);
$config->save();
// Refresh the page to verify custom logo is placed.
$this->drupalGet('/admin/config/user-interface/navigation/settings');
$this->assertSession()
->elementExists('css', 'a.admin-toolbar__logo > img');
$this->assertSession()
->elementAttributeContains('css', 'a.admin-toolbar__logo > img', 'src', $logo_file->getFilename());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.