Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 30... Línea 30...
30
 * @category   test
30
 * @category   test
31
 * @copyright  2010 The Open University
31
 * @copyright  2010 The Open University
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 */
33
 */
34
class questionutils_test extends \advanced_testcase {
34
class questionutils_test extends \advanced_testcase {
35
    public function test_arrays_have_same_keys_and_values() {
35
    public function test_arrays_have_same_keys_and_values(): void {
36
        $this->assertTrue(question_utils::arrays_have_same_keys_and_values(
36
        $this->assertTrue(question_utils::arrays_have_same_keys_and_values(
37
                array(),
37
                array(),
38
                array()));
38
                array()));
39
        $this->assertTrue(question_utils::arrays_have_same_keys_and_values(
39
        $this->assertTrue(question_utils::arrays_have_same_keys_and_values(
40
                array('key' => 1),
40
                array('key' => 1),
Línea 51... Línea 51...
51
        $this->assertFalse(question_utils::arrays_have_same_keys_and_values(
51
        $this->assertFalse(question_utils::arrays_have_same_keys_and_values(
52
                array('sub0' => '2', 'sub1' => '2', 'sub2' => '3', 'sub3' => '1'),
52
                array('sub0' => '2', 'sub1' => '2', 'sub2' => '3', 'sub3' => '1'),
53
                array('sub0' => '1', 'sub1' => '2', 'sub2' => '3', 'sub3' => '1')));
53
                array('sub0' => '1', 'sub1' => '2', 'sub2' => '3', 'sub3' => '1')));
54
    }
54
    }
Línea 55... Línea 55...
55
 
55
 
56
    public function test_arrays_same_at_key() {
56
    public function test_arrays_same_at_key(): void {
57
        $this->assertTrue(question_utils::arrays_same_at_key(
57
        $this->assertTrue(question_utils::arrays_same_at_key(
58
                array(),
58
                array(),
59
                array(),
59
                array(),
60
                'key'));
60
                'key'));
Línea 86... Línea 86...
86
                array(),
86
                array(),
87
                array('key' => ''),
87
                array('key' => ''),
88
                'key'));
88
                'key'));
89
    }
89
    }
Línea 90... Línea 90...
90
 
90
 
91
    public function test_arrays_same_at_key_missing_is_blank() {
91
    public function test_arrays_same_at_key_missing_is_blank(): void {
92
        $this->assertTrue(question_utils::arrays_same_at_key_missing_is_blank(
92
        $this->assertTrue(question_utils::arrays_same_at_key_missing_is_blank(
93
                array(),
93
                array(),
94
                array(),
94
                array(),
95
                'key'));
95
                'key'));
Línea 121... Línea 121...
121
                array(),
121
                array(),
122
                array('key' => ''),
122
                array('key' => ''),
123
                'key'));
123
                'key'));
124
    }
124
    }
Línea 125... Línea 125...
125
 
125
 
126
    public function test_arrays_same_at_key_integer() {
126
    public function test_arrays_same_at_key_integer(): void {
127
        $this->assertTrue(question_utils::arrays_same_at_key_integer(
127
        $this->assertTrue(question_utils::arrays_same_at_key_integer(
128
                array(),
128
                array(),
129
                array(),
129
                array(),
130
                'key'));
130
                'key'));
Línea 156... Línea 156...
156
                array(),
156
                array(),
157
                array('key' => 0),
157
                array('key' => 0),
158
                'key'));
158
                'key'));
159
    }
159
    }
Línea 160... Línea 160...
160
 
160
 
161
    public function test_int_to_roman() {
161
    public function test_int_to_roman(): void {
162
        $this->assertSame('i', question_utils::int_to_roman(1));
162
        $this->assertSame('i', question_utils::int_to_roman(1));
163
        $this->assertSame('iv', question_utils::int_to_roman(4));
163
        $this->assertSame('iv', question_utils::int_to_roman(4));
164
        $this->assertSame('v', question_utils::int_to_roman(5));
164
        $this->assertSame('v', question_utils::int_to_roman(5));
165
        $this->assertSame('vi', question_utils::int_to_roman(6));
165
        $this->assertSame('vi', question_utils::int_to_roman(6));
Línea 170... Línea 170...
170
        $this->assertSame('c', question_utils::int_to_roman(100));
170
        $this->assertSame('c', question_utils::int_to_roman(100));
171
        $this->assertSame('mccxxxiv', question_utils::int_to_roman(1234));
171
        $this->assertSame('mccxxxiv', question_utils::int_to_roman(1234));
172
        $this->assertSame('mmmcmxcix', question_utils::int_to_roman(3999));
172
        $this->assertSame('mmmcmxcix', question_utils::int_to_roman(3999));
173
    }
173
    }
Línea 174... Línea 174...
174
 
174
 
175
    public function test_int_to_letter() {
175
    public function test_int_to_letter(): void {
176
        $this->assertEquals('A', question_utils::int_to_letter(1));
176
        $this->assertEquals('A', question_utils::int_to_letter(1));
177
        $this->assertEquals('B', question_utils::int_to_letter(2));
177
        $this->assertEquals('B', question_utils::int_to_letter(2));
178
        $this->assertEquals('C', question_utils::int_to_letter(3));
178
        $this->assertEquals('C', question_utils::int_to_letter(3));
179
        $this->assertEquals('D', question_utils::int_to_letter(4));
179
        $this->assertEquals('D', question_utils::int_to_letter(4));
Línea 199... Línea 199...
199
        $this->assertEquals('X', question_utils::int_to_letter(24));
199
        $this->assertEquals('X', question_utils::int_to_letter(24));
200
        $this->assertEquals('Y', question_utils::int_to_letter(25));
200
        $this->assertEquals('Y', question_utils::int_to_letter(25));
201
        $this->assertEquals('Z', question_utils::int_to_letter(26));
201
        $this->assertEquals('Z', question_utils::int_to_letter(26));
202
    }
202
    }
Línea 203... Línea 203...
203
 
203
 
204
    public function test_int_to_roman_too_small() {
204
    public function test_int_to_roman_too_small(): void {
205
        $this->expectException(\moodle_exception::class);
205
        $this->expectException(\moodle_exception::class);
206
        question_utils::int_to_roman(0);
206
        question_utils::int_to_roman(0);
Línea 207... Línea 207...
207
    }
207
    }
208
 
208
 
209
    public function test_int_to_roman_too_big() {
209
    public function test_int_to_roman_too_big(): void {
210
        $this->expectException(\moodle_exception::class);
210
        $this->expectException(\moodle_exception::class);
Línea 211... Línea 211...
211
        question_utils::int_to_roman(4000);
211
        question_utils::int_to_roman(4000);
212
    }
212
    }
213
 
213
 
214
    public function test_int_to_roman_not_int() {
214
    public function test_int_to_roman_not_int(): void {
Línea 215... Línea 215...
215
        $this->expectException(\moodle_exception::class);
215
        $this->expectException(\moodle_exception::class);
216
        question_utils::int_to_roman(1.5);
216
        question_utils::int_to_roman(1.5);
217
    }
217
    }
218
 
218
 
219
    public function test_clean_param_mark() {
219
    public function test_clean_param_mark(): void {
220
        $this->assertNull(question_utils::clean_param_mark(null));
220
        $this->assertNull(question_utils::clean_param_mark(null));