[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DiffusionSubversionWireProtocolTestCase 4 extends PhabricatorTestCase { 5 6 public function testSubversionWireProtocolParser() { 7 $this->assertSameSubversionMessages( 8 '( ) ', 9 array( 10 array( 11 ), 12 )); 13 14 $this->assertSameSubversionMessages( 15 '( duck 5:quack 42 ( item1 item2 ) ) ', 16 array( 17 array( 18 array( 19 'type' => 'word', 20 'value' => 'duck', 21 ), 22 array( 23 'type' => 'string', 24 'value' => 'quack', 25 ), 26 array( 27 'type' => 'number', 28 'value' => 42, 29 ), 30 array( 31 'type' => 'list', 32 'value' => array( 33 array( 34 'type' => 'word', 35 'value' => 'item1', 36 ), 37 array( 38 'type' => 'word', 39 'value' => 'item2', 40 ), 41 ), 42 ), 43 ), 44 )); 45 46 $this->assertSameSubversionMessages( 47 '( msg1 ) ( msg2 ) ', 48 array( 49 array( 50 array( 51 'type' => 'word', 52 'value' => 'msg1', 53 ), 54 ), 55 array( 56 array( 57 'type' => 'word', 58 'value' => 'msg2', 59 ), 60 ), 61 )); 62 } 63 64 public function testSubversionWireProtocolPartialFrame() { 65 $proto = new DiffusionSubversionWireProtocol(); 66 67 // This is primarily a test that we don't hang when we write() a frame 68 // which straddles a string boundary. 69 $msg1 = $proto->writeData('( duck 5:qu'); 70 $msg2 = $proto->writeData('ack ) '); 71 72 $this->assertEqual(array(), ipull($msg1, 'structure')); 73 $this->assertEqual( 74 array( 75 array( 76 array( 77 'type' => 'word', 78 'value' => 'duck', 79 ), 80 array( 81 'type' => 'string', 82 'value' => 'quack', 83 ), 84 ), 85 ), 86 ipull($msg2, 'structure')); 87 } 88 89 private function assertSameSubversionMessages($string, array $structs) { 90 $proto = new DiffusionSubversionWireProtocol(); 91 92 // Verify that the wire message parses into the structs. 93 $messages = $proto->writeData($string); 94 $messages = ipull($messages, 'structure'); 95 $this->assertEqual($structs, $messages, 'parse<'.$string.'>'); 96 97 // Verify that the structs serialize into the wire message. 98 $serial = array(); 99 foreach ($structs as $struct) { 100 $serial[] = $proto->serializeStruct($struct); 101 } 102 $serial = implode('', $serial); 103 $this->assertEqual($string, $serial, 'serialize<'.$string.'>'); 104 } 105 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |