public function ThunderMediaTestTrait::selectMedia in Thunder 8.2
Same name and namespace in other branches
- 8.5 tests/src/FunctionalJavascript/ThunderMediaTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMediaTestTrait::selectMedia()
- 8.3 tests/src/FunctionalJavascript/ThunderMediaTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMediaTestTrait::selectMedia()
- 8.4 tests/src/FunctionalJavascript/ThunderMediaTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMediaTestTrait::selectMedia()
- 6.2.x tests/src/FunctionalJavascript/ThunderMediaTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMediaTestTrait::selectMedia()
- 6.0.x tests/src/FunctionalJavascript/ThunderMediaTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMediaTestTrait::selectMedia()
- 6.1.x tests/src/FunctionalJavascript/ThunderMediaTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMediaTestTrait::selectMedia()
Select Medias for field.
Parameters
string $fieldName: Field name.
string $entityBrowser: Entity browser identifier.
array $medias: List of media identifiers.
7 calls to ThunderMediaTestTrait::selectMedia()
- ArticleCreationTest::testCreateArticle in tests/
src/ FunctionalJavascript/ ArticleCreationTest.php - Test Creation of Article.
- ChannelsTagsTest::testChannelsCreation in tests/
src/ FunctionalJavascript/ ChannelsTagsTest.php - Test channel creation, tagging of articles and channel page with articles.
- LiveblogTest::testWithPusher in tests/
src/ FunctionalJavascript/ Integration/ LiveblogTest.php - Testing of module integration.
- MetaInformationTest::createArticleWithFields in tests/
src/ FunctionalJavascript/ MetaInformationTest.php - Create simple article for meta tag testing.
- ModuleIntegrationTest::testDiffModule in tests/
src/ FunctionalJavascript/ ModuleIntegrationTest.php - Testing integration of "diff" module.
File
- tests/
src/ FunctionalJavascript/ ThunderMediaTestTrait.php, line 22
Class
- ThunderMediaTestTrait
- Trait for handling of Media related test actions.
Namespace
Drupal\Tests\thunder\FunctionalJavascriptCode
public function selectMedia($fieldName, $entityBrowser, array $medias) {
/** @var \Behat\Mink\Element\DocumentElement $page */
$page = $this
->getSession()
->getPage();
$this
->assertSession()
->assertWaitOnAjaxRequest();
$buttonName = $fieldName . '_entity_browser_entity_browser';
$this
->scrollElementInView("[name=\"{$buttonName}\"]");
$page
->pressButton($buttonName);
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->getSession()
->switchToIFrame('entity_browser_iframe_' . $entityBrowser);
$this
->assertSession()
->assertWaitOnAjaxRequest();
foreach ($medias as $media) {
$page
->find('xpath', "//div[contains(@class, 'views-row') and .//*[@name='entity_browser_select[{$media}]']]")
->click();
}
$this
->assertSession()
->assertWaitOnAjaxRequest();
$element = 'img';
if ($entityBrowser == 'multiple_image_browser') {
$this
->getSession()
->wait(200);
$this
->assertSession()
->assertWaitOnAjaxRequest();
$page
->pressButton('Use selected');
}
elseif ($entityBrowser == 'image_browser') {
$page
->pressButton('Select image');
}
elseif ($entityBrowser == 'riddle_browser') {
$page
->pressButton('Select riddle');
}
elseif ($entityBrowser == 'video_browser') {
$page
->pressButton('Select video');
$element = 'iframe';
}
$this
->getSession()
->switchToIFrame();
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->waitUntilVisible('div[data-drupal-selector="edit-' . str_replace('_', '-', $fieldName) . '-wrapper"] ' . $element);
}