/** * Send a keepalive request. * @return mixed|null */ protected function keepAlive() { if (!$this->phx->serviceTokenID()) { return null; } return $this->get('system/session/' . $this->phx->serviceTokenID()); }
/** * Test logging in as a test customer. */ public function test_customer_login() { $response = $this->phx->customer->login(self::TEST_CUSTOMER_USER, self::TEST_CUSTOMER_PASS, self::TEST_CUSTOMER_ANSWER); // The response should return an access token and a customer ID. // The login method will set those variables globally. $this->assertEquals($this->phx->customerTokenID(), $response->access_token); $this->assertEquals($this->phx->customerID(), $response->customer_id); // Our service token should still be set. $this->assertNotEmpty($this->phx->serviceTokenID()); // We should get a security question back. $question = $this->phx->customer->securityQuestion(self::TEST_CUSTOMER_USER); $this->assertNotEmpty($question('0.question_id')); $this->assertNotEmpty($question('0.question_text')); // We should get a customer object back, once we're logged in. $customer = $this->phx->customer->getObject(); $this->assertInstanceOf('\\PHX\\Models\\Customer', $customer); $this->assertEquals($customer->id(), $this->phx->customerID()); // Check for Login method $this->assertTrue($this->phx->isLoggedIn()); }