@@ 489-512 (lines=24) @@ | ||
486 | * @param string $expectedFileName File with expected xml result. |
|
487 | * @return void |
|
488 | */ |
|
489 | public static function assertXmlEquals($actualOutput, $expectedFileName) |
|
490 | { |
|
491 | $actual = simplexml_load_string($actualOutput); |
|
492 | // Remove dynamic timestamp and duration attribute |
|
493 | if (isset($actual['timestamp'])) { |
|
494 | $actual['timestamp'] = ''; |
|
495 | } |
|
496 | if (isset($actual['duration'])) { |
|
497 | $actual['duration'] = ''; |
|
498 | } |
|
499 | if (isset($actual['version'])) { |
|
500 | $actual['version'] = '@package_version@'; |
|
501 | } |
|
502 | ||
503 | $expected = str_replace( |
|
504 | '#{rootDirectory}', |
|
505 | self::$filesDirectory, |
|
506 | file_get_contents(self::createFileUri($expectedFileName)) |
|
507 | ); |
|
508 | ||
509 | $expected = str_replace('_DS_', DIRECTORY_SEPARATOR, $expected); |
|
510 | ||
511 | self::assertXmlStringEqualsXmlString($expected, $actual->saveXML()); |
|
512 | } |
|
513 | ||
514 | /** |
|
515 | * Asserts the actual JSON output matches against the expected file. |
|
@@ 522-545 (lines=24) @@ | ||
519 | * |
|
520 | * @return void |
|
521 | */ |
|
522 | public function assertJsonEquals($actualOutput, $expectedFileName) |
|
523 | { |
|
524 | $actual = json_decode($actualOutput, true); |
|
525 | // Remove dynamic timestamp and duration attribute |
|
526 | if (isset($actual['timestamp'])) { |
|
527 | $actual['timestamp'] = ''; |
|
528 | } |
|
529 | if (isset($actual['duration'])) { |
|
530 | $actual['duration'] = ''; |
|
531 | } |
|
532 | if (isset($actual['version'])) { |
|
533 | $actual['version'] = '@package_version@'; |
|
534 | } |
|
535 | ||
536 | $expected = str_replace( |
|
537 | '#{rootDirectory}', |
|
538 | self::$filesDirectory, |
|
539 | file_get_contents(self::createFileUri($expectedFileName)) |
|
540 | ); |
|
541 | ||
542 | $expected = str_replace('_DS_', DIRECTORY_SEPARATOR, $expected); |
|
543 | ||
544 | self::assertJsonStringEqualsJsonString($expected, json_encode($actual)); |
|
545 | } |
|
546 | ||
547 | /** |
|
548 | * This method initializes the test environment, it configures the files |