public function EntityBrowserUITest::testEntityBrowserToken in Entity Browser 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/EntityBrowserUITest.php \Drupal\Tests\entity_browser\Functional\EntityBrowserUITest::testEntityBrowserToken()
Tests entity browser token support for upload widget.
File
- tests/
src/ Functional/ EntityBrowserUITest.php, line 58
Class
- EntityBrowserUITest
- Tests the entity browser UI.
Namespace
Drupal\Tests\entity_browser\FunctionalCode
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);
// Go to the entity browser iframe link.
$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);
// Test entity browser token that has upload location configured to
// public://[current-user:account-name]/.
$this
->assertEquals($file
->getFileUri(), 'public://' . $account
->getAccountName() . '/' . $file
->getFilename(), 'Image has the correct uri.');
}