home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (node_example.test)

This example Drupal source code file (node_example.test) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

account, array, color, content, drupalwebtestcase, edit, example, extends, function, getinfo, node, php, title, type

The node_example.test Drupal example source code


 * @file
 * Simpletest case for node_example module.
 * Verify example module functionality.

 * Functionality tests for node example module.
class NodeExampleTestCase extends DrupalWebTestCase {

  public static function getInfo() {
    return array(
      'name' => 'Node example',
      'description' => 'Verify the custom node type creation.',
      'group' => 'Examples',

  function setUp() {
    // Enable the module.

   * Verify the functionality of the example module.
  function testNodeCreation() {
    // Create and login user.
    $account = $this->drupalCreateUser(array('access content', 'create example content'));

    // Create a new node. The image makes it more complicated, so skip it.
    $edit = array(
      'title' => $this->randomName(),
      'color' => 'red',
      'quantity' => 100,
    $this->drupalPost('node/add/example-node-type-1', $edit, t('Save'));
    $this->assertText(t("Example node type 1 @title has been created", array('@title' => $edit['title'])));
    $this->assertText(t('The order is for @number @color items', array('@number' => $edit['quantity'], '@color' => $edit['color'])));

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal node_example.test source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.