ImageMediaTest.php in Lightning Media 8.3
File
tests/src/Functional/ImageMediaTest.php
View source
<?php
namespace Drupal\Tests\lightning_media\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\lightning_media\Traits\EntityBrowserTrait;
class ImageMediaTest extends BrowserTestBase {
use EntityBrowserTrait;
protected $defaultTheme = 'stark';
protected static $modules = [
'image_widget_crop',
'lightning_media_image',
'lightning_roles',
];
protected function setUp() {
parent::setUp();
$this
->addMediaLibraryToEntityBrowsers();
}
public function testCreateIgnoredImage() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$account = $this
->drupalCreateUser([]);
$account
->addRole('media_creator');
$account
->save();
$this
->drupalLogin($account);
$this
->drupalGet('/media/add/image');
$page
->attachFileToField('Image', __DIR__ . '/../../files/test.jpg');
$page
->pressButton('Upload');
$summary = $assert_session
->elementExists('css', 'details > summary:contains(Crop image)');
$this
->assertTrue($summary
->getParent()
->hasAttribute('open'));
$assert_session
->elementExists('css', 'details > summary:contains(Freeform)');
$page
->fillField('Name', 'Blorg');
$page
->uncheckField('Show in media library');
$page
->pressButton('Save');
$this
->drupalGet('/entity-browser/modal/media_browser');
$assert_session
->pageTextContains('There are no media items to display.');
}
}