/**
  * @expectedException RuntimeException
  */
 public function testFetchRevisionUnknownBase()
 {
     $file = 'jakarta/ecs/tags/V1_0/src/java/org/apache/ecs/AlignType.java';
     $revision = 'xyz';
     $promise = $this->viewvc->fetchRevisionPrevious($file, $revision);
     Block\await($promise, $this->loop);
 }
 public function testFetchFileDeletedShowsLastState()
 {
     $file = '.frozen';
     $promise = $this->viewvc->fetchFile($file);
     $contents = Block\await($promise, $this->loop);
     $this->assertEquals("robbat2\n", $contents);
 }
Пример #3
0
 public function testBlzServiceWithInvalidMethod()
 {
     $api = new Proxy($this->client);
     $promise = $api->doesNotexist();
     $this->expectPromiseReject($promise);
     $this->setExpectedException('Exception');
     Block\await($promise, $this->loop);
 }
Пример #4
0
 public function testAwaitOnceWithTimeoutWillResolvemmediatelyAndCleanUpTimeout()
 {
     $promise = Promise\resolve(true);
     $time = microtime(true);
     Block\await($promise, $this->loop, 5.0);
     $this->loop->run();
     $time = microtime(true) - $time;
     $this->assertLessThan(0.1, $time);
 }
 public function testImageTag()
 {
     // create new tag "bb:now" on "busybox:latest"
     $promise = $this->client->imageTag('busybox', 'bb', 'now');
     $ret = Block\await($promise, $this->loop);
     // delete tag "bb:now" again
     $promise = $this->client->imageRemove('bb:now');
     $ret = Block\await($promise, $this->loop);
 }
Пример #6
0
 public function testSenderRejection()
 {
     $connector = $this->getMock('React\\SocketClient\\ConnectorInterface');
     $connector->expects($this->once())->method('create')->willReturn(Promise\reject(new RuntimeException('Rejected')));
     $sender = Sender::createFromLoopConnectors($this->loop, $connector);
     $request = new Request('GET', 'http://www.google.com/');
     $promise = $sender->send($request, $this->getMock('Clue\\React\\Buzz\\Message\\MessageFactory'));
     $this->setExpectedException('RuntimeException');
     Block\await($promise, $this->loop);
 }
Пример #7
0
 public function testReceivingStreamingBodyWillResolveWithStreamingResponseIfStreamingIsEnabled()
 {
     $messageFactory = new MessageFactory();
     $request = $this->getMock('Psr\\Http\\Message\\RequestInterface');
     $response = $messageFactory->response(1.0, 200, 'OK', array(), $this->getMock('React\\Stream\\ReadableStreamInterface'));
     // mock sender to resolve promise with the given $response in response to the given $request
     $sender = $this->getMockBuilder('Clue\\React\\Buzz\\Io\\Sender')->disableOriginalConstructor()->getMock();
     $sender->expects($this->once())->method('send')->with($this->equalTo($request))->willReturn(Promise\resolve($response));
     $transaction = new Transaction($request, $sender, array('streaming' => true), $messageFactory);
     $promise = $transaction->send();
     $response = Block\await($promise, $this->getMock('React\\EventLoop\\LoopInterface'));
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('', (string) $response->getBody());
 }
Пример #8
0
 public function testValid()
 {
     $path = tempnam(sys_get_temp_dir(), 'socket');
     $server = @stream_socket_server('unix://' . $path, $errno, $errstr);
     if (!$server) {
         $this->markTestSkipped('Unable to create socket: ' . $errstr . '(' . $errno . ')');
         return;
     }
     $loop = $this->getMock('React\\EventLoop\\LoopInterface');
     $connector = new UnixConnector($loop, 'unix://' . $path);
     $promise = $connector->create('localhost', 80);
     $stream = Block\await($promise, $loop);
     /* @var $stream React\Stream\Stream */
     $stream->close();
     fclose($server);
     unlink($path);
 }
Пример #9
0
 /**
  * @param Route $route
  * @return mixed
  * @throws \Exception
  * @throws \InvalidArgumentException
  * @throws \React\Promise\Timer\TimeoutException
  */
 public function request(Route $route)
 {
     return Block\await(parent::request($route), $this->gitter->loop);
 }
Пример #10
0
 public function repository(string $repository) : Repository
 {
     return await($this->client->repository($repository), $this->transport->getLoop());
 }
Пример #11
0
 private function awaitMessage(Client $client)
 {
     return Block\await(new Promise(function ($resolve, $reject) use($client) {
         $client->once('data', $resolve);
         $client->once('error', $reject);
         $client->once('close', $reject);
     }), self::$loop, 10.0);
 }
 public function testClosingStreamWillCloseStreamIfItIgnoredCancellationAndResolvesLater()
 {
     $input = new ReadableStream();
     $loop = $this->loop;
     $promise = new Promise\Promise(function ($resolve) use($loop, $input) {
         $loop->addTimer(0.001, function () use($resolve, $input) {
             $resolve($input);
         });
     });
     $stream = Stream\unwrapReadable($promise);
     $stream->on('close', $this->expectCallableOnce());
     $stream->close();
     Block\await($promise, $this->loop);
     $this->assertFalse($input->isReadable());
 }
Пример #13
0
 public function testPostStreamClosed()
 {
     $stream = new ReadableStream();
     $stream->close();
     $response = Block\await($this->browser->post($this->base . 'post', array(), $stream), $this->loop);
     $data = json_decode((string) $response->getBody(), true);
     $this->assertEquals('', $data['data']);
 }
 public function testAwaitOneInterrupted()
 {
     $promise = $this->createPromiseResolved(2, 0.02);
     $this->createTimerInterrupt(0.01);
     $this->assertEquals(2, Block\await($promise, $this->loop));
 }
Пример #15
0
 /**
  * @return array
  */
 public function broadcasts() : array
 {
     return await(Promise::fromObservable($this->client->broadcasts()->toArray()), $this->transport->getLoop());
 }
Пример #16
0
 /**
  * @param string $other
  * @dataProvider provideOtherBaseUris
  * @expectedException UnexpectedValueException
  */
 public function testRequestingUrlsNotBelowBaseWillRejectBeforeSending($other)
 {
     $browser = $this->browser->withBase('http://example.com/base/');
     $this->sender->expects($this->never())->method('send');
     Block\await($browser->get($other), $this->loop);
 }
Пример #17
0
 private function assertRejectPromise($promise)
 {
     $this->expectPromiseReject($promise);
     $this->setExpectedException('Exception');
     Block\await($promise, $this->loop, 2.0);
 }
Пример #18
0
 private function await($thenable, float $timeout = 0.1)
 {
     if (!$thenable instanceof PromiseInterface) {
         $deferred = new Deferred();
         $thenable->then([$deferred, 'resolve'], [$deferred, 'reject']);
         $thenable = $deferred->promise();
     }
     return await(timeout($thenable, $timeout, $this->eventLoop), $this->eventLoop);
 }
Пример #19
0
 /**
  * @return Client
  */
 protected function createClient()
 {
     return Block\await($this->factory->createClient(), $this->loop);
 }
 protected function dequeue($item)
 {
     return Block\await(Promise\resolve($item), LoopFactory::create(), 5);
 }