You are here

public function AccordionBlocksTest::testBlockContentType in Accordion Blocks 8

Test our accordion blocks block content type.

Tests for the following:

  • That block content type appear in the user interface.
  • That block content type has correct blocks entity reference field.
  • That block content type has correct display format settings.

File

src/Tests/AccordionBlocksTest.php, line 49
Contains Drupal\accordion_blocks\Tests\AccordionBlocksTest.

Class

AccordionBlocksTest
Test that Accordion Blocks Custom Block Type is created and block widgets are working.

Namespace

Drupal\accordion_blocks\Tests

Code

public function testBlockContentType() {

  // Log in an admin user.
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer blocks',
    'administer block_content fields',
    'administer block_content display',
    'administer block_content form display',
  ));
  $this
    ->drupalLogin($admin_user);

  // Get a list of Block content types.
  $this
    ->drupalGet('/admin/structure/block/block-content/types');

  // Verify that these content types show up in the user interface.
  $this
    ->assertRaw('Accordion block', 'Accordion Block Content Type found.');

  // Get a list of Accordion Blocks conten type fields
  $this
    ->drupalGet('/admin/structure/block/block-content/manage/accordion_block/fields');
  $this
    ->assertRaw('field_blocks', 'Field Blocks is found');

  // Check that the blocks field form display is auto complete.
  $this
    ->drupalGet('/admin/structure/block/block-content/manage/accordion_block/form-display');
  $this
    ->assertFieldByXPath('//select[@name="fields[field_blocks][type]"]', 'entity_reference_autocomplete', 'Form Display is auto complete');

  // Check display format of the blocks field to be Accordion Widget
  $this
    ->drupalGet('/admin/structure/block/block-content/manage/accordion_block/display');
  $this
    ->assertFieldByXPath('//select[@name="fields[field_blocks][type]"]', 'accordion_widget_formatter', 'Display Accordion Widget');
}