Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 42... Línea 42...
42
    /**
42
    /**
43
     * A contextlist_collection should support the contextlist type.
43
     * A contextlist_collection should support the contextlist type.
44
     *
44
     *
45
     * @covers ::add_contextlist
45
     * @covers ::add_contextlist
46
     */
46
     */
47
    public function test_supports_contextlist() {
47
    public function test_supports_contextlist(): void {
48
        $uit = new contextlist_collection(1);
48
        $uit = new contextlist_collection(1);
49
        $contextlist = new contextlist();
49
        $contextlist = new contextlist();
50
        $contextlist->set_component('core_privacy');
50
        $contextlist->set_component('core_privacy');
51
        $uit->add_contextlist($contextlist);
51
        $uit->add_contextlist($contextlist);
Línea 56... Línea 56...
56
    /**
56
    /**
57
     * A contextlist_collection should support the approved_contextlist type.
57
     * A contextlist_collection should support the approved_contextlist type.
58
     *
58
     *
59
     * @covers ::add_contextlist
59
     * @covers ::add_contextlist
60
     */
60
     */
61
    public function test_supports_approved_contextlist() {
61
    public function test_supports_approved_contextlist(): void {
62
        $uit = new contextlist_collection(1);
62
        $uit = new contextlist_collection(1);
63
        $testuser = \core_user::get_user_by_username('admin');
63
        $testuser = \core_user::get_user_by_username('admin');
64
        $contextids = [3, 2, 1];
64
        $contextids = [3, 2, 1];
65
        $uit->add_contextlist(new approved_contextlist($testuser, 'core_privacy', $contextids));
65
        $uit->add_contextlist(new approved_contextlist($testuser, 'core_privacy', $contextids));
Línea 70... Línea 70...
70
    /**
70
    /**
71
     * Ensure that get_contextlist_for_component returns the correct contextlist.
71
     * Ensure that get_contextlist_for_component returns the correct contextlist.
72
     *
72
     *
73
     * @covers ::get_contextlist_for_component
73
     * @covers ::get_contextlist_for_component
74
     */
74
     */
75
    public function test_get_contextlist_for_component() {
75
    public function test_get_contextlist_for_component(): void {
76
        $uit = new contextlist_collection(1);
76
        $uit = new contextlist_collection(1);
77
        $coretests = new contextlist();
77
        $coretests = new contextlist();
78
        $coretests->set_component('core_tests');
78
        $coretests->set_component('core_tests');
79
        $uit->add_contextlist($coretests);
79
        $uit->add_contextlist($coretests);
Línea 91... Línea 91...
91
    /**
91
    /**
92
     * Ensure that get_contextlist_for_component does not die horribly when querying a non-existent component.
92
     * Ensure that get_contextlist_for_component does not die horribly when querying a non-existent component.
93
     *
93
     *
94
     * @covers ::get_contextlist_for_component
94
     * @covers ::get_contextlist_for_component
95
     */
95
     */
96
    public function test_get_contextlist_for_component_not_found() {
96
    public function test_get_contextlist_for_component_not_found(): void {
97
        $uit = new contextlist_collection(1);
97
        $uit = new contextlist_collection(1);
Línea 98... Línea 98...
98
 
98
 
99
        $this->assertNull($uit->get_contextlist_for_component('core_tests'));
99
        $this->assertNull($uit->get_contextlist_for_component('core_tests'));
Línea 100... Línea 100...
100
    }
100
    }
101
 
101
 
102
    /**
102
    /**
103
     * Ensure that a duplicate contextlist in the collection throws an Exception.
103
     * Ensure that a duplicate contextlist in the collection throws an Exception.
104
     *
104
     *
105
     * @covers ::add_contextlist
105
     * @covers ::add_contextlist
106
     */
106
     */
Línea 107... Línea 107...
107
    public function test_duplicate_addition_throws() {
107
    public function test_duplicate_addition_throws(): void {
108
        $uit = new contextlist_collection(1);
108
        $uit = new contextlist_collection(1);
109
 
109
 
Línea 118... Línea 118...
118
    /**
118
    /**
119
     * Ensure that the contextlist_collection is countable.
119
     * Ensure that the contextlist_collection is countable.
120
     *
120
     *
121
     * @covers ::count
121
     * @covers ::count
122
     */
122
     */
123
    public function test_countable() {
123
    public function test_countable(): void {
124
        $uit = new contextlist_collection(1);
124
        $uit = new contextlist_collection(1);
Línea 125... Línea 125...
125
 
125
 
126
        $contextlist = new contextlist();
126
        $contextlist = new contextlist();
127
        $contextlist->set_component('test_example');
127
        $contextlist->set_component('test_example');
Línea 141... Línea 141...
141
     * @covers ::key
141
     * @covers ::key
142
     * @covers ::next
142
     * @covers ::next
143
     * @covers ::rewind
143
     * @covers ::rewind
144
     * @covers ::valid
144
     * @covers ::valid
145
     */
145
     */
146
    public function test_iteration() {
146
    public function test_iteration(): void {
147
        $uit = new contextlist_collection(1);
147
        $uit = new contextlist_collection(1);
Línea 148... Línea 148...
148
 
148
 
Línea 149... Línea 149...
149
        $testdata = [];
149
        $testdata = [];
Línea 176... Línea 176...
176
    /**
176
    /**
177
     * Test that the userid is correctly returned.
177
     * Test that the userid is correctly returned.
178
     *
178
     *
179
     * @covers ::get_userid
179
     * @covers ::get_userid
180
     */
180
     */
181
    public function test_get_userid() {
181
    public function test_get_userid(): void {
182
        $uit = new contextlist_collection(1);
182
        $uit = new contextlist_collection(1);
Línea 183... Línea 183...
183
 
183
 
184
        $this->assertEquals(1, $uit->get_userid());
184
        $this->assertEquals(1, $uit->get_userid());
Línea 185... Línea 185...
185
    }
185
    }
186
 
186
 
187
    /**
187
    /**
188
     * Test that an exception is thrown if a contextlist does not contain a component.
188
     * Test that an exception is thrown if a contextlist does not contain a component.
189
     */
189
     */
Línea 190... Línea 190...
190
    public function test_add_without_component() {
190
    public function test_add_without_component(): void {
191
        $uit = new contextlist_collection(1);
191
        $uit = new contextlist_collection(1);
192
 
192