You are here

token_example.test in Examples for Developers 6

Same filename and directory in other branches
  1. 7 token_example/token_example.test

Test cases for Testing the token example module.

File

token_example/token_example.test
View source
<?php

/**
 * @file
 * Test cases for Testing the token example module.
 */
class TokenExampleTestCase extends DrupalWebTestCase {
  protected $web_user;
  public static function getInfo() {
    return array(
      'name' => 'Token example functionality',
      'description' => 'Verify the token example interface.',
      'group' => 'Examples',
      'dependencies' => array(
        'token',
      ),
    );
  }
  function setUp() {
    parent::setUp('token', 'token_example');
    $this->web_user = $this
      ->drupalCreateUser();
    $this
      ->drupalLogin($this->web_user);
  }
  function testInterface() {
    $this
      ->drupalGet('examples/token');
    $this
      ->assertNoFieldByName('node');
    $this
      ->assertNoFieldByName('user');
    $edit = array(
      'text' => 'User [user-name] is trying the token example!',
    );
    $this
      ->drupalPost(NULL, $edit, t('Submit'));
    $this
      ->assertText('User ' . $this->web_user->name . ' is trying the token example!');
    $node = $this
      ->drupalCreateNode(array(
      'title' => 'Example node',
      'status' => 1,
    ));
    $this
      ->drupalGet('examples/token');
    $edit = array(
      'text' => 'Would you like to view the [type-name] [title]?',
      'node' => $node->nid,
    );
    $this
      ->drupalPost(NULL, $edit, t('Submit'));
    $this
      ->assertText('Would you like to view the Page Example node?');
  }

}

Classes

Namesort descending Description
TokenExampleTestCase @file Test cases for Testing the token example module.