class BoxesTestCase

  1. nittany7 modules/contrib/boxes/tests/boxes.test BoxesTestCase
  2. cis7 modules/contrib/boxes/tests/boxes.test BoxesTestCase
  3. mooc7 modules/contrib/boxes/tests/boxes.test BoxesTestCase

Hierarchy

Expanded class hierarchy of BoxesTestCase

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
BoxesTestCase::$profile protected property
BoxesTestCase::getInfo public static function Implementation of getInfo().
BoxesTestCase::setUp function Implementation of setUp().
BoxesTestCase::testBoxes function Test creating and deleting a box.

File

modules/contrib/boxes/tests/boxes.test, line 3

View source
class BoxesTestCase extends DrupalWebTestCase {
  protected $profile = 'testing';

  /**
   * Implementation of getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => t('Boxes functionality'),
      'description' => t('Add and delete custom boxes.'),
      'group' => t('Boxes'),
    );
  }

  /**
   * Implementation of setUp().
   */
  function setUp() {
    parent::setUp(array('comment', 'ctools', 'block', 'boxes'));

    // Create and login user
    $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer boxes'));
    $this->drupalLogin($admin_user);
  }

  /**
   * Test creating and deleting a box.
   */
  function testBoxes() {

    // Add a new box by filling out the input form on the admin/build/block/add page.
    $box = array();
    $box['description'] = $this->randomName(8);
    $box['title'] = $this->randomName(8);
    $box['body[value]'] = $this->randomName(32);
    $box['delta'] = strtolower($this->randomName(16));
    $this->drupalPost('admin/structure/block/box-add/simple', $box, t('Save'));

    // Confirm that the box has been created, and then query the created bid.
    $this->assertText(t('@description has been created.', array('@description' => $box['description'])), t('Box successfully created.'));
    $delta = db_query("select delta from {box} where delta = :delta", array('delta' => $box['delta']))->fetchField();
    $this->assertNotNull($delta, t('box found in database'));

    // Delete the created box & verify that it's been deleted and no longer appearing on the page.
    $this->drupalPost('admin/structure/block/manage/boxes/' . $delta . '/delete/', array(), t('Delete'));
    // TODO check confirmation message ...of course we'd need to show one first.
    $delta = db_query("select delta from {box} where delta = :delta", array('delta' => $box['delta']))->fetchField();
    $this->assertFalse($delta, t('box not found in database'));
  }

}