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

Drupal example source code file (link.base-test.inc)

This example Drupal source code file (link.base-test.inc) 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

access, administer, array, comments, content, fields, function, link_field, modules, name, node_type, php, public, settings

The link.base-test.inc Drupal example source code

<?php

/**
 * @file
 * Link base test file - contains common functions for testing links.
 */

class LinkBaseTestClass extends DrupalWebTestCase {
  public $permissions = array(
    'access content',
    'administer content types',
    'administer nodes',
    'administer filters',
    'access comments',
    'post comments',
    'access administration pages',
    'create page content',
  );
  
  public $account;
  
  function setUp($modules = array()) {
    if ($modules) {
      parent::setUp($modules);
    }
    else {
      parent::setUp('field_ui', 'link');
    }
    $this->account = $this->drupalCreateUser($this->permissions);
    $this->drupalLogin($this->account);
  }
  
  function createLinkField($node_type = 'page',
                           $settings = array()) {
    $name = strtolower($this->randomName());
    $edit = array(
      'fields[_add_new_field][label]' => $name,
      'fields[_add_new_field][field_name]' => $name,
      'fields[_add_new_field][type]' => 'link_field',
      'fields[_add_new_field][widget_type]' => 'link_field',
    );
    $field_name = 'field_'. $name;
    $this->drupalPost('admin/structure/types/manage/'. $node_type .'/fields', $edit, t('Save'));
    $this->drupalPost(NULL, array(), t('Save field settings'));
    $this->drupalPost(NULL, $settings, t('Save settings'));

    // Is field created?
    $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
    node_types_rebuild();
    menu_rebuild();
    
    return $field_name;
  }
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal link.base-test.inc source code file:

new blog posts

 


"Drupal" is a registered trademark of Dries Buytaert.

our drupal tutorials and examples  
 

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