2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * PHPUnit integration tests
22 * @copyright 2012 Petr Skoda {@link http://skodak.org}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') || die();
34 * @copyright 2012 Petr Skoda {@link http://skodak.org}
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 class core_phpunit_generator_testcase extends advanced_testcase {
38 public function test_create() {
41 $this->resetAfterTest(true);
42 $generator = $this->getDataGenerator();
44 $count = $DB->count_records('user');
45 $user = $generator->create_user();
46 $this->assertEquals($count+1, $DB->count_records('user'));
48 $count = $DB->count_records('course_categories');
49 $category = $generator->create_category();
50 $this->assertEquals($count+1, $DB->count_records('course_categories'));
52 $count = $DB->count_records('course');
53 $course = $generator->create_course();
54 $this->assertEquals($count+1, $DB->count_records('course'));
56 $section = $generator->create_course_section(array('course'=>$course->id, 'section'=>3));
57 $this->assertEquals($course->id, $section->course);
59 $scale = $generator->create_scale();
60 $this->assertNotEmpty($scale);
63 public function test_create_module() {
65 if (!file_exists("$CFG->dirroot/mod/page/")) {
66 $this->markTestSkipped('Can not find standard Page module');
69 $this->resetAfterTest(true);
70 $generator = $this->getDataGenerator();
72 $page = $generator->create_module('page', array('course'=>$SITE->id));
73 $this->assertNotEmpty($page);
76 public function test_create_block() {
78 if (!file_exists("$CFG->dirroot/blocks/online_users/")) {
79 $this->markTestSkipped('Can not find standard Online users block');
82 $this->resetAfterTest(true);
83 $generator = $this->getDataGenerator();
85 $page = $generator->create_block('online_users');
86 $this->assertNotEmpty($page);