/** * @param PushPayload $pushPayload * * @throws Exception * * @return BranchHandler|TagHandler */ private function getHandler(PushPayload $pushPayload) { if ($pushPayload->isBranch()) { return $this->branchHandler; } elseif ($pushPayload->isTag()) { return $this->tagHandler; } throw new Exception('Unsupported push payload: payload should be branch or tag!'); }
/** * @dataProvider provideDeletedBranch * * @param $data * * @throws \Exception */ public function testDeleteBranch($data) { $payload = new PushPayload($data); $this->assertTrue($payload->isBranch()); $this->assertTrue($payload->isDelete()); $this->assertSame(PushPayload::DELETED, $payload->getType()); $this->assertFalse($payload->isTag()); $this->assertFalse($payload->isCreate()); $this->assertFalse($payload->isUpdate()); }
public function it_will_throw_exception_if_not_branch_or_tag_push_event(PushPayload $pushPayload) { $pushPayload->isBranch()->willReturn(false); $pushPayload->isTag()->willReturn(false); $this->shouldThrow('Exception')->duringProcess($pushPayload); }