Verify the logged in user has the desired access to the various blog nodes.

Parameters

object $node_user: The user who creates the node.

object $node: A node object.

boolean $admin: User has 'access administration pages' privilege.

integer $response: HTTP response code.

2 calls to BlogTestCase::verifyBlogs()
BlogTestCase::doBasicTests in modules/blog/blog.test
Run basic tests on the indicated user.
BlogTestCase::testBlog in modules/blog/blog.test
Login users, create blog nodes, and test blog functionality through the admin and user interfaces.

File

modules/blog/blog.test, line 128
Tests for blog.module.

Class

BlogTestCase
@file Tests for blog.module.

Code

private function verifyBlogs($node_user, $node, $admin, $response = 200) {
  $response2 = $admin ? 200 : 403;

  // View blog help node.
  $this
    ->drupalGet('admin/help/blog');
  $this
    ->assertResponse($response2);
  if ($response2 == 200) {
    $this
      ->assertTitle(t('Blog | Drupal'), 'Blog help node was displayed');
    $this
      ->assertText(t('Blog'), 'Blog help node was displayed');
  }

  // Verify the blog block was displayed.
  $this
    ->drupalGet('');
  $this
    ->assertResponse(200);
  $this
    ->assertText(t('Recent blog posts'), 'Blog block was displayed');

  // View blog node.
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertResponse(200);
  $this
    ->assertTitle($node->title . ' | Drupal', 'Blog node was displayed');
  $breadcrumb = array(
    l(t('Home'), NULL),
    l(t('Blogs'), 'blog'),
    l(t("!name's blog", array(
      '!name' => format_username($node_user),
    )), 'blog/' . $node_user->uid),
  );
  $this
    ->assertRaw(theme('breadcrumb', array(
    'breadcrumb' => $breadcrumb,
  )), 'Breadcrumbs were displayed');

  // View blog edit node.
  $this
    ->drupalGet('node/' . $node->nid . '/edit');
  $this
    ->assertResponse($response);
  if ($response == 200) {
    $this
      ->assertTitle('Edit Blog entry ' . $node->title . ' | Drupal', 'Blog edit node was displayed');
  }
  if ($response == 200) {

    // Edit blog node.
    $edit = array();
    $langcode = LANGUAGE_NONE;
    $edit["title"] = 'node/' . $node->nid;
    $edit["body[{$langcode}][0][value]"] = $this
      ->randomName(256);
    $this
      ->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
    $this
      ->assertRaw(t('Blog entry %title has been updated.', array(
      '%title' => $edit["title"],
    )), 'Blog node was edited');

    // Delete blog node.
    $this
      ->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
    $this
      ->assertResponse($response);
    $this
      ->assertRaw(t('Blog entry %title has been deleted.', array(
      '%title' => $edit["title"],
    )), 'Blog node was deleted');
  }
}