コード例 #1
0
 public function testRegisterClient()
 {
     $this->clientRepository->expects($this->once())->method('idExists')->willReturn(false);
     $this->clientRepository->expects($this->once())->method('save')->will($this->returnArgument(0));
     list($client, $secret) = $this->clientService->registerClient('name', ['http://www.example.com']);
     $this->assertEquals(60, strlen($client->getSecret()));
     $this->assertEquals(40, strlen($secret));
 }
コード例 #2
0
 public function testRegisterClient()
 {
     $client = new Client();
     $this->clientRepository->expects($this->once())->method('save')->with($client)->willReturn($client);
     list($client, $secret) = $this->clientService->registerClient($client);
     $this->assertEquals(60, strlen($client->getSecret()));
     $this->assertEquals(40, strlen($secret));
     $this->assertFalse($this->clientService->authenticate($client, 'azerty'));
     $this->assertTrue($this->clientService->authenticate($client, $secret));
     $this->assertFalse($this->clientService->authenticate($client, $client->getSecret()));
 }
コード例 #3
0
 /**
  * Get the client using its id
  *
  * @param  string $id
  * @return Client|null
  */
 public function getClient(string $id)
 {
     return $this->clientRepository->findById($id);
 }