type_tray-1.0.x-dev/tests/src/FunctionalJavascript/TypeTrayWebDriverTestBase.php
tests/src/FunctionalJavascript/TypeTrayWebDriverTestBase.php
<?php
namespace Drupal\Tests\type_tray\FunctionalJavascript;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\file\Entity\File;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Behat\Mink\Element\NodeElement;
use Drupal\language\Entity\ConfigurableLanguage;
/**
* Base class for Type Tray Javascript functional tests.
*
* @package Drupal\Tests\type_tray\FunctionalJavascript
*/
abstract class TypeTrayWebDriverTestBase extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected static $modules = [
'block',
'node',
'filter',
'field_ui',
'system',
'type_tray',
];
/**
* The admin user account.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $adminUser;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
// Place some blocks to make our lives easier down the road.
$this->drupalPlaceBlock('system_breadcrumb_block');
$this->drupalPlaceBlock('local_tasks_block');
$this->drupalPlaceBlock('local_actions_block');
$this->drupalPlaceBlock('page_title_block');
// Start off logged in as admin.
$account = $this->drupalCreateUser([
'administer content types',
'administer node fields',
'administer node display',
'administer nodes',
'bypass node access',
'administer type tray'
]);
$this->adminUser = $account;
$this->drupalLogin($this->adminUser);
}
/**
* Debugger method to save additional HTML output.
*
* The base class will only save browser output when accessing page using
* ::drupalGet and providing a printer class to PHPUnit. This method
* is intended for developers to help debug browser test failures and capture
* more verbose output.
*/
protected function saveHtmlOutput() {
$out = $this->getSession()->getPage()->getContent();
// Ensure that any changes to variables in the other thread are picked up.
$this->refreshVariables();
if ($this->htmlOutputEnabled) {
$html_output = '<hr />Ending URL: ' . $this->getSession()->getCurrentUrl();
$html_output .= '<hr />' . $out;
$html_output .= $this->getHtmlOutputHeaders();
$this->htmlOutput($html_output);
}
}
}
