File tree Expand file tree Collapse file tree 4 files changed +119
-0
lines changed Expand file tree Collapse file tree 4 files changed +119
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ A simple PHP wrapper for Bitbucket API.
2424 * [ Services] ( repositories/services.md )
2525 * [ Src] ( repositories/src.md )
2626 * [ Wiki] ( repositories/wiki.md )
27+ * [ Teams] ( teams.md ) (API 2.0)
2728* [ User] ( user.md )
2829 * [ Repositories] ( user/repositories.md )
2930* [ Users] ( users.md )
Original file line number Diff line number Diff line change 1+ ## Teams
2+
3+ ----
4+ Get Team related information.
5+
6+ ### Prepare:
7+ ``` php
8+ $team = new Bitbucket\API\Teams();
9+ $team->setCredentials( new Bitbucket\API\Authentication\Basic($bb_user, $bb_pass) );
10+ ```
11+
12+ ### Get the team profile: (API 2.0)
13+ ``` php
14+ $team->profile($team_name);
15+ ```
16+
17+ ### Get the team members: (API 2.0)
18+ ``` php
19+ $team->members($team_name);
20+ ```
21+
22+ ----
23+
24+ #### Related:
25+ * [ Authentication] ( authentication.md )
26+ * [ BB Wiki] ( https://confluence.atlassian.com/x/XwZAGQ )
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * This file is part of the bitbucket-api package.
5+ *
6+ * (c) Alexandru G. <alex@gentle.ro>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Bitbucket \API ;
13+
14+ use Buzz \Message \MessageInterface ;
15+
16+ /**
17+ * @author Alexandru G. <alex@gentle.ro>
18+ */
19+ class Teams extends Api
20+ {
21+ /**
22+ * Get the public information associated with a team.
23+ *
24+ * @access public
25+ * @param string $name The team's name.
26+ * @return MessageInterface
27+ */
28+ public function profile ($ name )
29+ {
30+ return $ this ->getClient ()->setApiVersion ('2.0 ' )->get (
31+ sprintf ('teams/%s ' , $ name )
32+ );
33+ }
34+
35+ /**
36+ * Get the team members.
37+ *
38+ * @access public
39+ * @param string $name The team's name.
40+ * @return MessageInterface
41+ */
42+ public function members ($ name )
43+ {
44+ return $ this ->getClient ()->setApiVersion ('2.0 ' )->get (
45+ sprintf ('teams/%s/members ' , $ name )
46+ );
47+ }
48+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bitbucket \Tests \API ;
4+
5+ use Bitbucket \Tests \API as Tests ;
6+
7+ class TeamsTest extends Tests \TestCase
8+ {
9+ public function testGetTeamProfile ()
10+ {
11+ $ endpoint = 'teams/gentle-web ' ;
12+ $ expectedResult = $ this ->fakeResponse (array ('dummy ' ));
13+
14+ $ client = $ this ->getHttpClientMock ();
15+ $ client ->expects ($ this ->once ())
16+ ->method ('get ' )
17+ ->with ($ endpoint )
18+ ->will ($ this ->returnValue ($ expectedResult ));
19+
20+ /** @var \Bitbucket\API\Teams $team */
21+ $ team = $ this ->getClassMock ('Bitbucket\API\Teams ' , $ client );
22+ $ actual = $ team ->profile ('gentle-web ' );
23+
24+ $ this ->assertEquals ($ expectedResult , $ actual );
25+ }
26+
27+ public function testGetTeamMembers ()
28+ {
29+ $ endpoint = 'teams/gentle-web/members ' ;
30+ $ expectedResult = $ this ->fakeResponse (array ('dummy ' ));
31+
32+ $ client = $ this ->getHttpClientMock ();
33+ $ client ->expects ($ this ->once ())
34+ ->method ('get ' )
35+ ->with ($ endpoint )
36+ ->will ($ this ->returnValue ($ expectedResult ));
37+
38+ /** @var \Bitbucket\API\Teams $team */
39+ $ team = $ this ->getClassMock ('Bitbucket\API\Teams ' , $ client );
40+ $ actual = $ team ->members ('gentle-web ' );
41+
42+ $ this ->assertEquals ($ expectedResult , $ actual );
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments