You are here

public function RecurringOrderManagerTest::setUp in Commerce Recurring Framework 8

Overrides RecurringKernelTestBase::setUp

File

tests/src/Kernel/RecurringOrderManagerTest.php, line 44

Class

RecurringOrderManagerTest
@coversDefaultClass \Drupal\commerce_recurring\RecurringOrderManager @group commerce_recurring

Namespace

Drupal\Tests\commerce_recurring\Kernel

Code

public function setUp() : void {
  parent::setUp();
  $trial_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('20', 'USD'),
    'state' => 'trial',
    'trial_starts' => strtotime('2019-02-05 00:00'),
  ]);
  $trial_subscription
    ->save();
  $this->trialSubscription = $this
    ->reloadEntity($trial_subscription);
  $active_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('20', 'USD'),
    'state' => 'active',
    'starts' => strtotime('2019-02-15 00:00:00'),
  ]);
  $active_subscription
    ->save();
  $this->activeSubscription = $this
    ->reloadEntity($active_subscription);
  $this->recurringOrderManager = $this->container
    ->get('commerce_recurring.order_manager');
}