Ejemplo n.º 1
0
 /**
  * This will update the comment vote if there is a -1 or +1 found.
  * We'll take the positive vote in case there is an off chance
  * where both are found.
  */
 private function parseForVotes()
 {
     $voter = new Voter($this->username(), $this->avatar());
     if (str_contains($this->body, '-1')) {
         $this->vote = 'n';
         $this->gist->setNegativeVote($voter);
     }
     if (str_contains($this->body, '+1')) {
         $this->vote = 'y';
         $this->gist->setPositiveVote($voter);
     }
 }
Ejemplo n.º 2
0
 /** @test */
 public function it_should_return_correct_votes_gh()
 {
     list($eloquentGist, $githubGist) = $this->buildGithubGist();
     $gistFromGithub = Gist::fromGitHub($eloquentGist, $githubGist);
     $this->assertCount(0, $gistFromGithub->getPositiveVotes());
     $this->assertCount(1, $gistFromGithub->getNegativeVotes());
 }
Ejemplo n.º 3
0
 /**
  * Returns a collection of correctly formed gist objects.
  *
  * @param $gists
  * @return Collection
  */
 protected function createGistCollection($gists)
 {
     return collect($gists)->map(function ($gist) {
         return Gist::fromEloquent($gist);
     });
 }