public function AcceptJsPaymentMethodTest::testDuplicateProfiles in Commerce Authorize.Net 8
Tests creating a duplicate profile.
@link Here is a list of what deems things as a duplicate: https://developer.authorize.net/api/reference/features/customer_profiles...
File
- tests/src/ Kernel/ AcceptJsPaymentMethodTest.php, line 282 
Class
- AcceptJsPaymentMethodTest
- Tests creating a payment method with AcceptJS.
Namespace
Drupal\Tests\commerce_authnet\KernelCode
public function testDuplicateProfiles() {
  // Force the uid and email to match so the customer profile is flagged
  // as being a duplicate.
  $user = $this
    ->createUser([
    'uid' => 10,
    'mail' => 'fred.pabst@example.com',
  ]);
  $profile = Profile::create([
    'type' => 'customer',
    'address' => [
      'country_code' => 'US',
      'postal_code' => '53177',
      'locality' => 'Milwaukee',
      'address_line1' => 'Pabst Blue Ribbon Dr',
      'administrative_area' => 'WI',
      'given_name' => 'Frederick',
      'family_name' => 'Pabst',
    ],
    'uid' => $user
      ->id(),
  ]);
  $profile
    ->save();
  /** @var \Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\AcceptJs $plugin */
  $plugin = $this->gateway
    ->getPlugin();
  $opaque_data = $this
    ->createDataDescriptor();
  /** @var \Drupal\commerce_payment\PaymentMethodStorageInterface $payment_method_storage */
  $payment_method_storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('commerce_payment_method');
  /** @var \Drupal\commerce_payment\Entity\PaymentMethodInterface $payment_method */
  $payment_method = $payment_method_storage
    ->create([
    'type' => 'credit_card',
    'payment_gateway' => $this->gateway
      ->id(),
    'uid' => $user,
    'billing_profile' => $profile,
  ]);
  $plugin
    ->createPaymentMethod($payment_method, [
    'data_descriptor' => $opaque_data->dataDescriptor,
    'data_value' => $opaque_data->dataValue,
    'last4' => '0015',
    'expiration_month' => '12',
    'expiration_year' => '2027',
  ]);
  $this
    ->assertNotEmpty($payment_method
    ->id());
  $this
    ->assertEquals('mastercard', $payment_method->card_type->value);
}