Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 31... Línea 31...
31
    }
31
    }
Línea 32... Línea 32...
32
 
32
 
33
    /**
33
    /**
34
     * Tests constructing a tree with errors.
34
     * Tests constructing a tree with errors.
35
     */
35
     */
36
    public function test_construct_errors() {
36
    public function test_construct_errors(): void {
37
        try {
37
        try {
38
            new tree('frog');
38
            new tree('frog');
39
            $this->fail();
39
            $this->fail();
40
        } catch (\coding_exception $e) {
40
        } catch (\coding_exception $e) {
Línea 128... Línea 128...
128
    }
128
    }
Línea 129... Línea 129...
129
 
129
 
130
    /**
130
    /**
131
     * Tests constructing a tree with plugin that does not exist (ignored).
131
     * Tests constructing a tree with plugin that does not exist (ignored).
132
     */
132
     */
133
    public function test_construct_ignore_missing_plugin() {
133
    public function test_construct_ignore_missing_plugin(): void {
134
        // Construct a tree with & combination of one condition that doesn't exist.
134
        // Construct a tree with & combination of one condition that doesn't exist.
135
        $tree = new tree(tree::get_root_json(array(
135
        $tree = new tree(tree::get_root_json(array(
136
                (object)array('type' => 'doesnotexist')), tree::OP_OR), true);
136
                (object)array('type' => 'doesnotexist')), tree::OP_OR), true);
137
        // Expected result is an empty tree with | condition, shown.
137
        // Expected result is an empty tree with | condition, shown.
138
        $this->assertEquals('+|()', (string)$tree);
138
        $this->assertEquals('+|()', (string)$tree);
Línea 139... Línea 139...
139
    }
139
    }
140
 
140
 
141
    /**
141
    /**
142
     * Tests constructing a tree with subtrees using all available operators.
142
     * Tests constructing a tree with subtrees using all available operators.
143
     */
143
     */
144
    public function test_construct_just_trees() {
144
    public function test_construct_just_trees(): void {
145
        $structure = tree::get_root_json(array(
145
        $structure = tree::get_root_json(array(
146
                tree::get_nested_json(array(), tree::OP_OR),
146
                tree::get_nested_json(array(), tree::OP_OR),
147
                tree::get_nested_json(array(
147
                tree::get_nested_json(array(
Línea 152... Línea 152...
152
    }
152
    }
Línea 153... Línea 153...
153
 
153
 
154
    /**
154
    /**
155
     * Tests constructing tree using the mock plugin.
155
     * Tests constructing tree using the mock plugin.
156
     */
156
     */
157
    public function test_construct_with_mock_plugin() {
157
    public function test_construct_with_mock_plugin(): void {
158
        $structure = tree::get_root_json(array(
158
        $structure = tree::get_root_json(array(
159
                self::mock(array('a' => true, 'm' => ''))), tree::OP_OR);
159
                self::mock(array('a' => true, 'm' => ''))), tree::OP_OR);
160
        $tree = new tree($structure);
160
        $tree = new tree($structure);
161
        $this->assertEquals('+|({mock:y,})', (string)$tree);
161
        $this->assertEquals('+|({mock:y,})', (string)$tree);
Línea 162... Línea 162...
162
    }
162
    }
163
 
163
 
164
    /**
164
    /**
165
     * Tests the check_available and get_result_information functions.
165
     * Tests the check_available and get_result_information functions.
166
     */
166
     */
Línea 167... Línea 167...
167
    public function test_check_available() {
167
    public function test_check_available(): void {
168
        global $USER;
168
        global $USER;
169
 
169
 
Línea 357... Línea 357...
357
    }
357
    }
Línea 358... Línea 358...
358
 
358
 
359
    /**
359
    /**
360
     * Tests the is_available_for_all() function.
360
     * Tests the is_available_for_all() function.
361
     */
361
     */
362
    public function test_is_available_for_all() {
362
    public function test_is_available_for_all(): void {
363
        // Empty tree is always available.
363
        // Empty tree is always available.
364
        $structure = tree::get_root_json(array(), tree::OP_OR);
364
        $structure = tree::get_root_json(array(), tree::OP_OR);
365
        $tree = new tree($structure);
365
        $tree = new tree($structure);
Línea 396... Línea 396...
396
    }
396
    }
Línea 397... Línea 397...
397
 
397
 
398
    /**
398
    /**
399
     * Tests the get_full_information() function.
399
     * Tests the get_full_information() function.
400
     */
400
     */
401
    public function test_get_full_information() {
401
    public function test_get_full_information(): void {
402
        global $PAGE;
402
        global $PAGE;
403
        // Setup.
403
        // Setup.
Línea 404... Línea 404...
404
        $info = new \core_availability\mock_info();
404
        $info = new \core_availability\mock_info();
Línea 495... Línea 495...
495
    }
495
    }
Línea 496... Línea 496...
496
 
496
 
497
    /**
497
    /**
498
     * Tests the is_empty() function.
498
     * Tests the is_empty() function.
499
     */
499
     */
500
    public function test_is_empty() {
500
    public function test_is_empty(): void {
501
        // Tree with nothing in should be empty.
501
        // Tree with nothing in should be empty.
502
        $structure = tree::get_root_json(array(), tree::OP_OR);
502
        $structure = tree::get_root_json(array(), tree::OP_OR);
503
        $tree = new tree($structure);
503
        $tree = new tree($structure);
Línea 510... Línea 510...
510
    }
510
    }
Línea 511... Línea 511...
511
 
511
 
512
    /**
512
    /**
513
     * Tests the get_all_children() function.
513
     * Tests the get_all_children() function.
514
     */
514
     */
515
    public function test_get_all_children() {
515
    public function test_get_all_children(): void {
516
        // Create a tree with nothing in.
516
        // Create a tree with nothing in.
517
        $structure = tree::get_root_json(array(), tree::OP_OR);
517
        $structure = tree::get_root_json(array(), tree::OP_OR);
Línea 518... Línea 518...
518
        $tree1 = new tree($structure);
518
        $tree1 = new tree($structure);
Línea 540... Línea 540...
540
    }
540
    }
Línea 541... Línea 541...
541
 
541
 
542
    /**
542
    /**
543
     * Tests the update_dependency_id() function.
543
     * Tests the update_dependency_id() function.
544
     */
544
     */
545
    public function test_update_dependency_id() {
545
    public function test_update_dependency_id(): void {
546
        // Create tree with structure of 3 mocks.
546
        // Create tree with structure of 3 mocks.
547
        $structure = tree::get_root_json(array(
547
        $structure = tree::get_root_json(array(
548
                tree::get_nested_json(array(
548
                tree::get_nested_json(array(
549
                    self::mock(array('table' => 'frogs', 'id' => 9)),
549
                    self::mock(array('table' => 'frogs', 'id' => 9)),
Línea 573... Línea 573...
573
    }
573
    }
Línea 574... Línea 574...
574
 
574
 
575
    /**
575
    /**
576
     * Tests the filter_users function.
576
     * Tests the filter_users function.
577
     */
577
     */
578
    public function test_filter_users() {
578
    public function test_filter_users(): void {
579
        $info = new \core_availability\mock_info();
579
        $info = new \core_availability\mock_info();
Línea 580... Línea 580...
580
        $checker = new capability_checker($info->get_context());
580
        $checker = new capability_checker($info->get_context());
581
 
581
 
Línea 635... Línea 635...
635
 
635
 
636
    /**
636
    /**
637
     * Tests the get_json methods in tree (which are mainly for use in testing
637
     * Tests the get_json methods in tree (which are mainly for use in testing
638
     * but might be used elsewhere).
638
     * but might be used elsewhere).
639
     */
639
     */
640
    public function test_get_json() {
640
    public function test_get_json(): void {
641
        // Create a simple child object (fake).
641
        // Create a simple child object (fake).
642
        $child = (object)array('type' => 'fake');
642
        $child = (object)array('type' => 'fake');
Línea 643... Línea 643...
643
        $childstr = json_encode($child);
643
        $childstr = json_encode($child);
Línea 683... Línea 683...
683
     * To minimise risk of false expected behaviour, this test method should be
683
     * To minimise risk of false expected behaviour, this test method should be
684
     * first one where {@link core_availability\tree::get_user_list_sql()} is
684
     * first one where {@link core_availability\tree::get_user_list_sql()} is
685
     * used. We also use higher number of condition instances to increase the
685
     * used. We also use higher number of condition instances to increase the
686
     * risk of the counter collision, should there remain a problem.
686
     * risk of the counter collision, should there remain a problem.
687
     */
687
     */
688
    public function test_unique_sql_parameter_behaviour() {
688
    public function test_unique_sql_parameter_behaviour(): void {
689
        global $DB;
689
        global $DB;
690
        $this->resetAfterTest();
690
        $this->resetAfterTest();
691
        $generator = $this->getDataGenerator();
691
        $generator = $this->getDataGenerator();
Línea 692... Línea 692...
692
 
692
 
Línea 730... Línea 730...
730
    }
730
    }
Línea 731... Línea 731...
731
 
731
 
732
    /**
732
    /**
733
     * Tests get_user_list_sql.
733
     * Tests get_user_list_sql.
734
     */
734
     */
735
    public function test_get_user_list_sql() {
735
    public function test_get_user_list_sql(): void {
736
        global $DB;
736
        global $DB;
737
        $this->resetAfterTest();
737
        $this->resetAfterTest();
Línea 738... Línea 738...
738
        $generator = $this->getDataGenerator();
738
        $generator = $this->getDataGenerator();