Línea 34... |
Línea 34... |
34 |
* Test an XML import using a valid XML file.
|
34 |
* Test an XML import using a valid XML file.
|
35 |
*
|
35 |
*
|
36 |
* The test expected file was generated using the original xmlize
|
36 |
* The test expected file was generated using the original xmlize
|
37 |
* implentation found at https://github.com/rmccue/XMLize/blob/master/xmlize-php5.inc.
|
37 |
* implentation found at https://github.com/rmccue/XMLize/blob/master/xmlize-php5.inc.
|
38 |
*/
|
38 |
*/
|
39 |
public function test_xmlimport_of_proper_file() {
|
39 |
public function test_xmlimport_of_proper_file(): void {
|
40 |
$xml = file_get_contents(__DIR__ . '/sample_questions.xml');
|
40 |
$xml = file_get_contents(__DIR__ . '/sample_questions.xml');
|
41 |
$serialised = file_get_contents(__DIR__ . '/sample_questions.ser');
|
41 |
$serialised = file_get_contents(__DIR__ . '/sample_questions.ser');
|
42 |
$this->assertEquals(unserialize($serialised), xmlize($xml));
|
42 |
$this->assertEquals(unserialize($serialised), xmlize($xml));
|
43 |
}
|
43 |
}
|
Línea 44... |
Línea 44... |
44 |
|
44 |
|
45 |
/**
|
45 |
/**
|
46 |
* Test an XML import using invalid XML.
|
46 |
* Test an XML import using invalid XML.
|
47 |
*/
|
47 |
*/
|
48 |
public function test_xmlimport_of_wrong_file() {
|
48 |
public function test_xmlimport_of_wrong_file(): void {
|
49 |
$xml = file_get_contents(__DIR__ . '/sample_questions_wrong.xml');
|
49 |
$xml = file_get_contents(__DIR__ . '/sample_questions_wrong.xml');
|
50 |
$this->expectException('xml_format_exception');
|
50 |
$this->expectException('xml_format_exception');
|
51 |
$this->expectExceptionMessage('Error parsing XML: Mismatched tag at line 18, char 23');
|
51 |
$this->expectExceptionMessage('Error parsing XML: Mismatched tag at line 18, char 23');
|
52 |
$xmlnew = xmlize($xml, 1, "UTF-8", true);
|
52 |
$xmlnew = xmlize($xml, 1, "UTF-8", true);
|
Línea 53... |
Línea 53... |
53 |
}
|
53 |
}
|
54 |
|
54 |
|
55 |
/**
|
55 |
/**
|
56 |
* Test an XML import using legacy question data with old image tag.
|
56 |
* Test an XML import using legacy question data with old image tag.
|
57 |
*/
|
57 |
*/
|
58 |
public function test_xmlimport_of_sample_question_with_old_image_tag() {
|
58 |
public function test_xmlimport_of_sample_question_with_old_image_tag(): void {
|
Línea 59... |
Línea 59... |
59 |
$xml = file_get_contents(__DIR__ . '/sample_questions_with_old_image_tag.xml');
|
59 |
$xml = file_get_contents(__DIR__ . '/sample_questions_with_old_image_tag.xml');
|
60 |
$serialised = file_get_contents(__DIR__ . '/sample_questions_with_old_image_tag.ser');
|
60 |
$serialised = file_get_contents(__DIR__ . '/sample_questions_with_old_image_tag.ser');
|