|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Tests\Functional; |
| 4 | + |
| 5 | +class IssueCommentTest extends TestCase |
| 6 | +{ |
| 7 | + /** |
| 8 | + * @test |
| 9 | + */ |
| 10 | + public function shouldRetrieveCommentsForIssue() |
| 11 | + { |
| 12 | + $username = 'KnpLabs'; |
| 13 | + $repo = 'php-github-api'; |
| 14 | + $issue = 13; |
| 15 | + |
| 16 | + $comments = $this->client->api('issue')->comments()->all($username, $repo, $issue); |
| 17 | + $comment = array_pop($comments); |
| 18 | + |
| 19 | + $this->assertArrayHasKey('id', $comment); |
| 20 | + $this->assertArrayHasKey('url', $comment); |
| 21 | + $this->assertArrayHasKey('body', $comment); |
| 22 | + $this->assertArrayHasKey('user', $comment); |
| 23 | + $this->assertArrayHasKey('created_at', $comment); |
| 24 | + $this->assertArrayHasKey('updated_at', $comment); |
| 25 | + |
| 26 | + return $comment['id']; |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * @test |
| 31 | + * @depends shouldRetrieveCommentsForIssue |
| 32 | + */ |
| 33 | + public function shouldRetrieveSingleComment($commentId) |
| 34 | + { |
| 35 | + $username = 'KnpLabs'; |
| 36 | + $repo = 'php-github-api'; |
| 37 | + |
| 38 | + $comment = $this->client->api('issue')->comments()->show($username, $repo, $commentId); |
| 39 | + |
| 40 | + $this->assertArrayHasKey('id', $comment); |
| 41 | + $this->assertArrayHasKey('url', $comment); |
| 42 | + $this->assertArrayHasKey('body', $comment); |
| 43 | + $this->assertArrayHasKey('user', $comment); |
| 44 | + $this->assertArrayHasKey('created_at', $comment); |
| 45 | + $this->assertArrayHasKey('updated_at', $comment); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @test |
| 50 | + */ |
| 51 | + public function shouldCreateCommentForIssue() |
| 52 | + { |
| 53 | + $username = 'KnpLabs'; |
| 54 | + $repo = 'php-github-api'; |
| 55 | + $issue = 13; |
| 56 | + $params = array('body' => '%'); |
| 57 | + |
| 58 | + $comment = $this->client->api('issue')->comments()->create($username, $repo, $issue, $params); |
| 59 | + |
| 60 | + $this->assertArrayHasKey('id', $comment); |
| 61 | + $this->assertArrayHasKey('url', $comment); |
| 62 | + $this->assertArrayHasKey('body', $comment); |
| 63 | + $this->assertArrayHasKey('user', $comment); |
| 64 | + $this->assertArrayHasKey('created_at', $comment); |
| 65 | + $this->assertArrayHasKey('updated_at', $comment); |
| 66 | + |
| 67 | + return $comment['id']; |
| 68 | + } |
| 69 | + /** |
| 70 | + * @test |
| 71 | + * @depends shouldCreateCommentForIssue |
| 72 | + */ |
| 73 | + public function shouldUpdateCommentByCommentId($commentId) |
| 74 | + { |
| 75 | + $username = 'KnpLabs'; |
| 76 | + $repo = 'php-github-api'; |
| 77 | + $params = array('body' => 'test update'); |
| 78 | + |
| 79 | + $comment = $this->client->api('issue')->comments()->update($username, $repo, $commentId, $params); |
| 80 | + |
| 81 | + $this->assertArrayHasKey('id', $comment); |
| 82 | + $this->assertArrayHasKey('url', $comment); |
| 83 | + $this->assertArrayHasKey('body', $comment); |
| 84 | + $this->assertArrayHasKey('user', $comment); |
| 85 | + $this->assertArrayHasKey('created_at', $comment); |
| 86 | + $this->assertArrayHasKey('updated_at', $comment); |
| 87 | + |
| 88 | + return $comment['id']; |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * @test |
| 93 | + * @depends shouldUpdateCommentByCommentId |
| 94 | + */ |
| 95 | + public function shouldRemoveCommentByCommentId($commentId) |
| 96 | + { |
| 97 | + $username = 'KnpLabs'; |
| 98 | + $repo = 'php-github-api'; |
| 99 | + |
| 100 | + $this->client->api('issue')->comments()->remove($username, $repo, $commentId); |
| 101 | + } |
| 102 | +} |
0 commit comments