protected function PanelsIPETestTrait::addBlock in Panels 8.4
Same name and namespace in other branches
- 8.3 panels_ipe/tests/src/FunctionalJavascript/PanelsIPETestTrait.php \Drupal\Tests\panels_ipe\FunctionalJavascript\PanelsIPETestTrait::addBlock()
 
Adds a Block (Plugin) to the page.
Parameters
string $category: The name of the category, i.e. "Help".
string $plugin_id: The ID of the Block Plugin, i.e. "help_block".
Return value
string The newly created Block ID.
1 call to PanelsIPETestTrait::addBlock()
- PanelsIPETestBase::testIPEAddBlock in panels_ipe/
tests/ src/ FunctionalJavascript/ PanelsIPETestBase.php  - Tests that adding a block with default configuration works.
 
File
- panels_ipe/
tests/ src/ FunctionalJavascript/ PanelsIPETestTrait.php, line 135  
Class
- PanelsIPETestTrait
 - Trait which can be used to test Panels IPE components.
 
Namespace
Drupal\Tests\panels_ipe\FunctionalJavascriptCode
protected function addBlock($category, $plugin_id) {
  // Get a list of current Block Plugins.
  $old_blocks = $this
    ->getOnScreenBlockIDs();
  // Open the "Manage Content" tab and select the given Block Plugin.
  $this
    ->clickAndWait('[data-tab-id="manage_content"]');
  $this
    ->waitUntilNotPresent('.ipe-icon-loading');
  $this
    ->clickAndWait('[data-category="' . $category . '"]');
  // @todo Remove when https://github.com/jcalderonzumba/gastonjs/issues/19
  // is fixed. Currently clicking anchor tags with nested elements is not
  // possible.
  $this
    ->getSession()
    ->executeScript("jQuery('" . '[data-plugin-id="' . $plugin_id . '"]' . "')[0].click()");
  // Wait for the Block form to finish loading/opening.
  $this
    ->waitUntilNotPresent('.ipe-icon-loading');
  $this
    ->waitUntilVisible('.ipe-form form');
  // Submit the form with default settings.
  $this
    ->saveBlockConfigurationForm();
  // Find the newest Block Plugin.
  $new_blocks = $this
    ->getOnScreenBlockIDs();
  $diff_blocks = array_diff($new_blocks, $old_blocks);
  $new_block = reset($diff_blocks);
  $this
    ->assertNotFalse($new_block, 'New block was placed on screen.');
  return $new_block;
}