ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PHPUnitAssertions.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\VObject;
4
15trait PHPUnitAssertions {
16
35 function assertVObjectEqualsVObject($expected, $actual, $message = '') {
36
37 $self = $this;
38 $getObj = function($input) use ($self) {
39
40 if (is_resource($input)) {
41 $input = stream_get_contents($input);
42 }
43 if (is_string($input)) {
45 }
46 if (!$input instanceof Component) {
47 $this->fail('Input must be a string, stream or VObject component');
48 }
49 unset($input->PRODID);
50 if ($input instanceof Component\VCalendar && (string)$input->CALSCALE === 'GREGORIAN') {
51 unset($input->CALSCALE);
52 }
53 return $input;
54
55 };
56
57 $expected = $getObj($expected)->serialize();
58 $actual = $getObj($actual)->serialize();
59
60 // Finding wildcards in expected.
61 preg_match_all('|^([A-Z]+):\\*\\*ANY\\*\\*\r$|m', $expected, $matches, PREG_SET_ORDER);
62
63 foreach ($matches as $match) {
64
65 $actual = preg_replace(
66 '|^' . preg_quote($match[1], '|') . ':(.*)\r$|m',
67 $match[1] . ':**ANY**' . "\r",
68 $actual
69 );
70
71 }
72
73 $this->assertEquals(
74 $expected,
75 $actual,
77 );
78
79 }
80
81
82}
An exception for terminatinating execution or to throw for unit testing.
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
catch(Exception $e) $message
foreach($paths as $path) if($argc< 3) $input