17 $this->cli->stderr =
fopen(
'php://memory',
'r+');
18 $this->cli->stdout =
fopen(
'php://memory',
'r+');
26 $this->cli->main([
'vobject',
'--hi'])
28 rewind($this->cli->stderr);
29 $this->assertTrue(strlen(stream_get_contents($this->cli->stderr)) > 100);
37 $this->cli->main([
'vobject',
'-q'])
39 $this->assertTrue($this->cli->quiet);
41 rewind($this->cli->stderr);
42 $this->assertEquals(0, strlen(stream_get_contents($this->cli->stderr)));
50 $this->cli->main([
'vobject',
'-h'])
52 rewind($this->cli->stderr);
53 $this->assertTrue(strlen(stream_get_contents($this->cli->stderr)) > 100);
61 $this->cli->main([
'vobject',
'--format=jcard'])
64 rewind($this->cli->stderr);
65 $this->assertTrue(strlen(stream_get_contents($this->cli->stderr)) > 100);
67 $this->assertEquals(
'jcard', $this->cli->format);
75 $this->cli->main([
'vobject',
'--format=foo'])
78 rewind($this->cli->stderr);
79 $this->assertTrue(strlen(stream_get_contents($this->cli->stderr)) > 100);
81 $this->assertNull($this->cli->format);
89 $this->cli->main([
'vobject',
'--inputformat=foo'])
92 rewind($this->cli->stderr);
93 $this->assertTrue(strlen(stream_get_contents($this->cli->stderr)) > 100);
95 $this->assertNull($this->cli->format);
104 $this->cli->main([
'vobject',
'color'])
107 rewind($this->cli->stderr);
108 $this->assertTrue(strlen(stream_get_contents($this->cli->stderr)) > 100);
116 $this->cli->main([
'vobject',
'color',
'a',
'b',
'c'])
125 $this->cli->main([
'vobject',
'foo',
'-'])
132 $inputStream =
fopen(
'php://memory',
'r+');
134 fwrite($inputStream, <<<ICS
141 rewind($inputStream);
142 $this->cli->stdin = $inputStream;
146 $this->cli->main([
'vobject',
'convert',
'--format=json',
'-'])
149 rewind($this->cli->stdout);
152 '["vcard",[["version",{},"text","4.0"],["prodid",{},"text","-\/\/Sabre\/\/Sabre VObject ' .
$version .
'\/\/EN"],["fn",{},"text","Cowboy Henk"]]]',
153 stream_get_contents($this->cli->stdout)
160 if (version_compare(PHP_VERSION,
'5.4.0') < 0) {
161 $this->markTestSkipped(
'This test required PHP 5.4.0');
164 $inputStream =
fopen(
'php://memory',
'r+');
166 fwrite($inputStream, <<<ICS
173 rewind($inputStream);
174 $this->cli->stdin = $inputStream;
178 $this->cli->main([
'vobject',
'convert',
'--format=jcard',
'--pretty',
'-'])
181 rewind($this->cli->stdout);
193 $this->assertStringStartsWith( 195 stream_get_contents($this->cli->stdout) 200 function testConvertJCalFail() { 202 $inputStream = fopen('php://memory', 'r+'); 204 fwrite($inputStream, <<<ICS 211 rewind($inputStream); 212 $this->cli->stdin = $inputStream; 216 $this->cli->main(['vobject', 'convert', '--format=jcal', '--inputformat=mimedir', '-']) 221 function testConvertMimeDir() { 223 $inputStream = fopen('php://memory', 'r+'); 225 fwrite($inputStream, <<<JCARD 257 rewind($inputStream); 258 $this->cli->stdin = $inputStream; 262 $this->cli->main(['vobject', 'convert', '--format=mimedir', '--inputformat=json', '--pretty', '-']) 265 rewind($this->cli->stdout); 269 PRODID:-//Sabre//Sabre VObject 3.1.0//EN 276 strtr($expected, ["\n" => "\r\n"]), 277 stream_get_contents($this->cli->stdout) 282 function testConvertDefaultFormats() { 284 $outputFile = SABRE_TEMPDIR . 'bar.json'; 288 $this->cli->main(['vobject', 'convert', 'foo.json', $outputFile]) 291 $this->assertEquals('json', $this->cli->inputFormat); 292 $this->assertEquals('json', $this->cli->format); 296 function testConvertDefaultFormats2() { 298 $outputFile = SABRE_TEMPDIR . 'bar.ics'; 302 $this->cli->main(['vobject', 'convert', 'foo.ics', $outputFile]) 305 $this->assertEquals('mimedir', $this->cli->inputFormat); 306 $this->assertEquals('mimedir', $this->cli->format); 310 function testVCard3040() { 312 $inputStream = fopen('php://memory', 'r+'); 314 fwrite($inputStream, <<<VCARD 317 PRODID:-//Sabre//Sabre VObject 3.1.0//EN 323 rewind($inputStream); 324 $this->cli->stdin = $inputStream; 328 $this->cli->main(['vobject', 'convert', '--format=vcard40', '--pretty', '-']) 331 rewind($this->cli->stdout); 333 $version = Version::VERSION; 337 PRODID:-//Sabre//Sabre VObject $version//EN 344 strtr($expected, ["\n" => "\r\n"]), 345 stream_get_contents($this->cli->stdout) 350 function testVCard4030() { 352 $inputStream = fopen('php://memory', 'r+'); 354 fwrite($inputStream, <<<VCARD 357 PRODID:-//Sabre//Sabre VObject 3.1.0//EN 363 rewind($inputStream); 364 $this->cli->stdin = $inputStream; 368 $this->cli->main(['vobject', 'convert', '--format=vcard30', '--pretty', '-']) 371 $version = Version::VERSION; 373 rewind($this->cli->stdout); 377 PRODID:-//Sabre//Sabre VObject $version//EN 384 strtr($expected, ["\n" => "\r\n"]), 385 stream_get_contents($this->cli->stdout) 390 function testVCard4021() { 392 $inputStream = fopen('php://memory', 'r+'); 394 fwrite($inputStream, <<<VCARD 397 PRODID:-//Sabre//Sabre VObject 3.1.0//EN 403 rewind($inputStream); 404 $this->cli->stdin = $inputStream; 408 $this->cli->main(['vobject', 'convert', '--format=vcard21', '--pretty', '-']) 413 function testValidate() { 415 $inputStream = fopen('php://memory', 'r+'); 417 fwrite($inputStream, <<<VCARD 420 PRODID:-//Sabre//Sabre VObject 3.1.0//EN 427 rewind($inputStream); 428 $this->cli->stdin = $inputStream; 429 $result = $this->cli->main(['vobject', 'validate', '-']); 438 function testValidateFail() { 440 $inputStream = fopen('php://memory', 'r+'); 442 fwrite($inputStream, <<<VCARD 449 rewind($inputStream); 450 $this->cli->stdin = $inputStream; 451 // vCard 2.0 is not supported yet, so this returns a failure. 454 $this->cli->main(['vobject', 'validate', '-']) 459 function testValidateFail2() { 461 $inputStream = fopen('php://memory', 'r+'); 463 fwrite($inputStream, <<<VCARD 470 rewind($inputStream); 471 $this->cli->stdin = $inputStream; 475 $this->cli->main(['vobject', 'validate', '-']) 480 function testRepair() { 482 $inputStream = fopen('php://memory', 'r+'); 484 fwrite($inputStream, <<<VCARD 491 rewind($inputStream); 492 $this->cli->stdin = $inputStream; 496 $this->cli->main(['vobject', 'repair', '-']) 499 rewind($this->cli->stdout); 500 $this->assertRegExp("/^BEGIN:VCARD\r\nVERSION:2.1\r\nUID:[0-9
a-f]{8}-[0-9
a-f]{4}-[0-9
a-f]{4}-[0-9
a-f]{4}-[0-9
a-f]{12}\r\nEND:
VCARD\r\n$/
", stream_get_contents($this->cli->stdout)); 503 function testRepairNothing() { 505 $inputStream = fopen('php://memory', 'r+'); 507 fwrite($inputStream, <<<VCARD 510 PRODID:-//Sabre//Sabre VObject 3.1.0//EN 513 DTSTAMP:20140122T233226Z 514 DTSTART:20140101T120000Z 520 rewind($inputStream); 521 $this->cli->stdin = $inputStream; 523 $result = $this->cli->main(['vobject', 'repair', '-']); 525 rewind($this->cli->stderr); 526 $error = stream_get_contents($this->cli->stderr); 531 "This should have been error free. stderr output:
\n" . $error 542 function testColorCalendar() { 544 $inputStream = fopen('php://memory', 'r+'); 546 $version = Version::VERSION; 552 fwrite($inputStream, <<<VCARD 555 PRODID:-//Sabre//Sabre VObject {$version}//EN 559 ATTENDEE;RSVP=TRUE:mailto:foo@example.org 567 rewind($inputStream); 568 $this->cli->stdin = $inputStream; 570 $result = $this->cli->main(['vobject', 'color', '-']); 572 rewind($this->cli->stderr); 573 $error = stream_get_contents($this->cli->stderr); 578 "This should have been error free. stderr output:
\n" . $error 589 function testColorVCard() { 591 $inputStream = fopen('php://memory', 'r+'); 593 $version = Version::VERSION; 599 fwrite($inputStream, <<<VCARD 602 PRODID:-//Sabre//Sabre VObject {$version}//EN 609 rewind($inputStream); 610 $this->cli->stdin = $inputStream; 612 $result = $this->cli->main(['vobject', 'color', '-']); 614 rewind($this->cli->stderr); 615 $error = stream_get_contents($this->cli->stderr); 620 "This should have been error free. stderr output:
\n" . $error 626 class CliMock extends Cli { 628 public $quiet = false; 642 public $outputFormat;
const VERSION
Full version number.
if(! $in) print Initializing normalization quick check tables n
foreach($paths as $path) duplicate contact merge tool n