@@ -24,14 +24,14 @@ public function shouldServeCachedResponse()
2424 $ mockClient ->addResponse ($ this ->getCurrentUserResponse ('octocat ' ));
2525
2626 $ github = Client::createWithHttpClient ($ mockClient );
27- $ github ->addCache (new ArrayCachePool (), ['default_ttl ' =>60 ]);
27+ $ github ->addCache (new ArrayCachePool (), ['default_ttl ' =>600 ]);
2828
2929 $ github ->authenticate ('fake_token_aaa ' , Client::AUTH_HTTP_TOKEN );
3030 $ userA = $ github ->currentUser ()->show ();
3131 $ this ->assertEquals ('nyholm ' , $ userA ['login ' ]);
3232
3333 $ userB = $ github ->currentUser ()->show ();
34- $ this ->assertEquals ('nyholm ' , $ userB ['login ' ]);
34+ $ this ->assertEquals ('nyholm ' , $ userB ['login ' ], ' Two request following each other should be cached. ' );
3535 }
3636 /**
3737 * @test
@@ -43,15 +43,15 @@ public function shouldVaryOnAuthorization()
4343 $ mockClient ->addResponse ($ this ->getCurrentUserResponse ('octocat ' ));
4444
4545 $ github = Client::createWithHttpClient ($ mockClient );
46- $ github ->addCache (new ArrayCachePool (), ['default_ttl ' =>60 ]);
46+ $ github ->addCache (new ArrayCachePool (), ['default_ttl ' =>600 ]);
4747
4848 $ github ->authenticate ('fake_token_aaa ' , Client::AUTH_HTTP_TOKEN );
4949 $ userA = $ github ->currentUser ()->show ();
5050 $ this ->assertEquals ('nyholm ' , $ userA ['login ' ]);
5151
5252 $ github ->authenticate ('fake_token_bbb ' , Client::AUTH_HTTP_TOKEN );
5353 $ userB = $ github ->currentUser ()->show ();
54- $ this ->assertEquals ('octocat ' , $ userB ['login ' ]);
54+ $ this ->assertEquals ('octocat ' , $ userB ['login ' ], ' We must vary on the Authorization header. ' );
5555 }
5656
5757 private function getCurrentUserResponse ($ username )
@@ -62,47 +62,6 @@ private function getCurrentUserResponse($username)
6262
6363 $ body = stream_for (json_encode ([
6464 'login ' => $ username ,
65- 'id ' => 1 ,
66- 'avatar_url ' => 'https://github.com/images/error/ ' .$ username .'_happy.gif ' ,
67- 'gravatar_id ' => '' ,
68- 'url ' => 'https://api.github.com/users/ ' .$ username ,
69- 'html_url ' => 'https://github.com/ ' .$ username ,
70- 'followers_url ' => 'https://api.github.com/users/ ' .$ username .'/followers ' ,
71- 'following_url ' => 'https://api.github.com/users/ ' .$ username .'/following{/other_user} ' ,
72- 'gists_url ' => 'https://api.github.com/users/ ' .$ username .'/gists{/gist_id} ' ,
73- 'starred_url ' => 'https://api.github.com/users/ ' .$ username .'/starred{/owner}{/repo} ' ,
74- 'subscriptions_url ' => 'https://api.github.com/users/ ' .$ username .'/subscriptions ' ,
75- 'organizations_url ' => 'https://api.github.com/users/ ' .$ username .'/orgs ' ,
76- 'repos_url ' => 'https://api.github.com/users/ ' .$ username .'/repos ' ,
77- 'events_url ' => 'https://api.github.com/users/ ' .$ username .'/events{/privacy} ' ,
78- 'received_events_url ' => 'https://api.github.com/users/ ' .$ username .'/received_events ' ,
79- 'type ' => 'User ' ,
80- 'site_admin ' => false ,
81- 'name ' => 'monalisa ' .$ username ,
82- 'company ' => 'GitHub ' ,
83- 'blog ' => 'https://github.com/blog ' ,
84- 'location ' => 'San Francisco ' ,
85- 'email ' => $ username .'@github.com ' ,
86- 'hireable ' => false ,
87- 'bio ' => 'There once was... ' ,
88- 'public_repos ' => 2 ,
89- 'public_gists ' => 1 ,
90- 'followers ' => 20 ,
91- 'following ' => 0 ,
92- 'created_at ' => '2008-01-14T04:33:35Z ' ,
93- 'updated_at ' => '2008-01-14T04:33:35Z ' ,
94- 'total_private_repos ' => 100 ,
95- 'owned_private_repos ' => 100 ,
96- 'private_gists ' => 81 ,
97- 'disk_usage ' => 10000 ,
98- 'collaborators ' => 8 ,
99- 'two_factor_authentication ' => true ,
100- 'plan ' => [
101- 'name ' => 'Medium ' ,
102- 'space ' => 400 ,
103- 'private_repos ' => 20 ,
104- 'collaborators ' => 0 ,
105- ],
10665 ]));
10766
10867 return new Response (200 , $ headers , $ body );
0 commit comments