MDL-21009 Group selector must use absolute links in order to work with javascript off
[moodle.git] / blog / simpletest / testbloglib.php
CommitLineData
cae83708 1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18
19/**
20 * Unit tests for blog
21 *
22 * @package moodlecore
23 * @subpackage blog
24 * @copyright 2009 Nicolas Connault
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 */
27
28require_once($CFG->dirroot . '/blog/locallib.php');
29
30class bloglib_test extends UnitTestCaseUsingDatabase {
31
32 public static $includecoverage = array('blog/locallib.php');
33
34 public function test_overrides() {
1c7b8b93 35
cae83708 36 // Try all the filters at once: Only the entry filter is active
37 $blog_listing = new blog_listing(array('site' => 1, 'course' => 1, 'module' => 1, 'group' => 1, 'user' => 1, 'tag' => 1, 'entry' => 1));
38 $this->assertFalse(array_key_exists('site', $blog_listing->filters));
39 $this->assertFalse(array_key_exists('course', $blog_listing->filters));
40 $this->assertFalse(array_key_exists('module', $blog_listing->filters));
41 $this->assertFalse(array_key_exists('group', $blog_listing->filters));
42 $this->assertFalse(array_key_exists('user', $blog_listing->filters));
43 $this->assertFalse(array_key_exists('tag', $blog_listing->filters));
44 $this->assertTrue(array_key_exists('entry', $blog_listing->filters));
45
46 // Again, but without the entry filter: This time, the tag, user and module filters are active
47 $blog_listing = new blog_listing(array('site' => 1, 'course' => 1, 'module' => 1, 'group' => 1, 'user' => 1, 'tag' => 1));
48 $this->assertFalse(array_key_exists('site', $blog_listing->filters));
49 $this->assertFalse(array_key_exists('course', $blog_listing->filters));
50 $this->assertFalse(array_key_exists('group', $blog_listing->filters));
51 $this->assertTrue(array_key_exists('module', $blog_listing->filters));
52 $this->assertTrue(array_key_exists('user', $blog_listing->filters));
53 $this->assertTrue(array_key_exists('tag', $blog_listing->filters));
54
55 // We should get the same result by removing the 3 inactive filters: site, course and group:
56 $blog_listing = new blog_listing(array('module' => 1, 'user' => 1, 'tag' => 1));
57 $this->assertFalse(array_key_exists('site', $blog_listing->filters));
58 $this->assertFalse(array_key_exists('course', $blog_listing->filters));
59 $this->assertFalse(array_key_exists('group', $blog_listing->filters));
60 $this->assertTrue(array_key_exists('module', $blog_listing->filters));
61 $this->assertTrue(array_key_exists('user', $blog_listing->filters));
62 $this->assertTrue(array_key_exists('tag', $blog_listing->filters));
63
cae83708 64 }
65
66 /**
67 * Some user, course, module, group and blog sample data needs to be setup for this test
68 */
69 public function test_blog_get_headers_case_1() {
70 global $CFG, $PAGE, $OUTPUT;
cae83708 71 $PAGE->url = new moodle_url($CFG->wwwroot . '/blog/index.php', array('entryid' => 1));
72 $blog_headers = blog_get_headers();
73
74 $this->assertEqual($blog_headers['title'], '');
75 }
76}