[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/lib/simpletest/ -> testaccesslib.php (source)

   1  <?php
   2  /**
   3   * Unit tests for (some of) ../accesslib.php.
   4   *
   5   * @copyright &copy; 2006 The Open University
   6   * @author T.J.Hunt@open.ac.uk
   7   * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
   8   * @package moodlecore
   9   */
  10  
  11  if (!defined('MOODLE_INTERNAL')) {
  12      die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
  13  }
  14  
  15  class accesslib_test extends UnitTestCase {
  16  
  17      function setUp() {
  18      }
  19  
  20      function tearDown() {
  21      }
  22  
  23      function test_get_parent_contexts() {
  24          $context = get_context_instance(CONTEXT_SYSTEM);
  25          $this->assertEqual(get_parent_contexts($context), array());
  26  
  27          $context = new stdClass;
  28          $context->path = '/1/25';
  29          $this->assertEqual(get_parent_contexts($context), array(1));
  30  
  31          $context = new stdClass;
  32          $context->path = '/1/123/234/345/456';
  33          $this->assertEqual(get_parent_contexts($context), array(345, 234, 123, 1));
  34      }
  35  
  36      function test_get_parent_contextid() {
  37          $context = get_context_instance(CONTEXT_SYSTEM);
  38          $this->assertFalse(get_parent_contextid($context));
  39  
  40          $context = new stdClass;
  41          $context->path = '/1/25';
  42          $this->assertEqual(get_parent_contextid($context), 1);
  43  
  44          $context = new stdClass;
  45          $context->path = '/1/123/234/345/456';
  46          $this->assertEqual(get_parent_contextid($context), 345);
  47      }
  48  }
  49  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7