You are here

content_lock.test in Content locking (anti-concurrent editing) 6

Backport of Drupal 7 block.test with modifications, see BACKPORT.txt.

Copyright 2008-2009 by Jimmy Berry ("boombatower", http://drupal.org/user/214218)

File

tests/content_lock.test
View source
<?php

/**
 * @file
 * Backport of Drupal 7 block.test with modifications, see BACKPORT.txt.
 *
 * Copyright 2008-2009 by Jimmy Berry ("boombatower", http://drupal.org/user/214218)
 */
class ContentLockTestCase extends DrupalWebTestCase {

  /**
   * Implementation of getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => 'Content lock functionality',
      'description' => t('Tests locking'),
      'group' => 'Edit',
    );
  }

  /**
   * Implementation of setUp().
   */
  function setUp() {
    parent::setUp('content_lock');

    // Create and login user
    $author = $this
      ->drupalCreateUser(array(
      'check out documents',
      'edit any page content',
    ));
    $this
      ->drupalLogin($author);
  }
  function testSetupNodeForLocking() {

    // Add a new box by filling out the input form on the admin/build/block/add page.

    /*$this->drupalPost('http://dst.l/admin/content/node-type/page',array(

        ))*/
  }
  function testConcurrentEditing() {

    // TODO
  }
  function testLocking() {

    // Add a new box by filling out the input form on the admin/build/block/add page.
    $n = $this
      ->DrupalCreateNode(array(
      'type' => 'page',
    ));
    $this
      ->drupalGet('node/' . $n->nid . '/edit');
    $this
      ->assertTrue($this
      ->_checkLock($n->nid, true), 'Checking edit lock when user is editing');
  }
  function testLockingNotAllowed() {

    // Add a new box by filling out the input form on the admin/build/block/add page.
    $author = $this
      ->drupalCreateUser(array(
      'edit any page content',
    ));
    $this
      ->drupalLogin($author);
    $n = $this
      ->DrupalCreateNode(array(
      'type' => 'page',
    ));
    $this
      ->drupalGet('node/' . $n->nid . '/edit');
    $this
      ->assertTrue($this
      ->_checkLock($n->nid, false), 'Edit lock is not set, when user is editing and has no "checkout out decuments" permission');
  }
  protected function _checkLock($nid, $bool) {
    $lock = content_lock_fetch_lock($nid);
    if (is_object($lock) && $bool) {
      return true;
    }
    else {
      if ($lock === false && $bool === false) {
        return true;
      }
    }

    // else
    return true;
  }

}

Classes

Namesort descending Description
ContentLockTestCase @file Backport of Drupal 7 block.test with modifications, see BACKPORT.txt.