Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 81... Línea 81...
81
    }
81
    }
Línea 82... Línea 82...
82
 
82
 
83
    /**
83
    /**
84
     * Tests the static asort method.
84
     * Tests the static asort method.
85
     */
85
     */
86
    public function test_asort() {
86
    public function test_asort(): void {
87
        $arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc');
87
        $arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc');
88
        $result = core_collator::asort($arr);
88
        $result = core_collator::asort($arr);
89
        $this->assertSame(array('aa', 'ab', 'cc'), array_values($arr));
89
        $this->assertSame(array('aa', 'ab', 'cc'), array_values($arr));
90
        $this->assertSame(array(1, 'b', 0), array_keys($arr));
90
        $this->assertSame(array(1, 'b', 0), array_keys($arr));
Línea 153... Línea 153...
153
    }
153
    }
Línea 154... Línea 154...
154
 
154
 
155
    /**
155
    /**
156
     * Tests the static asort_objects_by_method method.
156
     * Tests the static asort_objects_by_method method.
157
     */
157
     */
158
    public function test_asort_objects_by_method() {
158
    public function test_asort_objects_by_method(): void {
159
        $objects = array(
159
        $objects = array(
160
            'b' => new string_test_class('ab'),
160
            'b' => new string_test_class('ab'),
161
            1 => new string_test_class('aa'),
161
            1 => new string_test_class('aa'),
162
            0 => new string_test_class('cc')
162
            0 => new string_test_class('cc')
Línea 178... Línea 178...
178
    }
178
    }
Línea 179... Línea 179...
179
 
179
 
180
    /**
180
    /**
181
     * Tests the static asort_objects_by_method method.
181
     * Tests the static asort_objects_by_method method.
182
     */
182
     */
183
    public function test_asort_objects_by_property() {
183
    public function test_asort_objects_by_property(): void {
184
        $objects = array(
184
        $objects = array(
185
            'b' => new string_test_class('ab'),
185
            'b' => new string_test_class('ab'),
186
            1 => new string_test_class('aa'),
186
            1 => new string_test_class('aa'),
187
            0 => new string_test_class('cc')
187
            0 => new string_test_class('cc')
Línea 203... Línea 203...
203
    }
203
    }
Línea 204... Línea 204...
204
 
204
 
205
    /**
205
    /**
206
     * Tests the sorting of an array of arrays by key.
206
     * Tests the sorting of an array of arrays by key.
207
     */
207
     */
208
    public function test_asort_array_of_arrays_by_key() {
208
    public function test_asort_array_of_arrays_by_key(): void {
209
        $array = array(
209
        $array = array(
210
            'a' => array('name' => 'bravo'),
210
            'a' => array('name' => 'bravo'),
211
            'b' => array('name' => 'charlie'),
211
            'b' => array('name' => 'charlie'),
212
            'c' => array('name' => 'alpha')
212
            'c' => array('name' => 'alpha')
Línea 263... Línea 263...
263
    }
263
    }
Línea 264... Línea 264...
264
 
264
 
265
    /**
265
    /**
266
     * Tests the static ksort method.
266
     * Tests the static ksort method.
267
     */
267
     */
268
    public function test_ksort() {
268
    public function test_ksort(): void {
269
        $arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc');
269
        $arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc');
270
        $result = core_collator::ksort($arr);
270
        $result = core_collator::ksort($arr);
271
        $this->assertSame(array(0, 1, 'b'), array_keys($arr));
271
        $this->assertSame(array(0, 1, 'b'), array_keys($arr));
272
        $this->assertSame(array('cc', 'aa', 'ab'), array_values($arr));
272
        $this->assertSame(array('cc', 'aa', 'ab'), array_values($arr));