UiPatternsViewsSettingsTest.php in UI Patterns 8
File
modules/ui_patterns_views/tests/src/FunctionalJavascript/UiPatternsViewsSettingsTest.php
View source
<?php
namespace Drupal\Tests\ui_patterns_views\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\views\Entity\View;
class UiPatternsViewsSettingsTest extends WebDriverTestBase {
protected $defaultTheme = 'stark';
protected $strictConfigSchema = FALSE;
protected static $modules = [
'field',
'ui_patterns_views_test',
];
public function testUiPatternsViewsSettings() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$user = $this
->drupalCreateUser([], NULL, TRUE);
$this
->drupalLogin($user);
$this
->drupalGet('/admin/structure/views/view/articles');
$page
->clickLink('Change settings for this style');
$assert_session
->assertWaitOnAjaxRequest();
$page
->selectFieldOption('Variant', 'Highlighted');
$page
->selectFieldOption('Destination for Content: Title', 'Description');
$page
->find('css', '.ui-dialog-buttonpane .form-actions')
->pressButton('Apply');
$assert_session
->assertWaitOnAjaxRequest();
$page
->find('css', '#edit-actions')
->pressButton('Save');
$view = View::load('articles');
$settings = $view
->getDisplay('default')['display_options']['row']['options'];
$this
->assertEquals($settings['pattern'], 'teaser');
$this
->assertEquals($settings['pattern_variant'], 'highlighted');
$this
->assertNotEmpty($settings['pattern_mapping'], "Pattern mapping is empty.");
$mapping = $settings['pattern_mapping'];
$this
->assertArrayHasKey('views_row:title', $mapping, 'Mapping not found.');
$this
->assertEquals($mapping['views_row:title']['destination'], 'description', "Mapping not valid.");
}
}