EntityBrowserUITest.php in Entity Browser 8.2
File
tests/src/Functional/EntityBrowserUITest.php
View source
<?php
namespace Drupal\Tests\entity_browser\Functional;
use Drupal\file\Entity\File;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\TestFileCreationTrait;
class EntityBrowserUITest extends BrowserTestBase {
use TestFileCreationTrait;
public static $modules = [
'entity_browser_test',
'views',
'block',
];
protected $defaultTheme = 'stark';
public function testEntityBrowserUI() {
$account = $this
->drupalCreateUser([
'administer entity browsers',
'access test_entity_browser_iframe entity browser pages',
]);
$this
->drupalLogin($account);
$this
->drupalGet('/entity-browser/iframe/test_entity_browser_iframe');
$this
->assertSession()
->responseContains('Select');
$this
->drupalGet('/admin/config/content/entity_browser/test_entity_browser_iframe/widgets');
$edit = [
'table[871dbf77-012e-41cb-b32a-ada353d2de35][form][submit_text]' => 'Different',
];
$this
->submitForm($edit, 'Save');
$this
->drupalGet('/entity-browser/iframe/test_entity_browser_iframe');
$this
->assertSession()
->responseContains('Different');
}
public function testEntityBrowserToken() {
$this->container
->get('module_installer')
->install([
'token',
'file',
]);
$account = $this
->drupalCreateUser([
'access test_entity_browser_token entity browser pages',
]);
$this
->drupalLogin($account);
$this
->drupalGet('/entity-browser/iframe/test_entity_browser_token');
$image = current($this
->getTestFiles('image'));
$edit = [
'files[upload][]' => $this->container
->get('file_system')
->realpath($image->uri),
];
$this
->submitForm($edit, 'Select files');
$file = File::load(1);
$this
->assertEquals($file
->getFileUri(), 'public://' . $account
->getAccountName() . '/' . $file
->getFilename(), 'Image has the correct uri.');
}
}