public function testPHPObjectChannelBasics()
 {
     list($x, $y) = PhutilSocketChannel::newChannelPair();
     $xp = new PhutilPHPObjectProtocolChannel($x);
     $yp = new PhutilPHPObjectProtocolChannel($y);
     $object = (object) array('key' => mt_rand());
     $xp->write($object);
     $xp->flush();
     $result = $yp->waitForMessage();
     $this->assertEqual(true, (array) $object === (array) $result, "Values are identical.");
     $this->assertEqual(false, $object === $result, "Objects are not the same.");
 }
 public function testCloseSocketWriteChannel()
 {
     list($x, $y) = PhutilSocketChannel::newChannelPair();
     $xp = new PhutilPHPObjectProtocolChannel($x);
     $yp = new PhutilPHPObjectProtocolChannel($y);
     $yp->closeWriteChannel();
     $yp->update();
     // NOTE: This test is more broad than the implementation needs to be. A
     // better test would be to verify that this throws an exception:
     //
     //   $xp->waitForMessage();
     //
     // However, if the test breaks, that method will hang forever instead of
     // returning, which would be hard to diagnose. Since the current
     // implementation shuts down the entire channel, just test for that.
     $this->assertFalse($xp->update(), pht('Expected channel to close.'));
 }