Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 22... Línea 22...
22
 * @package   quizaccess_seb
22
 * @package   quizaccess_seb
23
 * @author    Andrew Madden <andrewmadden@catalyst-au.net>
23
 * @author    Andrew Madden <andrewmadden@catalyst-au.net>
24
 * @copyright 2020 Catalyst IT
24
 * @copyright 2020 Catalyst IT
25
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
26
 */
27
class property_list_test extends \advanced_testcase {
27
final class property_list_test extends \advanced_testcase {
Línea 28... Línea 28...
28
 
28
 
29
    /**
29
    /**
30
     * Test that an empty PList with a root dictionary is created.
30
     * Test that an empty PList with a root dictionary is created.
31
     */
31
     */
Línea 233... Línea 233...
233
 
233
 
234
    /**
234
    /**
235
     * Test that the xml is exported to JSON from a real SEB config file. Expected JSON extracted from SEB logs.
235
     * Test that the xml is exported to JSON from a real SEB config file. Expected JSON extracted from SEB logs.
236
     */
236
     */
237
    public function test_export_to_json_full_file(): void {
237
    public function test_export_to_json_full_file(): void {
238
        $xml = file_get_contents(__DIR__ . '/fixtures/unencrypted_mac_001.seb');
238
        $xml = file_get_contents(self::get_fixture_path(__NAMESPACE__, 'unencrypted_mac_001.seb'));
239
        $plist = new property_list($xml);
239
        $plist = new property_list($xml);
240
        $plist->delete_element('originatorVersion'); // JSON should not contain originatorVersion key.
240
        $plist->delete_element('originatorVersion'); // JSON should not contain originatorVersion key.
241
        $generatedjson = $plist->to_json();
241
        $generatedjson = $plist->to_json();
242
        $json = trim(file_get_contents(__DIR__ . '/fixtures/JSON_unencrypted_mac_001.txt'));
242
        $json = trim(file_get_contents(self::get_fixture_path(__NAMESPACE__, 'JSON_unencrypted_mac_001.txt')));
243
        $this->assertEquals($json, $generatedjson);
243
        $this->assertEquals($json, $generatedjson);
Línea 244... Línea 244...
244
    }
244
    }
245
 
245
 
Línea 302... Línea 302...
302
    /**
302
    /**
303
     * Data provider for good data on update.
303
     * Data provider for good data on update.
304
     *
304
     *
305
     * @return array Array with test data.
305
     * @return array Array with test data.
306
     */
306
     */
307
    public function good_update_data_provider(): array {
307
    public static function good_update_data_provider(): array {
308
        return [
308
        return [
309
            'Update string' => ['<key>testKey</key><string>testValue</string>', 'testKey', 'newValue'],
309
            'Update string' => ['<key>testKey</key><string>testValue</string>', 'testKey', 'newValue'],
310
            'Update bool' => ['<key>testKey</key><true/>', 'testKey', false],
310
            'Update bool' => ['<key>testKey</key><true/>', 'testKey', false],
311
            'Update number' => ['<key>testKey</key><real>888</real>', 'testKey', 123.4],
311
            'Update number' => ['<key>testKey</key><real>888</real>', 'testKey', 123.4],
312
        ];
312
        ];
Línea 315... Línea 315...
315
    /**
315
    /**
316
     * Data provider for bad data on update.
316
     * Data provider for bad data on update.
317
     *
317
     *
318
     * @return array Array with test data.
318
     * @return array Array with test data.
319
     */
319
     */
320
    public function bad_update_data_provider(): array {
320
    public static function bad_update_data_provider(): array {
Línea 321... Línea 321...
321
 
321
 
322
        return [
322
        return [
323
            'Update string with bool' => ['<key>testKey</key><string>testValue</string>', 'testKey', true, 'testValue',
323
            'Update string with bool' => ['<key>testKey</key><string>testValue</string>', 'testKey', true, 'testValue',
324
                    'Invalid parameter value detected (Only string, number and boolean elements can be updated, '
324
                    'Invalid parameter value detected (Only string, number and boolean elements can be updated, '
Línea 377... Línea 377...
377
     * 9. JSON key ordering should be case insensitive, and use string ordering.
377
     * 9. JSON key ordering should be case insensitive, and use string ordering.
378
     * 10. URL forward slashes should not be escaped.
378
     * 10. URL forward slashes should not be escaped.
379
     *
379
     *
380
     * @return array
380
     * @return array
381
     */
381
     */
382
    public function json_data_provider(): array {
382
    public static function json_data_provider(): array {
383
        $data = "blahblah";
383
        $data = "blahblah";
384
        $base64data = base64_encode($data);
384
        $base64data = base64_encode($data);
Línea 385... Línea 385...
385
 
385
 
386
        return [
386
        return [