@@ -60,6 +60,44 @@ public function testGetClientEntityReturnsNullIfNoRowReturned()
6060 );
6161 }
6262
63+ public function testGetClientEntityReturnsCorrectEntity ()
64+ {
65+ $ name = 'foo ' ;
66+ $ redirect = 'bar ' ;
67+
68+ $ statement = $ this ->prophesize (PDOStatement::class);
69+ $ statement ->bindParam (':clientIdentifier ' , 'client_id ' )->shouldBeCalled ();
70+ $ statement ->execute ()->will (function () use ($ statement , $ name , $ redirect ) {
71+ $ statement ->fetch ()->willReturn ([
72+ 'name ' => $ name ,
73+ 'redirect ' => $ redirect ,
74+ ]);
75+ return null ;
76+ });
77+
78+ $ this ->pdo
79+ ->prepare (Argument::containingString ('SELECT * FROM oauth_clients ' ))
80+ ->will ([$ statement , 'reveal ' ]);
81+
82+ $ this ->prophesize (ClientEntityInterface::class);
83+
84+ /** @var ClientEntityInterface $client */
85+ $ client = $ this ->repo ->getClientEntity ('client_id ' );
86+
87+ $ this ->assertInstanceOf (
88+ ClientEntityInterface::class,
89+ $ client
90+ );
91+ $ this ->assertEquals (
92+ $ name ,
93+ $ client ->getName ()
94+ );
95+ $ this ->assertEquals (
96+ [$ redirect ],
97+ $ client ->getRedirectUri ()
98+ );
99+ }
100+
63101 public function invalidGrants ()
64102 {
65103 return [
@@ -76,6 +114,30 @@ public function invalidGrants()
76114 ];
77115 }
78116
117+ public function testValidateClientReturnsFalseIfNoRowReturned ()
118+ {
119+ $ statement = $ this ->prophesize (PDOStatement::class);
120+ $ statement ->bindParam (':clientIdentifier ' , 'client_id ' )->shouldBeCalled ();
121+ $ statement ->execute ()->will (function () use ($ statement ) {
122+ $ statement ->fetch ()->willReturn ([]);
123+ return null ;
124+ });
125+
126+ $ this ->pdo
127+ ->prepare (Argument::containingString ('SELECT * FROM oauth_clients ' ))
128+ ->will ([$ statement , 'reveal ' ]);
129+
130+ $ client = $ this ->prophesize (ClientEntityInterface::class);
131+
132+ $ this ->assertFalse (
133+ $ this ->repo ->validateClient (
134+ 'client_id ' ,
135+ '' ,
136+ 'password '
137+ )
138+ );
139+ }
140+
79141 /**
80142 * @dataProvider invalidGrants
81143 */
0 commit comments