You are here

public function OrderEventsTransactionsTest::testFailGracefulIfNoPurchasableEntity in Commerce Stock 8

Its absolutly possible to get orders from an order event that doesn't hold a $order->original order object. Here we test, whether our event subscriber fail graceful in such cases.

File

modules/local_storage/tests/src/Kernel/OrderEventsTransactionsTest.php, line 555

Class

OrderEventsTransactionsTest
Ensure the stock transactions are performed on order events.

Namespace

Drupal\Tests\commerce_stock_local\Kernel

Code

public function testFailGracefulIfNoPurchasableEntity() {
  $prophecy = $this
    ->prophesize(OrderEvent::class);
  $order = $this->order;
  $order->original = NULL;
  $prophecy
    ->getOrder()
    ->willReturn($order);
  $event = $prophecy
    ->reveal();
  $stockServiceManagerStub = $this
    ->prophesize(StockServiceManager::class);
  $eventTypeManagerStub = $this
    ->prophesize(StockEventTypeManagerInterface::class);
  $eventsManagerStub = $this
    ->prophesize(StockEventsManagerInterface::class);
  $entityTypeManager = \Drupal::EntityTypeManager();
  $sut = new OrderEventSubscriber($stockServiceManagerStub
    ->reveal(), $eventTypeManagerStub
    ->reveal(), $eventsManagerStub
    ->reveal(), $entityTypeManager);
  $sut
    ->onOrderUpdate($event);
}