BlazyJavaScriptTestBase.php in Blazy 8.2
File
tests/src/FunctionalJavascript/BlazyJavaScriptTestBase.php
View source
<?php
namespace Drupal\Tests\blazy\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Tests\blazy\Traits\BlazyUnitTestTrait;
use Drupal\Tests\blazy\Traits\BlazyCreationTestTrait;
abstract class BlazyJavaScriptTestBase extends WebDriverTestBase {
use BlazyUnitTestTrait;
use BlazyCreationTestTrait;
protected $defaultTheme = 'stark';
protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
protected static $modules = [
'field',
'filter',
'image',
'node',
'text',
'blazy',
'blazy_test',
];
protected function setUp() {
parent::setUp();
$this
->setUpVariables();
$this->root = $this->container
->get('app.root');
$this->fileSystem = $this->container
->get('file_system');
$this->entityFieldManager = $this->container
->get('entity_field.manager');
$this->formatterPluginManager = $this->container
->get('plugin.manager.field.formatter');
$this->blazyAdmin = $this->container
->get('blazy.admin');
$this->blazyManager = $this->container
->get('blazy.manager');
$this->scriptLoader = 'blazy';
$this->maxParagraphs = 180;
}
public function doTestFormatterDisplay() {
$image_path = $this
->getImagePath(TRUE);
$this
->createScreenshot($image_path . '/' . $this->scriptLoader . '_1_initial.png');
$this
->assertSession()
->elementExists('css', '.b-lazy');
$this
->getSession()
->executeScript('window.scrollTo(0, document.body.scrollHeight);');
$this
->createScreenshot($image_path . '/' . $this->scriptLoader . '_2_loading.png');
$this
->getSession()
->wait(3000);
$this
->assertNotEmpty($this
->assertSession()
->waitForElement('css', '.b-loaded'));
$this
->createScreenshot($image_path . '/' . $this->scriptLoader . '_3_loaded.png');
}
}