/**
  * Most of the logic for ID token validation is in AuthTest -
  * this is just a general check to ensure we verify a valid
  * id token if one exists.
  */
 public function testValidateIdToken()
 {
     $this->checkToken();
     $client = $this->getClient();
     $token = $client->getAccessToken();
     if ($client->isAccessTokenExpired()) {
         $token = $client->fetchAccessTokenWithRefreshToken();
     }
     $segments = explode('.', $token['id_token']);
     $this->assertEquals(3, count($segments));
     // Extract the client ID in this case as it wont be set on the test client.
     $data = json_decode(JWT::urlSafeB64Decode($segments[1]));
     $verify = new Google_AccessToken_Verify();
     $payload = $verify->verifyIdToken($token['id_token'], $data->aud);
     $this->assertTrue(isset($payload['sub']));
     $this->assertTrue(strlen($payload['sub']) > 0);
     // TODO: Need to be smart about testing/disabling the
     // caching for this test to make sense. Not sure how to do that
     // at the moment.
     $client = $this->getClient();
     $data = json_decode(JWT::urlSafeB64Decode($segments[1]));
     $verify = new Google_AccessToken_Verify();
     $payload = $verify->verifyIdToken($token['id_token'], $data->aud);
     $this->assertTrue(isset($payload['sub']));
     $this->assertTrue(strlen($payload['sub']) > 0);
 }