Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea 17...
17
declare(strict_types=1);
17
declare(strict_types=1);
Línea 18... Línea 18...
18
 
18
 
19
namespace core_cohort\reportbuilder\datasource;
-
 
20
 
19
namespace core_cohort\reportbuilder\datasource;
21
use context_coursecat;
20
 
22
use context_system;
-
 
23
use core_customfield_generator;
21
use core\context\{coursecat, system};
24
use core_reportbuilder_generator;
-
 
25
use core_reportbuilder_testcase;
-
 
26
use core_reportbuilder\local\filters\{boolean_select, date, select, text};
-
 
27
 
-
 
28
defined('MOODLE_INTERNAL') || die();
22
use core_customfield_generator;
Línea 29... Línea 23...
29
 
23
use core_reportbuilder_generator;
30
global $CFG;
24
use core_reportbuilder\local\filters\{boolean_select, date, select, text};
31
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
25
use core_reportbuilder\tests\core_reportbuilder_testcase;
32
 
26
 
33
/**
27
/**
34
 * Unit tests for cohorts datasource
28
 * Unit tests for cohorts datasource
35
 *
29
 *
36
 * @package     core_cohort
30
 * @package     core_cohort
37
 * @covers      \core_cohort\reportbuilder\datasource\cohorts
31
 * @covers      \core_cohort\reportbuilder\datasource\cohorts
Línea 38... Línea 32...
38
 * @copyright   2021 Paul Holden <paulh@moodle.com>
32
 * @copyright   2021 Paul Holden <paulh@moodle.com>
39
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40
 */
34
 */
41
class cohorts_test extends core_reportbuilder_testcase {
35
final class cohorts_test extends core_reportbuilder_testcase {
42
 
36
 
Línea 43... Línea 37...
43
    /**
37
    /**
44
     * Test default datasource
38
     * Test default datasource
45
     */
39
     */
46
    public function test_datasource_default(): void {
40
    public function test_datasource_default(): void {
47
        $this->resetAfterTest();
41
        $this->resetAfterTest();
48
 
42
 
49
        // Test subject.
43
        // Test subject.
50
        $contextsystem = context_system::instance();
44
        $contextsystem = system::instance();
Línea 51... Línea 45...
51
        $cohortone = $this->getDataGenerator()->create_cohort([
45
        $cohortone = $this->getDataGenerator()->create_cohort([
52
            'contextid' => $contextsystem->id,
46
            'contextid' => $contextsystem->id,
53
            'name' => 'Legends',
47
            'name' => 'Legends',
54
            'idnumber' => 'C101',
48
            'idnumber' => 'C101',
55
            'description' => 'Cohort for the legends',
49
            'description' => 'Cohort for the legends',
56
        ]);
50
        ]);
57
 
51
 
Línea 143... Línea 137...
143
    /**
137
    /**
144
     * Data provider for {@see test_datasource_filters}
138
     * Data provider for {@see test_datasource_filters}
145
     *
139
     *
146
     * @return array[]
140
     * @return array[]
147
     */
141
     */
148
    public function datasource_filters_provider(): array {
142
    public static function datasource_filters_provider(): array {
149
        return [
143
        return [
150
            // Cohort.
144
            // Cohort.
151
            'Filter cohort' => ['cohort:cohortselect', [
145
            'Filter cohort' => ['cohort:cohortselect', [
152
                'cohort:cohortselect_values' => [-1],
146
                'cohort:cohortselect_values' => [-1],
153
            ], false],
147
            ], false],
154
            'Filter context' => ['cohort:context', [
148
            'Filter context' => ['cohort:context', [
155
                'cohort:context_operator' => select::EQUAL_TO,
149
                'cohort:context_operator' => select::EQUAL_TO,
156
                'cohort:context_value' => context_system::instance()->id,
150
                'cohort:context_value' => system::instance()->id,
157
            ], true],
151
            ], true],
158
            'Filter content (no match)' => ['cohort:context', [
152
            'Filter context (no match)' => ['cohort:context', [
159
                'cohort:context_operator' => select::EQUAL_TO,
153
                'cohort:context_operator' => select::NOT_EQUAL_TO,
160
                'cohort:context_value' => -1,
154
                'cohort:context_value' => system::instance()->id,
161
            ], false],
155
            ], false],
162
            'Filter name' => ['cohort:name', [
156
            'Filter name' => ['cohort:name', [
163
                'cohort:name_operator' => text::IS_EQUAL_TO,
157
                'cohort:name_operator' => text::IS_EQUAL_TO,
164
                'cohort:name_value' => 'Legends',
158
                'cohort:name_value' => 'Legends',
165
            ], true],
159
            ], true],