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

Drupal example source code file (upgrade.filter.test)

This example Drupal source code file (upgrade.filter.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, block, delta, filter, format, function, machine, name, php, test_filter, upgrade, user, with

The upgrade.filter.test Drupal example source code

<?php
// $Id: upgrade.filter.test,v 1.1 2010/11/09 17:43:10 webchick Exp $

/**
 * Upgrade test for filter format identifiers.
 *
 * Filter format identifiers changed from sequential ids to machine names.
 * Verify that filter formats and references to filter formats in core are
 * converted properly.
 */
class FilterFormatUpgradePathTestCase extends UpgradePathTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Filter format upgrade path',
      'description' => 'Verifies that filter formats and references to filter formats are converted properly.',
      'group' => 'Upgrade path',
    );
  }

  function setUp() {
    // Path to the database dump.
    $this->databaseDumpFiles = array(
      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.filled.database.php',
    );
    parent::setUp();
  }

  /**
   * Test a successful upgrade.
   */
  function testFilterFormatUpgrade() {
    $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));

    $format = filter_format_load('1');
    $this->assertTrue($format->format == '1', t('Filter format found.'));
    $format->format = 'test_filter';
    $format->name = 'Test filter';
    filter_format_save($format);
    $format = filter_format_load('test_filter');
    $this->assertTrue($format->format == 'test_filter', t('Saved a filter format with machine name.'));

    $account = user_load(4);
    user_save($account, array('signature_format' => 'test_filter'));
    $account = user_load(4);
    $this->assertTrue($account->signature_format == 'test_filter', t('Signature format changed successfully to a filter format with machine name.'));

    $delta = db_insert('block_custom')
      ->fields(array(
        'body' => 'Test block',
        'info' => 'Test block',
        'format' => 'test_filter',
      ))
      ->execute();
    $this->assertTrue($delta > 0, t('Created a custom block using a filter format with machine name.'));
  }
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal upgrade.filter.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.