Exemple #1
0
 public function testItErrorsWhenAuthenticateFails()
 {
     $response = $this->getMock('Rvdv\\Nntp\\Response\\ResponseInterface');
     $response->expects($this->exactly(2))->method('getStatusCode')->will($this->returnValue(Response::AUTHENTICATION_REJECTED));
     $command = $this->getMock('Rvdv\\Nntp\\Command\\CommandInterface');
     $command->expects($this->once())->method('getResponse')->will($this->returnvalue($response));
     $connection = $this->getMock('Rvdv\\Nntp\\Connection\\ConnectionInterface', ['connect', 'disconnect', 'sendCommand', 'sendArticle']);
     $connection->expects($this->once())->method('sendCommand')->with($this->logicalAnd($this->isInstanceOf('Rvdv\\Nntp\\Command\\AuthInfoCommand'), $this->attributeEqualTo('type', AuthInfoCommand::AUTHINFO_USER), $this->attributeEqualTo('value', 'unknown')))->will($this->returnValue($command));
     $client = new Client($connection);
     try {
         $client->authenticate('unknown');
         $this->fail('->authenticate() throws a Rvdv\\Nntp\\Exception\\RuntimeException because incorrect credentials are given');
     } catch (\Exception $e) {
         $this->assertInstanceof('Rvdv\\Nntp\\Exception\\RuntimeException', $e, '->authenticate() throws a Rvdv\\Nntp\\Exception\\RuntimeException because incorrect credentials are given');
     }
 }