@@ -48,4 +48,57 @@ public function testGetLoginUrl()
4848 $ actual = $ this ->client ->getLoginUrl ();
4949 $ this ->assertNotEmpty ($ actual );
5050 }
51+
52+ /**
53+ * Make sure that method LinkedIn\Client::setAccessToken() works correctly
54+ *
55+ * @param $token
56+ * @param AccessToken|null $expectedToken
57+ * @param \Exception|null $expectedException
58+ *
59+ * @dataProvider getSetAccessTokenTestTable
60+ */
61+ public function testSetAccessToken ($ token , $ expectedToken , $ expectedException )
62+ {
63+ $ client = new Client ();
64+
65+ if ($ expectedException !== null ) {
66+ $ this ->setExpectedException (get_class ($ expectedException ), $ expectedException ->getMessage ());
67+ }
68+
69+ $ client ->setAccessToken ($ token );
70+
71+ if ($ expectedToken !== null ) {
72+ $ this ->assertEquals ($ expectedToken ->getToken (), $ client ->getAccessToken ()->getToken ());
73+ }
74+ }
75+
76+ public function getSetAccessTokenTestTable ()
77+ {
78+ return [
79+ [
80+ 'token ' => null ,
81+ 'expectedToken ' => null ,
82+ 'expectedException ' => new \InvalidArgumentException ('$accessToken must be instance of \LinkedIn\AccessToken class ' ),
83+ ],
84+
85+ [
86+ 'token ' => 'test token ' ,
87+ 'expectedToken ' => new AccessToken ('test token ' ),
88+ 'expectedException ' => null ,
89+ ],
90+
91+ [
92+ 'token ' => new AccessToken ('hello world ' ),
93+ 'expectedToken ' => new AccessToken ('hello world ' ),
94+ 'expectedException ' => null ,
95+ ],
96+
97+ [
98+ 'token ' => new \StdClass (),
99+ 'expectedToken ' => null ,
100+ 'expectedException ' => new \InvalidArgumentException ('$accessToken must be instance of \LinkedIn\AccessToken class ' ),
101+ ],
102+ ];
103+ }
51104}
0 commit comments