In the asymmetric coroutine model, "asymmetry" refers to the fact that there is a stack-like caller–callee relationship between coroutines. A coroutine can either call another coroutine or suspend itself by yielding control to its caller, typically also yielding a value to the caller at the same time.
However, if it were possible to pass values or exceptions into a generator at the point where it was suspended, a simple co-routine scheduler or trampoline function would let coroutines call each other without blocking -- a tremendous boon for asynchronous applications.
GitHub Actions execute in Docker containers. An action can use an existing publicly available Docker image, or you can create your own Docker image by including a Dockerfile with your code.
「masterブランチでフィルタ」をしているのは、 Masterのactionですね。
ついでにというか、さっき疑問だった「どうやって外部のイメージをactionに定義するのか」もこれで解消しました。 use に指定するんですね。そして、依存関係にあるactionは前ステップにあたるあactionをneedsとして宣言する、と。
<?phpnamespace App;
use GuzzleHttp\Client;
use Psr\Http\Message\ResponseInterface;
/** * Class HogeService * @package App */class HogeService
{/** * HogeService constructor */publicfunction__construct(){$this->http =new Client();
}/** * Request user object to Hoge * * @param int $id user id to request * @return ResponseInterface */publicfunction getUser(int$id){return$this->http->get("/user/{$id}");
}}
<?phpnamespace App;
use GuzzleHttp\Client;
use Psr\Http\Message\ResponseInterface;
/** * Class HogeService * @package App */class HogeService
{/** * HogeService constructor */publicfunction__construct($client=null){$this->http =$client??new Client();
}/** * Request user object to Hoge * * @param int $id user id to requestc * @return ResponseInterface */publicfunction getUser(int$id){return$this->http->get("/user/{$id}");
}}
ここに、説明用にいろいろとテストケースを追加していきます。
1. PHPUnit MockObjectのpartial mockを用いた例
まずは、以下の内容で検査をできると考えました。
HogeService::getUser($userId)の呼び出し実行時に
Client::get()に対して
/user/:user_id を引数として
呼び出しが1回行われている
これをもって、「ちゃんとHogeをキックできている」と判断することとします
素直に書いてしまえば、この様になりました。
<?php/** * test to get() */publicfunction testGet(){$userId=100;
/** @var MockObject|HogeService $mock */$httpMock=$this->createPartialMock(Client::class, ['get']);
$httpMock->expects($this->once())->method('get')->with("/user/{$userId}");
$this->subject->http =$httpMock;
$this->subject->getUser($userId);
}