Merge branch 'MDL-62448-master' of git://github.com/sarjona/moodle
[moodle.git] / calendar / tests / action_test.php
blobcc4dd6a3ccdd06273605ba50f0449d68d5877b87
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.
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/>.
17 /**
18 * Action tests.
20 * @package core_calendar
21 * @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
27 use core_calendar\local\event\value_objects\action;
29 /**
30 * Action testcase.
32 * @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 class core_calendar_action_testcase extends advanced_testcase {
36 /**
37 * Test action class getters.
39 * @dataProvider getters_testcases()
40 * @param array $constructorparams Associative array of constructor parameters.
42 public function test_getters($constructorparams) {
43 $action = new action(
44 $constructorparams['name'],
45 $constructorparams['url'],
46 $constructorparams['item_count'],
47 $constructorparams['actionable']
50 foreach ($constructorparams as $name => $value) {
51 if ($name == 'actionable') {
52 $this->assertEquals($action->is_actionable(), $value);
53 } else {
54 $this->assertEquals($action->{'get_' . $name}(), $value);
59 /**
60 * Test cases for getters test.
62 public function getters_testcases() {
63 return [
64 'Dataset 1' => [
65 'constructorparams' => [
66 'name' => 'Hello',
67 'url' => new moodle_url('http://example.com'),
68 'item_count' => 1,
69 'actionable' => true
72 'Dataset 2' => [
73 'constructorparams' => [
74 'name' => 'Goodbye',
75 'url' => new moodle_url('http://example.com'),
76 'item_count' => 2,
77 'actionable' => false