File tree Expand file tree Collapse file tree 3 files changed +55
-2
lines changed
lib/Bitbucket/API/Repositories
test/Bitbucket/Tests/API/Repositories Expand file tree Collapse file tree 3 files changed +55
-2
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ require_once __DIR__ .'/../../vendor/autoload.php ' ;
4+
5+ $ pullRequests = new Bitbucket \API \Repositories \PullRequests ;
6+
7+ // Your Bitbucket credentials
8+ $ bb_user = 'username ' ;
9+ $ bb_pass = 'password ' ;
10+
11+ /**
12+ * $accountname The team or individual account owning the repository.
13+ * repo_slub The repository identifier.
14+ */
15+ $ accountname = 'company ' ;
16+ $ repo_slug = 'sandbox ' ;
17+
18+ // login
19+ $ pullRequests ->setCredentials ( new Bitbucket \API \Authentication \Basic ($ bb_user , $ bb_pass ) );
20+
21+ # get list of pull requests
22+ print_r ($ pullRequests ->all ($ accountname , $ repo_slug ));
Original file line number Diff line number Diff line change @@ -33,4 +33,21 @@ public function comments()
3333 {
3434 return $ this ->childFactory ('Repositories \\PullRequests \\Comments ' );
3535 }
36+
37+ /**
38+ * Get a list of pull requests
39+ *
40+ * @access public
41+ * @param string $account The team or individual account owning the repository.
42+ * @param string $repo The repository identifier.
43+ * @return mixed
44+ */
45+ public function all ($ account , $ repo )
46+ {
47+ $ this ->httpClient ->setApiVersion ('2.0 ' );
48+
49+ return $ this ->requestGet (
50+ sprintf ('repositories/%s/%s/pullrequests ' , $ account , $ repo )
51+ );
52+ }
3653}
Original file line number Diff line number Diff line change 1010 */
1111class PullRequestsTest extends Tests \TestCase
1212{
13- public function testDummy ()
14- {}
13+ public function testGetAllPullRequests ()
14+ {
15+ $ endpoint = 'repositories/gentle/eof/pullrequests ' ;
16+ $ expectedResult = json_encode ('dummy ' );
17+
18+ $ pullRequests = $ this ->getApiMock ('Bitbucket\API\Repositories\PullRequests ' );
19+ $ pullRequests ->expects ($ this ->once ())
20+ ->method ('requestGet ' )
21+ ->with ($ endpoint )
22+ ->will ( $ this ->returnValue ($ expectedResult ) );
23+
24+ /** @var $pullRequests \Bitbucket\API\Repositories\PullRequests */
25+ $ actual = $ pullRequests ->all ('gentle ' , 'eof ' );
26+
27+ $ this ->assertEquals ($ expectedResult , $ actual );
28+ }
1529}
You can’t perform that action at this time.
0 commit comments