@@ -24,14 +24,14 @@ public function shouldServeCachedResponse()
24
24
$ mockClient ->addResponse ($ this ->getCurrentUserResponse ('octocat ' ));
25
25
26
26
$ github = Client::createWithHttpClient ($ mockClient );
27
- $ github ->addCache (new ArrayCachePool (), ['default_ttl ' =>60 ]);
27
+ $ github ->addCache (new ArrayCachePool (), ['default_ttl ' =>600 ]);
28
28
29
29
$ github ->authenticate ('fake_token_aaa ' , Client::AUTH_HTTP_TOKEN );
30
30
$ userA = $ github ->currentUser ()->show ();
31
31
$ this ->assertEquals ('nyholm ' , $ userA ['login ' ]);
32
32
33
33
$ userB = $ github ->currentUser ()->show ();
34
- $ this ->assertEquals ('nyholm ' , $ userB ['login ' ]);
34
+ $ this ->assertEquals ('nyholm ' , $ userB ['login ' ], ' Two request following each other should be cached. ' );
35
35
}
36
36
/**
37
37
* @test
@@ -43,15 +43,15 @@ public function shouldVaryOnAuthorization()
43
43
$ mockClient ->addResponse ($ this ->getCurrentUserResponse ('octocat ' ));
44
44
45
45
$ github = Client::createWithHttpClient ($ mockClient );
46
- $ github ->addCache (new ArrayCachePool (), ['default_ttl ' =>60 ]);
46
+ $ github ->addCache (new ArrayCachePool (), ['default_ttl ' =>600 ]);
47
47
48
48
$ github ->authenticate ('fake_token_aaa ' , Client::AUTH_HTTP_TOKEN );
49
49
$ userA = $ github ->currentUser ()->show ();
50
50
$ this ->assertEquals ('nyholm ' , $ userA ['login ' ]);
51
51
52
52
$ github ->authenticate ('fake_token_bbb ' , Client::AUTH_HTTP_TOKEN );
53
53
$ userB = $ github ->currentUser ()->show ();
54
- $ this ->assertEquals ('octocat ' , $ userB ['login ' ]);
54
+ $ this ->assertEquals ('octocat ' , $ userB ['login ' ], ' We must vary on the Authorization header. ' );
55
55
}
56
56
57
57
private function getCurrentUserResponse ($ username )
@@ -62,47 +62,6 @@ private function getCurrentUserResponse($username)
62
62
63
63
$ body = stream_for (json_encode ([
64
64
'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
- ],
106
65
]));
107
66
108
67
return new Response (200 , $ headers , $ body );
0 commit comments