public function EntityBrowserTest::testMultiCardinalityField in Entity Browser 8
Same name and namespace in other branches
- 8.2 tests/src/FunctionalJavascript/EntityBrowserTest.php \Drupal\Tests\entity_browser\FunctionalJavascript\EntityBrowserTest::testMultiCardinalityField()
Tests the field widget with a multi-cardinality field.
File
- tests/
src/ FunctionalJavascript/ EntityBrowserTest.php, line 87
Class
- EntityBrowserTest
- Tests the entity_browser.
Namespace
Drupal\Tests\entity_browser\FunctionalJavascriptCode
public function testMultiCardinalityField() {
$assert_session = $this
->assertSession();
$session = $this
->getSession();
$page = $session
->getPage();
$this->container
->get('entity_type.manager')
->getStorage('field_storage_config')
->load('node.field_reference')
->setCardinality(3)
->save();
// Create a few files to choose.
$images = [];
array_push($images, $this
->createFile('llama'));
array_push($images, $this
->createFile('sloth'));
array_push($images, $this
->createFile('puppy'));
$this
->drupalGet('node/add/article');
$assert_session
->linkExists('Select entities');
$assert_session
->pageTextContains('You can select up to 3 files (3 left).');
$page
->clickLink('Select entities');
$session
->switchToIFrame('entity_browser_iframe_test_entity_browser_file');
$page
->checkField('entity_browser_select[file:' . $images[0]
->id() . ']');
$page
->checkField('entity_browser_select[file:' . $images[1]
->id() . ']');
$page
->pressButton('Select entities');
// Switch back to the main page.
$session
->switchToIFrame();
$this
->waitForAjaxToFinish();
// Selections have been made, so the message should be different.
$assert_session
->pageTextContains('You can select up to 3 files (1 left).');
}