public function testGetServiceAccountName() { $req = new \google\appengine\GetServiceAccountNameRequest(); $service_account_result = '*****@*****.**'; $resp = new \google\appengine\GetServiceAccountNameResponse(); $resp->setServiceAccountName($service_account_result); $this->apiProxyMock->expectCall('app_identity_service', 'GetServiceAccountName', $req, $resp); $service_account = AppIdentityService::getServiceAccountName(); $this->assertEquals($service_account, $service_account_result); $this->apiProxyMock->verify(); }
/** * Get the default email address for App Engine * * @param string $user User part of the email address (typically 'wordpress') * @return string Email address with the correct email domain */ function get_default_email($user = '******') { // Let's build an email address for the app via the app identity api $service_account = new AppIdentityService(); $id = $service_account->getApplicationId(); if (empty($id)) { $service_account_name = $service_account->getServiceAccountName(); $service_account_from_name = explode('@', $service_account_name); $id = $service_account_from_name[0]; } return $user . '@' . $id . '.appspotmail.com'; }