|
3 | 3 | namespace Drupal\Tests\commerce_log\Kernel; |
4 | 4 |
|
5 | 5 | use Drupal\commerce_order\Entity\Order; |
| 6 | +use Drupal\commerce_order\Entity\OrderInterface; |
6 | 7 | use Drupal\commerce_order\Entity\OrderType; |
7 | 8 | use Drupal\commerce_price\Price; |
8 | 9 | use Drupal\commerce_product\Entity\Product; |
9 | 10 | use Drupal\commerce_product\Entity\ProductVariation; |
10 | 11 | use Drupal\commerce_product\Entity\ProductVariationType; |
11 | 12 | use Drupal\profile\Entity\Profile; |
12 | 13 | use Drupal\Tests\commerce\Kernel\CommerceKernelTestBase; |
| 14 | +use Drupal\user\Entity\User; |
13 | 15 |
|
14 | 16 | /** |
15 | 17 | * Tests integration with order events. |
@@ -185,4 +187,25 @@ public function testPlaceValidateFulfillLogs() { |
185 | 187 | $this->assertText('The order was fulfilled.'); |
186 | 188 | } |
187 | 189 |
|
| 190 | + /** |
| 191 | + * Tests that an order assignment log is generated. |
| 192 | + */ |
| 193 | + public function testOrderAssignedLog() { |
| 194 | + // Reassignment is currently only done on user login. |
| 195 | + $this->order->setCustomer(User::getAnonymousUser()); |
| 196 | + $this->order->setRefreshState(OrderInterface::REFRESH_SKIP); |
| 197 | + $this->order->save(); |
| 198 | + $new_user = $this->createUser(); |
| 199 | + |
| 200 | + $order_assignment = $this->container->get('commerce_order.order_assignment'); |
| 201 | + $order_assignment->assign($this->order, $new_user); |
| 202 | + |
| 203 | + $logs = $this->logStorage->loadByEntity($this->order); |
| 204 | + $this->assertEquals(1, count($logs)); |
| 205 | + $log = reset($logs); |
| 206 | + $build = $this->logViewBuilder->view($log); |
| 207 | + $this->render($build); |
| 208 | + $this->assertText("The order was assigned to {$new_user->getDisplayName()}."); |
| 209 | + } |
| 210 | + |
188 | 211 | } |
0 commit comments