You are here

public function SquareApiIntegrationTest::setUp in Commerce Square Connect 8

Overrides CommerceKernelTestBase::setUp

File

tests/src/Kernel/SquareApiIntegrationTest.php, line 48

Class

SquareApiIntegrationTest
Tests the Square SDK integration with Commerce.

Namespace

Drupal\Tests\commerce_square\Kernel

Code

public function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('profile');
  $this
    ->installEntitySchema('commerce_order');
  $this
    ->installEntitySchema('commerce_order_item');
  $this
    ->installEntitySchema('commerce_payment');
  $this
    ->installEntitySchema('commerce_payment_method');
  $this
    ->installConfig('commerce_order');
  $this
    ->installConfig('commerce_payment');
  $this->container
    ->get('config.factory')
    ->getEditable('commerce_square.settings')
    ->set('sandbox_app_id', 'sandbox-sq0idb-RMT75dFT1toXdUNnW8Ahmw')
    ->set('sandbox_access_token', 'EAAAEA3D3KIn2sjtYE0GjRPMJZPl4aigTyCyAhwojBAfWlr99jx4Wfz9GuCbzwfM')
    ->save();
  OrderItemType::create([
    'id' => 'test',
    'label' => 'Test',
    'orderType' => 'default',
  ])
    ->save();

  /** @var \Drupal\commerce_payment\Entity\PaymentGateway $gateway */
  $gateway = PaymentGateway::create([
    'id' => 'square_connect',
    'label' => 'Square',
    'plugin' => 'square',
  ]);
  $gateway
    ->getPlugin()
    ->setConfiguration([
    'test_location_id' => 'C9HQN1PSN4NKA',
    'mode' => 'test',
    'payment_method_types' => [
      'credit_card',
    ],
  ]);
  $gateway
    ->save();
  $this->gateway = $gateway;
}