You are here

function NodequeueAdministerTestCase::testNodequeueAddNode in Nodequeue 7.2

Same name and namespace in other branches
  1. 6.2 tests/nodequeue.test \NodequeueAdministerTestCase::testNodequeueAddNode()

File

tests/nodequeue.test, line 490
Tests for the Nodequeue module.

Class

NodequeueAdministerTestCase

Code

function testNodequeueAddNode() {
  $this
    ->drupalLogin($this->user);
  $queue = $this
    ->createNodequeue(array(
    'page',
    'article',
  ), array(
    2,
  ));
  $subqueues = nodequeue_load_subqueues_by_queue($queue->qid);
  $subqueue = array_shift($subqueues);
  $path = 'admin/structure/nodequeue/' . $queue->qid . '/view/' . $subqueue->sqid;
  $node1 = $this
    ->drupalCreateNode(array(
    'title' => 'Bar',
    'type' => 'article',
    'promote' => 1,
  ));
  $node2 = $this
    ->drupalCreateNode(array(
    'title' => 'Baz',
    'type' => 'article',
    'promote' => 1,
  ));

  // deliberately use an ambiguous title
  $this
    ->drupalGet($path);
  $this
    ->drupalPost($path, array(
    'add[nid]' => 'B',
  ), 'Add content');
  $this
    ->assertRaw('Please enter a valid node title.', t('Got an error message.'), t('Nodequeue'));
  $this
    ->drupalPost($path, array(
    'add[nid]' => 'Unknown',
  ), 'Add content');
  $this
    ->assertRaw('Please enter a valid node title.', t('Got an error message.'), t('Nodequeue'));
  $this
    ->drupalPost($path, array(
    'add[nid]' => $node1->title . ' [nid: ' . $node1->nid . ']',
  ), 'Add content');
  $this
    ->assertRaw('<a href="' . url('node/' . $node1->nid) . '">' . $node1->title . '</a>', t('Node has been added to the nodequeue.'), t('Nodequeue'));
  $this
    ->drupalPost($path, array(
    'add[nid]' => $node2->title . ' [nid: ' . $node2->nid . ']',
  ), 'Add content');
  $this
    ->assertRaw('<a href="' . url('node/' . $node2->nid) . '">' . $node2->title . '</a>', t('Node has been added to the nodequeue.'), t('Nodequeue'));
}