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