Refactoring

This commit is contained in:
dinamiko 2022-01-05 14:12:37 +01:00
parent 65b97f63c5
commit 96d154a856
3 changed files with 6 additions and 6 deletions

View file

@ -90,7 +90,7 @@ class IdentityToken {
* @return Token
* @throws RuntimeException If the request fails.
*/
public function generate_for_customer( int $user_id ): Token {
public function generate_for_user( int $user_id ): Token {
$bearer = $this->bearer->bearer();
$url = trailingslashit( $this->host ) . 'v1/identity/generate-token';
@ -105,7 +105,7 @@ class IdentityToken {
( $this->settings->has( 'vault_enabled' ) && $this->settings->get( 'vault_enabled' ) )
&& defined( 'PPCP_FLAG_SUBSCRIPTION' ) && PPCP_FLAG_SUBSCRIPTION
) {
$customer_id = $this->customer_repository->customer_id_for_user(($user_id));
$customer_id = $this->customer_repository->customer_id_for_user( ( $user_id ) );
if ( 0 === $user_id ) {
$customer_id = uniqid();

View file

@ -80,7 +80,7 @@ class DataClientIdEndpoint implements EndpointInterface {
try {
$this->request_data->read_request( $this->nonce() );
$user_id = get_current_user_id();
$token = $this->identity_token->generate_for_customer( $user_id );
$token = $this->identity_token->generate_for_user( $user_id );
wp_send_json(
array(
'token' => $token->token(),

View file

@ -92,7 +92,7 @@ class IdentityTokenTest extends TestCase
when('wc_print_r')->returnArg();
when('get_user_meta')->justReturn('');
$result = $this->sut->generate_for_customer(1);
$result = $this->sut->generate_for_user(1);
$this->assertInstanceOf(Token::class, $result);
}
@ -116,7 +116,7 @@ class IdentityTokenTest extends TestCase
$this->customer_repository->shouldReceive('customer_id_for_user');
$this->expectException(RuntimeException::class);
$this->sut->generate_for_customer(1);
$this->sut->generate_for_user(1);
}
public function testGenerateForCustomerFailsBecauseResponseCodeIsNot200()
@ -143,6 +143,6 @@ class IdentityTokenTest extends TestCase
$this->customer_repository->shouldReceive('customer_id_for_user');
$this->expectException(PayPalApiException::class);
$this->sut->generate_for_customer(1);
$this->sut->generate_for_user(1);
}
}