DropdownWithIncludeTest.php in Block Style Plugins 8.2
File
tests/src/Functional/DropdownWithIncludeTest.php
View source
<?php
namespace Drupal\Tests\block_style_plugins\Functional;
use Drupal\Tests\BrowserTestBase;
class DropdownWithIncludeTest extends BrowserTestBase {
protected static $modules = [
'block_style_plugins',
'block_style_plugins_test',
];
protected $defaultTheme = 'stark';
protected $adminUser;
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'administer blocks',
'access administration pages',
]);
$this
->drupalLogin($this->adminUser);
$this
->drupalPlaceBlock('system_powered_by_block', [
'id' => 'poweredbytest',
'region' => 'content',
]);
$this
->drupalPlaceBlock('system_breadcrumb_block', [
'id' => 'breadcrumbtest',
'region' => 'content',
]);
}
public function testBreadcrumbBlockUnstyled() {
$assert = $this
->assertSession();
$this
->drupalGet('admin/structure/block/manage/breadcrumbtest');
$assert
->pageTextContains('Block Styles');
$assert
->pageTextNotContains('Choose a style from the dropdown');
$assert
->fieldNotExists('third_party_settings[block_style_plugins][dropdown_with_include][dropdown_class]');
}
public function testPoweredByBlockIncluded() {
$assert = $this
->assertSession();
$this
->drupalGet('admin/structure/block/manage/poweredbytest');
$assert
->responseContains('Choose a style from the dropdown');
$assert
->fieldValueEquals('third_party_settings[block_style_plugins][dropdown_with_include][dropdown_class]', 'style-3');
$this
->submitForm([
'third_party_settings[block_style_plugins][dropdown_with_include][dropdown_class]' => 'style-1',
], 'Save block');
$this
->drupalGet('<front>');
$assert
->responseContains('style-1');
$this
->drupalGet('admin/structure/block/manage/poweredbytest');
$assert
->fieldValueEquals('third_party_settings[block_style_plugins][dropdown_with_include][dropdown_class]', 'style-1');
}
}