3 final class DiffusionSubversionWireProtocolTestCase
4 extends PhabricatorTestCase
{
6 public function testSubversionWireProtocolParser() {
7 $this->assertSameSubversionMessages(
14 $this->assertSameSubversionMessages(
15 '( duck 5:quack 42 ( item1 item2 ) ) ',
46 $this->assertSameSubversionMessages(
63 // This is testing that multiple spaces are parsed correctly. See T13140
65 $this->assertSameSubversionMessages(
66 '( get-file true false ) ',
67 // ^-- Note extra space!
72 'value' => 'get-file',
84 '( get-file true false ) ');
86 $this->assertSameSubversionMessages(
87 '( duck 5:quack moo ) ',
104 '( duck 5:quack moo ) ');
108 public function testSubversionWireProtocolPartialFrame() {
109 $proto = new DiffusionSubversionWireProtocol();
111 // This is primarily a test that we don't hang when we write() a frame
112 // which straddles a string boundary.
113 $msg1 = $proto->writeData('( duck 5:qu');
114 $msg2 = $proto->writeData('ack ) ');
116 $this->assertEqual(array(), ipull($msg1, 'structure'));
130 ipull($msg2, 'structure'));
133 private function assertSameSubversionMessages(
136 $serial_string = null) {
138 $proto = new DiffusionSubversionWireProtocol();
140 // Verify that the wire message parses into the structs.
141 $messages = $proto->writeData($string);
142 $messages = ipull($messages, 'structure');
143 $this->assertEqual($structs, $messages, 'parse<'.$string.'>');
145 // Verify that the structs serialize into the wire message.
147 foreach ($structs as $struct) {
148 $serial[] = $proto->serializeStruct($struct);
150 $serial = implode('', $serial);
152 if ($serial_string === null) {
153 $expect_serial = $string;
155 $expect_serial = $serial_string;
158 $this->assertEqual($expect_serial, $serial, 'serialize<'.$string.'>');