[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/tests/ -> outputrequirementslib_test.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Unit tests for lib/outputrequirementslibphp.
  19   *
  20   * @package   core
  21   * @category  phpunit
  22   * @copyright 2012 Petr Škoda
  23   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  global $CFG;
  29  require_once($CFG->libdir . '/outputrequirementslib.php');
  30  
  31  
  32  class core_outputrequirementslib_testcase extends advanced_testcase {
  33      public function test_string_for_js() {
  34          $this->resetAfterTest();
  35  
  36          $page = new moodle_page();
  37          $page->requires->string_for_js('course', 'moodle', 1);
  38          $page->requires->string_for_js('course', 'moodle', 1);
  39          $this->setExpectedException('coding_exception');
  40          $page->requires->string_for_js('course', 'moodle', 2);
  41  
  42          // Note: we can not switch languages in phpunit yet,
  43          //       it would be nice to test that the strings are actually fetched in the footer.
  44      }
  45  
  46      public function test_one_time_output_normal_case() {
  47          $page = new moodle_page();
  48          $this->assertTrue($page->requires->should_create_one_time_item_now('test_item'));
  49          $this->assertFalse($page->requires->should_create_one_time_item_now('test_item'));
  50      }
  51  
  52      public function test_one_time_output_repeat_output_throws() {
  53          $page = new moodle_page();
  54          $page->requires->set_one_time_item_created('test_item');
  55          $this->setExpectedException('coding_exception');
  56          $page->requires->set_one_time_item_created('test_item');
  57      }
  58  
  59      public function test_one_time_output_different_pages_independent() {
  60          $firstpage = new moodle_page();
  61          $secondpage = new moodle_page();
  62          $this->assertTrue($firstpage->requires->should_create_one_time_item_now('test_item'));
  63          $this->assertTrue($secondpage->requires->should_create_one_time_item_now('test_item'));
  64      }
  65  
  66  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1