22
33namespace Github \Tests \Functional ;
44
5- use Github \Client ;
6-
7- class UsetTest extends \PHPUnit_Framework_TestCase
5+ class UsetTest extends TestCase
86{
97 /**
108 * @test
@@ -13,8 +11,7 @@ public function shouldShowUserData()
1311 {
1412 $ username = 'KnpLabs ' ;
1513
16- $ github = new Client ();
17- $ user = $ github ->api ('user ' )->show ($ username );
14+ $ user = $ this ->client ->api ('user ' )->show ($ username );
1815
1916 $ this ->assertArrayHasKey ('id ' , $ user );
2017 $ this ->assertEquals ('KnpLabs ' , $ user ['login ' ]);
@@ -36,8 +33,7 @@ public function shouldShowUserData()
3633 */
3734 public function shouldNotUpdateUserWithoutAuthorization ()
3835 {
39- $ github = new Client ();
40- $ github ->api ('current_user ' )->update (array ('email ' => 'leszek.prabucki@gmail.com ' ));
36+ $ this ->client ->api ('current_user ' )->update (array ('email ' => 'leszek.prabucki@gmail.com ' ));
4137 }
4238
4339 /**
@@ -47,8 +43,7 @@ public function shouldGetUsersWhoUserIsFollowing()
4743 {
4844 $ username = 'l3l0 ' ;
4945
50- $ github = new Client ();
51- $ users = $ github ->api ('user ' )->following ($ username );
46+ $ users = $ this ->client ->api ('user ' )->following ($ username );
5247 $ user = array_pop ($ users );
5348
5449 $ this ->assertArrayHasKey ('id ' , $ user );
@@ -62,8 +57,12 @@ public function shouldGetFollowersUsers()
6257 {
6358 $ username = 'KnpLabs ' ;
6459
65- $ github = new Client ();
66- $ users = $ github ->api ('user ' )->followers ($ username );
60+ $ this ->client = new Client ();
61+ try {
62+ $ users = $ this ->client ->api ('user ' )->followers ($ username );
63+ } catch (ApiLimitExceedException $ e ) {
64+ $ this ->markTestSkipped ('API limit reached. Skipping to prevent unnecessary failure. ' );
65+ }
6766 $ user = array_pop ($ users );
6867
6968 $ this ->assertArrayHasKey ('id ' , $ user );
@@ -76,8 +75,7 @@ public function shouldGetFollowersUsers()
7675 */
7776 public function shouldNotFollowUserWithoutAuthorization ()
7877 {
79- $ github = new Client ();
80- $ github ->api ('current_user ' )->follow ()->follow ('KnpLabs ' );
78+ $ this ->client ->api ('current_user ' )->follow ()->follow ('KnpLabs ' );
8179 }
8280
8381 /**
@@ -86,8 +84,7 @@ public function shouldNotFollowUserWithoutAuthorization()
8684 */
8785 public function shouldNotUnfollowUserWithoutAuthorization ()
8886 {
89- $ github = new Client ();
90- $ github ->api ('current_user ' )->follow ()->unfollow ('KnpLabs ' );
87+ $ this ->client ->api ('current_user ' )->follow ()->unfollow ('KnpLabs ' );
9188 }
9289
9390 /**
@@ -97,8 +94,7 @@ public function shouldGetReposBeingWatched()
9794 {
9895 $ username = 'l3l0 ' ;
9996
100- $ github = new Client ();
101- $ repos = $ github ->api ('user ' )->watched ($ username );
97+ $ repos = $ this ->client ->api ('user ' )->watched ($ username );
10298 $ repo = array_pop ($ repos );
10399
104100 $ this ->assertArrayHasKey ('id ' , $ repo );
0 commit comments