EntityBrowserBlockTest.php in Entity Browser Block 8
File
tests/src/FunctionalJavascript/EntityBrowserBlockTest.php
View source
<?php
namespace Drupal\Tests\entity_browser_block\FunctionalJavascript;
use Drupal\Tests\entity_browser\FunctionalJavascript\EntityBrowserWebDriverTestBase;
class EntityBrowserBlockTest extends EntityBrowserWebDriverTestBase {
public static $modules = [
'entity_browser_block',
];
protected static $userPermissions = [
'access test_entity_browser_file entity browser pages',
'create article content',
'access content',
'administer blocks',
];
public function testEntityBrowserBlock() {
$image = $this
->createFile('llama');
$image2 = $this
->createFile('alpaca');
$this
->drupalGet('admin/structure/block/add/entity_browser_block:test_entity_browser_file');
$this
->assertSession()
->pageTextContains('Test entity browser file');
$this
->assertSession()
->linkExists('Select entities');
$this
->getSession()
->getPage()
->clickLink('Select entities');
$this
->getSession()
->switchToIFrame('entity_browser_iframe_test_entity_browser_file');
$this
->getSession()
->getPage()
->checkField('entity_browser_select[file:' . $image
->id() . ']');
$this
->getSession()
->getPage()
->checkField('entity_browser_select[file:' . $image2
->id() . ']');
$this
->getSession()
->getPage()
->pressButton('Select entities');
$this
->getSession()
->switchToIFrame();
$this
->waitForAjaxToFinish();
$this
->assertSession()
->pageTextContains('llama.jpg');
$this
->assertSession()
->pageTextContains('alpaca.jpg');
$this
->assertSession()
->buttonExists('remove_file:1');
$this
->getSession()
->getPage()
->pressButton('remove_file:1');
$this
->waitForAjaxToFinish();
$this
->assertSession()
->pageTextNotContains('llama.jpg');
$this
->assertSession()
->pageTextContains('alpaca.jpg');
$this
->drupalPostForm(NULL, [
'region' => 'content',
], 'Save block');
$this
->assertSession()
->pageTextContains('The block configuration has been saved.');
$this
->getSession()
->getPage()
->clickLink('Configure');
$this
->assertSession()
->pageTextContains('Test entity browser file');
$this
->assertSession()
->pageTextNotContains('llama.jpg');
$this
->assertSession()
->pageTextContains('alpaca.jpg');
}
}