Пример #1
0
 public function it_will_handle_delete_tag_push_event($tagHandler, PushPayload $pushPayload)
 {
     $pushPayload->isBranch()->willReturn(false);
     $pushPayload->isTag()->willReturn(true);
     $pushPayload->isCreate()->willReturn(false);
     $pushPayload->isUpdate()->willReturn(false);
     $pushPayload->isDelete()->willReturn(true);
     $tagHandler->delete($pushPayload)->willReturn(true)->shouldBeCalled();
     $this->process($pushPayload)->shouldReturn(true);
 }
Пример #2
0
 /**
  * @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());
 }
Пример #3
0
 /**
  * @param PushPayload $pushPayload
  *
  * @throws Exception
  *
  * @return bool
  */
 public function process(PushPayload $pushPayload)
 {
     if ($pushPayload->isCreate()) {
         return $this->getHandler($pushPayload)->create($pushPayload);
     } elseif ($pushPayload->isUpdate()) {
         return $this->getHandler($pushPayload)->update($pushPayload);
     } elseif ($pushPayload->isDelete()) {
         return $this->getHandler($pushPayload)->delete($pushPayload);
     } else {
         throw new Exception('Unsupported push payload: payload should be create/update/delete!');
     }
 }