You are here

private function PatternsBlockTestCase::testCreate in Patterns 7.2

Same name and namespace in other branches
  1. 7 tests/block/block.test \PatternsBlockTestCase::testCreate()
1 call to PatternsBlockTestCase::testCreate()
PatternsBlockTestCase::testCreateModifyDelete in tests/block/block.test

File

tests/block/block.test, line 38
SimpleTests for the Block component of Patterns.

Class

PatternsBlockTestCase
@file SimpleTests for the Block component of Patterns.

Code

private function testCreate() {

  // The block should not exist at this point.
  $block_count = db_select('block', 'b')
    ->fields('b', array(
    'bid',
  ))
    ->condition('module', 'block')
    ->condition('title', 'Test title')
    ->countQuery()
    ->execute()
    ->fetchField();
  $this
    ->assertIdentical($block_count, '0', t('The custom block should not exist at this point.'));

  // Run the pattern.
  parent::runFile('block.yaml', 'Blocks (create)', $this->block_tests_dir);

  // Expected messages.
  $this
    ->assertUniqueText(t('New block successfully added'));

  // The block should exist with the right values for the bartik and seven themes.
  $block = db_select('block', 'b')
    ->fields('b')
    ->condition('module', 'block')
    ->condition('theme', 'bartik')
    ->condition('title', 'Test title');
  $block
    ->join('block_custom', 'bc', 'b.delta = bc.bid');
  $block = $block
    ->fields('bc')
    ->execute()
    ->fetchAll();
  $this
    ->assertIdentical(count($block), 1);
  $this
    ->assertIdentical($block[0]->status, '0');
  $this
    ->assertIdentical($block[0]->weight, '0');
  $this
    ->assertIdentical($block[0]->region, '-1');
  $this
    ->assertIdentical($block[0]->custom, '1');
  $this
    ->assertIdentical($block[0]->visibility, '1');
  $this
    ->assertEqual($block[0]->pages, "<front>");
  $this
    ->assertIdentical($block[0]->body, 'Here comes the body text.');
  $this
    ->assertIdentical($block[0]->info, 'Test custom block');
  $this
    ->assertIdentical($block[0]->format, 'filtered_html');
  $block = db_select('block', 'b')
    ->fields('b')
    ->condition('module', 'block')
    ->condition('theme', 'seven')
    ->condition('title', 'Test title');
  $block
    ->join('block_custom', 'bc', 'b.delta = bc.bid');
  $block = $block
    ->fields('bc')
    ->execute()
    ->fetchAll();
  $this
    ->assertIdentical(count($block), 1);
  $this
    ->assertIdentical($block[0]->status, '1');
  $this
    ->assertIdentical($block[0]->weight, '4');
  $this
    ->assertIdentical($block[0]->region, 'content');
  $this
    ->assertIdentical($block[0]->custom, '1');
  $this
    ->assertIdentical($block[0]->visibility, '1');
  $this
    ->assertEqual($block[0]->pages, "<front>");
}