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
class user_test extends \advanced_testcase {
31
class user_test extends \advanced_testcase {
32
    /**
32
    /**
33
     * Tests legacy class.
33
     * Tests legacy class.
34
     * @coversNothing
34
     * @coversNothing
35
     */
35
     */
36
    public function test_legacy_classname() {
36
    public function test_legacy_classname(): void {
37
        $admin = get_admin();
37
        $admin = get_admin();
38
        $context = \context_user::instance($admin->id);
38
        $context = \context_user::instance($admin->id);
39
        $this->assertInstanceOf(user::class, $context);
39
        $this->assertInstanceOf(user::class, $context);
40
        $this->assertInstanceOf(\context_user::class, $context);
40
        $this->assertInstanceOf(\context_user::class, $context);
41
    }
41
    }
Línea 43... Línea 43...
43
    /**
43
    /**
44
     * Tests covered methods.
44
     * Tests covered methods.
45
     * @covers ::instance
45
     * @covers ::instance
46
     * @covers \core\context::instance_by_id
46
     * @covers \core\context::instance_by_id
47
     */
47
     */
48
    public function test_factory_methods() {
48
    public function test_factory_methods(): void {
49
        $admin = get_admin();
49
        $admin = get_admin();
50
        $context = user::instance($admin->id);
50
        $context = user::instance($admin->id);
51
        $this->assertInstanceOf(user::class, $context);
51
        $this->assertInstanceOf(user::class, $context);
52
        $this->assertSame($admin->id, $context->instanceid);
52
        $this->assertSame($admin->id, $context->instanceid);
Línea 58... Línea 58...
58
 
58
 
59
    /**
59
    /**
60
     * Tests covered method.
60
     * Tests covered method.
61
     * @covers ::get_short_name
61
     * @covers ::get_short_name
62
     */
62
     */
63
    public function test_get_short_name() {
63
    public function test_get_short_name(): void {
64
        $this->assertSame('user', user::get_short_name());
64
        $this->assertSame('user', user::get_short_name());
Línea 65... Línea 65...
65
    }
65
    }
66
 
66
 
67
    /**
67
    /**
68
     * Tests context level.
68
     * Tests context level.
69
     * @coversNothing
69
     * @coversNothing
70
     */
70
     */
71
    public function test_level() {
71
    public function test_level(): void {
72
        $this->assertSame(30, user::LEVEL);
72
        $this->assertSame(30, user::LEVEL);
Línea 73... Línea 73...
73
        $this->assertSame(CONTEXT_USER, user::LEVEL);
73
        $this->assertSame(CONTEXT_USER, user::LEVEL);
74
    }
74
    }
75
 
75
 
76
    /**
76
    /**
77
     * Tests covered method.
77
     * Tests covered method.
78
     * @covers ::get_level_name
78
     * @covers ::get_level_name
79
     */
79
     */
Línea 80... Línea 80...
80
    public function test_get_level_name() {
80
    public function test_get_level_name(): void {
81
        $this->assertSame('User', user::get_level_name());
81
        $this->assertSame('User', user::get_level_name());
82
    }
82
    }
83
 
83
 
84
    /**
84
    /**
85
     * Tests covered method.
85
     * Tests covered method.
86
     * @covers ::get_context_name
86
     * @covers ::get_context_name
87
     */
87
     */
88
    public function test_get_context_name() {
88
    public function test_get_context_name(): void {
89
        $admin = get_admin();
89
        $admin = get_admin();
Línea 97... Línea 97...
97
 
97
 
98
    /**
98
    /**
99
     * Tests covered method.
99
     * Tests covered method.
100
     * @covers ::get_url
100
     * @covers ::get_url
101
     */
101
     */
102
    public function test_get_url() {
102
    public function test_get_url(): void {
103
        $admin = get_admin();
103
        $admin = get_admin();
104
        $context = user::instance($admin->id);
104
        $context = user::instance($admin->id);
105
        $expected = new \moodle_url('/user/profile.php', ['id' => $admin->id]);
105
        $expected = new \moodle_url('/user/profile.php', ['id' => $admin->id]);
106
        $url = $context->get_url();
106
        $url = $context->get_url();
Línea 112... Línea 112...
112
     * Tests covered methods.
112
     * Tests covered methods.
113
     * @covers ::get_instance_table()
113
     * @covers ::get_instance_table()
114
     * @covers ::get_behat_reference_columns()
114
     * @covers ::get_behat_reference_columns()
115
     * @covers \core\context_helper::resolve_behat_reference
115
     * @covers \core\context_helper::resolve_behat_reference
116
     */
116
     */
117
    public function test_resolve_behat_reference() {
117
    public function test_resolve_behat_reference(): void {
118
        $this->resetAfterTest();
118
        $this->resetAfterTest();
Línea 119... Línea 119...
119
 
119
 
120
        $instance = $this->getDataGenerator()->create_user();
120
        $instance = $this->getDataGenerator()->create_user();
Línea 138... Línea 138...
138
 
138
 
139
    /**
139
    /**
140
     * Tests covered method.
140
     * Tests covered method.
141
     * @covers ::get_compatible_role_archetypes
141
     * @covers ::get_compatible_role_archetypes
142
     */
142
     */
143
    public function test_get_compatible_role_archetypes() {
143
    public function test_get_compatible_role_archetypes(): void {
Línea 144... Línea 144...
144
        global $DB;
144
        global $DB;
145
 
145
 
146
        $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL');
146
        $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL');
Línea 152... Línea 152...
152
 
152
 
153
    /**
153
    /**
154
     * Tests covered method.
154
     * Tests covered method.
155
     * @covers ::get_possible_parent_levels
155
     * @covers ::get_possible_parent_levels
156
     */
156
     */
157
    public function test_get_possible_parent_levels() {
157
    public function test_get_possible_parent_levels(): void {
158
        $this->assertSame([system::LEVEL], user::get_possible_parent_levels());
158
        $this->assertSame([system::LEVEL], user::get_possible_parent_levels());
Línea 159... Línea 159...
159
    }
159
    }
160
 
160
 
161
    /**
161
    /**
162
     * Tests covered method.
162
     * Tests covered method.
163
     * @covers ::get_capabilities
163
     * @covers ::get_capabilities
164
     */
164
     */
Línea 165... Línea 165...
165
    public function test_get_capabilities() {
165
    public function test_get_capabilities(): void {
166
        $admin = get_admin();
166
        $admin = get_admin();
167
 
167
 
Línea 178... Línea 178...
178
 
178
 
179
    /**
179
    /**
180
     * Tests covered method.
180
     * Tests covered method.
181
     * @covers ::create_level_instances
181
     * @covers ::create_level_instances
182
     */
182
     */
183
    public function test_create_level_instances() {
183
    public function test_create_level_instances(): void {
184
        global $DB;
184
        global $DB;
Línea 185... Línea 185...
185
        $this->resetAfterTest();
185
        $this->resetAfterTest();
186
 
186
 
Línea 194... Línea 194...
194
 
194
 
195
    /**
195
    /**
196
     * Tests covered method.
196
     * Tests covered method.
197
     * @covers ::get_child_contexts
197
     * @covers ::get_child_contexts
198
     */
198
     */
199
    public function test_get_child_contexts() {
199
    public function test_get_child_contexts(): void {
Línea 200... Línea 200...
200
        $admin = get_admin();
200
        $admin = get_admin();
201
 
201
 
202
        $context = user::instance($admin->id);
202
        $context = user::instance($admin->id);
Línea 206... Línea 206...
206
 
206
 
207
    /**
207
    /**
208
     * Tests covered method.
208
     * Tests covered method.
209
     * @covers ::get_cleanup_sql
209
     * @covers ::get_cleanup_sql
210
     */
210
     */
211
    public function test_get_cleanup_sql() {
211
    public function test_get_cleanup_sql(): void {
212
        global $DB;
212
        global $DB;
Línea 213... Línea 213...
213
        $this->resetAfterTest();
213
        $this->resetAfterTest();
214
 
214
 
Línea 223... Línea 223...
223
 
223
 
224
    /**
224
    /**
225
     * Tests covered method.
225
     * Tests covered method.
226
     * @covers ::build_paths
226
     * @covers ::build_paths
227
     */
227
     */
228
    public function test_build_paths() {
228
    public function test_build_paths(): void {
229
        global $DB;
229
        global $DB;
Línea 230... Línea 230...
230
        $this->resetAfterTest();
230
        $this->resetAfterTest();
231
 
231
 
Línea 245... Línea 245...
245
 
245
 
246
    /**
246
    /**
247
     * Tests covered method.
247
     * Tests covered method.
248
     * @covers ::set_locked
248
     * @covers ::set_locked
249
     */
249
     */
250
    public function test_set_locked() {
250
    public function test_set_locked(): void {
251
        global $DB;
251
        global $DB;
Línea 252... Línea 252...
252
        $this->resetAfterTest();
252
        $this->resetAfterTest();
253
 
253