You are here

public function TwitterBlockTest::testTwitterBlock in Twitter Block 8.2

Test that the twitter block can be placed and works.

File

src/Tests/TwitterBlockTest.php, line 37

Class

TwitterBlockTest
Tests if the twitter block is available.

Namespace

Drupal\twitter_block\Tests

Code

public function testTwitterBlock() {

  // Test availability of the twitter block in the admin "Place blocks" list.
  \Drupal::service('theme_handler')
    ->install([
    'bartik',
    'seven',
    'stark',
  ]);
  $theme_settings = $this
    ->config('system.theme');
  foreach ([
    'bartik',
    'seven',
    'stark',
  ] as $theme) {
    $this
      ->drupalGet('admin/structure/block/list/' . $theme);

    // Configure and save the block.
    $this
      ->drupalPlaceBlock('twitter_block', array(
      'widget_id' => 600720083413962752,
      'width' => 180,
      'height' => 200,
      'region' => 'content',
      'theme' => $theme,
    ));

    // Set the default theme and ensure the block is placed.
    $theme_settings
      ->set('default', $theme)
      ->save();
    $this
      ->drupalGet('');
    $this
      ->assertText('Twitter feed', 'Twitter block found');
  }
}