public function it_authenticate_credentials(CredentialInterface $credential, BetfairGuzzleClient $betfairHttpClient, Response $response) { $credential->getUsername()->shouldBeCalled()->willReturn('usr1'); $credential->getPassword()->shouldBeCalled()->willReturn('pwd1'); $credential->getApplicationKey()->shouldBeCalled()->willReturn('appkey'); $expectedLoginGuzzleParameters = array('X-Application' => 'appkey', 'username' => 'usr1', 'password' => 'pwd1'); $betfairHttpClient->betfairLogin($expectedLoginGuzzleParameters)->shouldBeCalled()->willReturn($response); $response->getStatusCode()->shouldBeCalled()->willReturn(200); $response->getBody()->shouldBeCalled()->willReturn(json_encode(array("status" => "SUCCESS", "token" => "12345"))); $credential->setSessionToken("12345")->shouldBeCalled(); $this->authenticateCredential(); }
/** * Login and set the sessionToken in Credential object */ public function authenticateCredential() { $sessionToken = $this->login(); $this->credential->setSessionToken($sessionToken); }