public function BynderWidgetsTest::testRedirectToEntityBrowserWidgets in Bynder 8.3
Same name and namespace in other branches
- 8 tests/src/Functional/BynderWidgetsTest.php \Drupal\Tests\bynder\Functional\BynderWidgetsTest::testRedirectToEntityBrowserWidgets()
- 8.2 tests/src/Functional/BynderWidgetsTest.php \Drupal\Tests\bynder\Functional\BynderWidgetsTest::testRedirectToEntityBrowserWidgets()
- 4.0.x tests/src/Functional/BynderWidgetsTest.php \Drupal\Tests\bynder\Functional\BynderWidgetsTest::testRedirectToEntityBrowserWidgets()
Tests redirect from Bynder to Entity browser widgets.
File
- tests/
src/ Functional/ BynderWidgetsTest.php, line 49
Class
- BynderWidgetsTest
- Tests the Bynder Entity Browser widgets.
Namespace
Drupal\Tests\bynder\FunctionalCode
public function testRedirectToEntityBrowserWidgets() {
\Drupal::state()
->set('bynder.bynder_test_brands', [
[
'id' => 'brand_id',
'name' => 'Brand Name',
'subBrands' => [],
],
]);
$entity_browser = $this->container
->get('entity_type.manager')
->getStorage('entity_browser')
->load('bynder');
$entity_browser
->setWidgetSelector('tabs');
$widget_configuration = [
'id' => 'bynder_upload',
'label' => 'Bynder upload',
'weight' => 5,
'settings' => [
'media_type' => 'media_type',
'brand' => 'brand_id',
],
];
$widget_id = $entity_browser
->addWidget($widget_configuration);
$entity_browser
->save();
$this
->drupalGet('/entity-browser/modal/bynder');
// Tests that we redirect to the upload widget after we press the "Reload
// after submit" button.
\Drupal::state()
->set('bynder.bynder_test_access_token', FALSE);
$this
->getSession()
->getPage()
->pressButton('Bynder upload');
$this
->assertSession()
->elementAttributeNotContains('css', '#edit-tab-selector-065aa618-5851-4744-b51c-02e57f5f0cc3', 'class', 'is-disabled');
$this
->assertSession()
->elementAttributeContains('css', '#edit-tab-selector-' . $widget_id, 'class', 'is-disabled');
\Drupal::state()
->set('bynder.bynder_test_access_token', TRUE);
$this
->getSession()
->getPage()
->pressButton('Reload after submit');
$this
->assertSession()
->elementAttributeNotContains('css', '#edit-tab-selector-065aa618-5851-4744-b51c-02e57f5f0cc3', 'class', 'is-disabled');
$this
->assertSession()
->elementAttributeContains('css', '#edit-tab-selector-' . $widget_id, 'class', 'is-disabled');
}