@@ -30,9 +30,9 @@ public function shouldPassHttpClientInterfaceToConstructor()
30
30
31
31
/**
32
32
* @test
33
- * @dataProvider getAuthenticationData
33
+ * @dataProvider getAuthenticationFullData
34
34
*/
35
- public function shouldAuthenticateUsingGivenParameters ($ login , $ password , $ method )
35
+ public function shouldAuthenticateUsingAllGivenParameters ($ login , $ password , $ method )
36
36
{
37
37
$ httpClient = $ this ->getHttpClientMock (array ('addListener ' ));
38
38
$ httpClient ->expects ($ this ->once ())
@@ -43,17 +43,51 @@ public function shouldAuthenticateUsingGivenParameters($login, $password, $metho
43
43
$ client ->authenticate ($ login , $ password , $ method );
44
44
}
45
45
46
- public function getAuthenticationData ()
46
+ public function getAuthenticationFullData ()
47
47
{
48
48
return array (
49
- array ('login ' , null , null ),
50
49
array ('login ' , 'password ' , Client::AUTH_HTTP_PASSWORD ),
51
50
array ('token ' , null , Client::AUTH_HTTP_TOKEN ),
52
51
array ('token ' , null , Client::AUTH_URL_TOKEN ),
53
52
array ('client_id ' , 'client_secret ' , Client::AUTH_URL_CLIENT_ID ),
54
53
);
55
54
}
56
55
56
+ /**
57
+ * @test
58
+ * @dataProvider getAuthenticationPartialData
59
+ */
60
+ public function shouldAuthenticateUsingGivenParameters ($ token , $ method )
61
+ {
62
+ $ httpClient = $ this ->getHttpClientMock (array ('addListener ' ));
63
+ $ httpClient ->expects ($ this ->once ())
64
+ ->method ('addListener ' )
65
+ ->with (new AuthListener ($ method , array ('tokenOrLogin ' => $ token , 'password ' => null )));
66
+
67
+ $ client = new Client ($ httpClient );
68
+ $ client ->authenticate ($ token , $ method );
69
+ }
70
+
71
+ public function getAuthenticationPartialData ()
72
+ {
73
+ return array (
74
+ array ('token ' , Client::AUTH_HTTP_TOKEN ),
75
+ array ('token ' , Client::AUTH_URL_TOKEN ),
76
+ );
77
+ }
78
+
79
+ /**
80
+ * @test
81
+ * @expectedException InvalidArgumentException
82
+ */
83
+ public function shouldThrowExceptionWhenAuthenticatingWithoutMethodSet ()
84
+ {
85
+ $ httpClient = $ this ->getHttpClientMock (array ('addListener ' ));
86
+
87
+ $ client = new Client ($ httpClient );
88
+ $ client ->authenticate ('login ' , null , null );
89
+ }
90
+
57
91
/**
58
92
* @test
59
93
*/
0 commit comments