当前位置: 首页>>代码示例>>PHP>>正文


PHP Promise\resolve函数代码示例

本文整理汇总了PHP中React\Promise\resolve函数的典型用法代码示例。如果您正苦于以下问题:PHP resolve函数的具体用法?PHP resolve怎么用?PHP resolve使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了resolve函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFetchFile

 public function testFetchFile()
 {
     $response = new Response(200, array(), '# hello', '1.0', 'OK');
     $this->expectRequest($this->uri . 'README.md?view=co')->will($this->returnValue(Promise\resolve($response)));
     $promise = $this->client->fetchFile('README.md');
     $this->expectPromiseResolveWith('# hello', $promise);
 }
开发者ID:clue,项目名称:viewvc-api-react,代码行数:7,代码来源:ClientTest.php

示例2: testWillWriteAuthCommandIfTargetContainsUserInfo

 public function testWillWriteAuthCommandIfTargetContainsUserInfo()
 {
     $stream = $this->getMockBuilder('React\\Stream\\Stream')->disableOriginalConstructor()->getMock();
     $stream->expects($this->once())->method('write')->with("*2\r\n\$4\r\nauth\r\n\$11\r\nhello:world\r\n");
     $this->connector->expects($this->once())->method('create')->willReturn(Promise\resolve($stream));
     $this->factory->createClient('tcp://hello:world@127.0.0.1');
 }
开发者ID:clue,项目名称:redis-react,代码行数:7,代码来源:FactoryTest.php

示例3: resolveHostname

 private function resolveHostname($host)
 {
     if (false !== filter_var($host, FILTER_VALIDATE_IP)) {
         return Promise\resolve($host);
     }
     return $this->resolver->resolve($host);
 }
开发者ID:gai00,项目名称:socket-client,代码行数:7,代码来源:DnsConnector.php

示例4: get

 public function get($key)
 {
     if (!isset($this->data[$key])) {
         return Promise\reject();
     }
     return Promise\resolve($this->data[$key]);
 }
开发者ID:shsrain,项目名称:ypyzApi,代码行数:7,代码来源:ArrayCache.php

示例5: testWillNotInvokeProberIfSchemeIsProtocol

 public function testWillNotInvokeProberIfSchemeIsProtocol()
 {
     $stream = $this->getMockBuilder('React\\Stream\\Stream')->disableOriginalConstructor()->getMock();
     $this->connector->expects($this->once())->method('create')->will($this->returnValue(Promise\resolve($stream)));
     $this->prober->expects($this->never())->method('probe');
     $this->expectPromiseResolve($this->factory->createClient('legacy://localhost'));
 }
开发者ID:clue,项目名称:quassel-react,代码行数:7,代码来源:FactoryTest.php

示例6: rejectShouldRejectWithFulfilledPromise

 /** @test */
 public function rejectShouldRejectWithFulfilledPromise()
 {
     extract($this->getPromiseTestAdapter());
     $mock = $this->createCallableMock();
     $mock->expects($this->once())->method('__invoke')->with($this->identicalTo(1));
     $promise()->then($this->expectCallableNever(), $mock);
     $reject(Promise\resolve(1));
 }
开发者ID:im286er,项目名称:ent,代码行数:9,代码来源:RejectTestTrait.php

示例7: getValues

 /**
  * {@inheritdoc}
  */
 public function getValues() : PromiseInterface
 {
     $counters = $this->infoProvider->getCounters();
     $storage = new \SplObjectStorage();
     $storage->attach(new Metric('current_read_streams', (double) $counters['streams']['read']['current']));
     $storage->attach(new Metric('current_write_streams', (double) $counters['streams']['write']['current']));
     return resolve($storage);
 }
开发者ID:WyriHaximus,项目名称:reactphp-event-loop-inspector-phunin-node-plugin,代码行数:11,代码来源:Streams.php

示例8: create

 public function create($path, $unusedPort = 0)
 {
     $resource = @stream_socket_client('unix://' . $path, $errno, $errstr, 1.0);
     if (!$resource) {
         return Promise\reject(new RuntimeException('Unable to connect to unix domain socket "' . $path . '": ' . $errstr, $errno));
     }
     return Promise\resolve(new Stream($resource, $this->loop));
 }
开发者ID:gai00,项目名称:socket-client,代码行数:8,代码来源:UnixConnector.php

示例9: resolveShouldResolveWithPromisedValue

 /** @test */
 public function resolveShouldResolveWithPromisedValue()
 {
     $adapter = $this->getPromiseTestAdapter();
     $mock = $this->createCallableMock();
     $mock->expects($this->once())->method('__invoke')->with($this->identicalTo(1));
     $adapter->promise()->then($mock);
     $adapter->resolve(Promise\resolve(1));
 }
开发者ID:Masterfion,项目名称:plugin-sonos,代码行数:9,代码来源:ResolveTestTrait.php

示例10: checkConnectedSocket

 /** @internal */
 public function checkConnectedSocket($socket)
 {
     // The following hack looks like the only way to
     // detect connection refused errors with PHP's stream sockets.
     if (false === stream_socket_get_name($socket, true)) {
         return Promise\reject(new ConnectionException('Connection refused'));
     }
     return Promise\resolve($socket);
 }
开发者ID:verzulli,项目名称:palestra,代码行数:10,代码来源:TcpConnector.php

示例11: testResolvedWillNotStartTimer

 public function testResolvedWillNotStartTimer()
 {
     $promise = Promise\resolve();
     Timer\timeout($promise, 3, $this->loop);
     $time = microtime(true);
     $this->loop->run();
     $time = microtime(true) - $time;
     $this->assertLessThan(0.5, $time);
 }
开发者ID:clue,项目名称:promise-timeout,代码行数:9,代码来源:FunctionTimeoutTest.php

示例12: testAwaitOnceWithTimeoutWillResolvemmediatelyAndCleanUpTimeout

 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);
 }
开发者ID:clue,项目名称:block-react,代码行数:9,代码来源:FunctionAwaitTest.php

示例13: resolveSouldProvideDefaultErrorbackToExecutor

 /** @test */
 public function resolveSouldProvideDefaultErrorbackToExecutor()
 {
     $executor = $this->createExecutorMock();
     $executor->expects($this->once())->method('query')->with($this->anything(), $this->isInstanceOf('React\\Dns\\Query\\Query'))->will($this->returnCallback(function ($nameserver, $query) {
         return Promise\resolve();
     }));
     $resolver = new Resolver('8.8.8.8:53', $executor);
     $resolver->resolve('igor.io')->then($this->expectCallableNever());
 }
开发者ID:adam-fonseca,项目名称:RuneUI,代码行数:10,代码来源:ResolverTest.php

示例14: callQueryCallbackWithAddress

 private function callQueryCallbackWithAddress($address)
 {
     return $this->returnCallback(function ($nameserver, $query) use($address) {
         $response = new Message();
         $response->header->set('qr', 1);
         $response->questions[] = new Record($query->name, $query->type, $query->class);
         $response->answers[] = new Record($query->name, $query->type, $query->class, 3600, $address);
         return Promise\resolve($response);
     });
 }
开发者ID:adam-fonseca,项目名称:RuneUI,代码行数:10,代码来源:CachedExecutorTest.php

示例15: send

 /**
  * @param string $data
  * @return PromiseInterface
  * @throws Exception
  */
 public function send($data)
 {
     try {
         $this->connect();
         stream_set_blocking($this->sock, true);
         fwrite($this->sock, $data);
         return Promise\resolve();
     } catch (\Exception $e) {
         return Promise\reject($e);
     }
 }
开发者ID:jahudka,项目名称:react-mpd,代码行数:16,代码来源:Native.php


注:本文中的React\Promise\resolve函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。