public function MediaBrowserContext::createFromUpload in Lightning Media 8.3
Same name and namespace in other branches
- 8.2 tests/contexts/MediaBrowserContext.behat.inc \Acquia\LightningExtension\Context\MediaBrowserContext::createFromUpload()
Creates a media item from a file upload.
@When I create media named :title by uploading :file
Parameters
string $title: The name of the media item to create.
string $file: The local path to the file to upload.
File
- tests/
contexts/ MediaBrowserContext.behat.inc, line 224
Class
- MediaBrowserContext
- Contains step definitions for interacting with Lightning's media browser.
Namespace
Acquia\LightningExtension\ContextCode
public function createFromUpload($title, $file) {
$this
->visitPath('/entity-browser/modal/media_browser');
$this
->upload($file);
// If the file is an image, assert that cropping is available.
$extension = pathinfo($file, PATHINFO_EXTENSION);
$extension = strtolower($extension);
if (in_array($extension, [
'jpg',
'jpeg',
'gif',
'png',
])) {
/** @var \Acquia\LightningExtension\Context\ImageBrowserContext $context */
$context = $this
->getContext(ImageBrowserContext::class);
$context
->assertCrop();
}
$page = $this
->getSession()
->getPage();
$page
->fillField('Name', $title);
$page
->pressButton('Place');
}