/** * Set a SHA in GitHub to a state * * @param string $organisation * @param string $repository * @param GitHubMessage $message */ public function updateStatus(string $organisation, string $repository, GitHubMessage $message) { $status = $message->getHighestWeightStatus(); /** @var Repo $repoApi */ $repoApi = $this->client->repo(); /** @var Statuses $statusesApi */ $statusesApi = $repoApi->statuses(); $state = self::GITHUB_STATUS_SUCCESS; if (!$status->isPositive()) { $state = self::GITHUB_STATUS_FAILURE; } $statusesApi->create($organisation, $repository, $message->getSha(), ['state' => $state, 'description' => $status->getMessage(), 'context' => self::CONTEXT, 'target_url' => $status->getDetailsUrl()]); }
function it_passes_the_highest_weight_status_to_github(Client $client, Repo $repo, Statuses $statuses, GitHubMessage $message) { $this->beConstructedWith($client); $client->repo()->willReturn($repo); $repo->statuses()->willReturn($statuses); $organisation = "organisation"; $repository = "repository"; $status = new SuccessStatus(); $message->getSha()->willReturn("a224"); $message->getHighestWeightStatus()->willReturn($status); $statuses->create($organisation, $repository, "a224", ['state' => 'success', 'description' => $status->getMessage(), 'context' => StatusSendServiceImplementation::CONTEXT, 'target_url' => $status->getDetailsUrl()])->shouldBeCalled(); $this->updateStatus($organisation, $repository, $message); }