You are here

protected function EntityBrowserWebDriverTestBase::createFile in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 tests/src/FunctionalJavascript/EntityBrowserWebDriverTestBase.php \Drupal\Tests\entity_browser\FunctionalJavascript\EntityBrowserWebDriverTestBase::createFile()

Creates an image.

Parameters

string $name: The name of the image.

string $extension: File extension.

Return value

\Drupal\file\FileInterface Returns an image.

10 calls to EntityBrowserWebDriverTestBase::createFile()
EntityBrowserTest::testDropdownWidgetSelector in tests/src/FunctionalJavascript/EntityBrowserTest.php
Tests dropdown widget selector.
EntityBrowserTest::testMultiCardinalityField in tests/src/FunctionalJavascript/EntityBrowserTest.php
Tests the field widget with a multi-cardinality field.
EntityBrowserTest::testSingleCardinalityField in tests/src/FunctionalJavascript/EntityBrowserTest.php
Tests the field widget with a single-cardinality field.
EntityBrowserTest::testSingleWidgetSelector in tests/src/FunctionalJavascript/EntityBrowserTest.php
Tests single widget selector.
EntityBrowserTest::testTabsWidgetSelector in tests/src/FunctionalJavascript/EntityBrowserTest.php
Tests tabs widget selector.

... See full list

File

tests/src/FunctionalJavascript/EntityBrowserWebDriverTestBase.php, line 175

Class

EntityBrowserWebDriverTestBase
Base class for Entity browser Javascript functional tests.

Namespace

Drupal\Tests\entity_browser\FunctionalJavascript

Code

protected function createFile($name, $extension = 'jpg') {
  file_put_contents('public://' . $name . '.' . $extension, $this
    ->randomMachineName());
  $image = File::create([
    'filename' => $name . '.' . $extension,
    'uri' => 'public://' . $name . '.' . $extension,
  ]);
  $image
    ->setPermanent();
  $image
    ->save();
  return $image;
}