You are here

protected function PaymentDeclinedMailTest::setUp in Commerce Recurring Framework 8

Overrides RecurringKernelTestBase::setUp

File

tests/src/Kernel/Mail/PaymentDeclinedMailTest.php, line 38

Class

PaymentDeclinedMailTest
Tests the sending of payment declined emails.

Namespace

Drupal\Tests\commerce_recurring\Kernel\Mail

Code

protected function setUp() : void {
  parent::setUp();
  $this->mail = $this->container
    ->get('commerce_recurring.payment_declined_mail');
  $this->user
    ->setEmail('test-recipient@example.com');
  $this->user
    ->save();
  $subscription = Subscription::create([
    'type' => 'product_variation',
    'store_id' => $this->store
      ->id(),
    'billing_schedule' => $this->billingSchedule,
    'uid' => $this->user,
    'payment_method' => $this->paymentMethod,
    'purchased_entity' => $this->variation,
    'title' => $this->variation
      ->getOrderItemTitle(),
    'quantity' => '2',
    'unit_price' => new Price('2', 'USD'),
    'state' => 'active',
    'starts' => strtotime('2017-02-24 17:30:00'),
  ]);
  $subscription
    ->save();
  $recurring_order_manager = $this->container
    ->get('commerce_recurring.order_manager');
  $this->order = $recurring_order_manager
    ->startRecurring($subscription);
  $this->order
    ->setOrderNumber($this->order
    ->id());
  $this->order
    ->save();
}