View source
<?php
namespace Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1;
use Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateTestTrait;
use Drupal\commerce_log\Entity\Log;
class LogTest extends Commerce1TestBase {
use CommerceMigrateTestTrait;
public static $modules = [
'commerce_number_pattern',
'commerce_log',
'commerce_order',
'commerce_payment',
'commerce_price',
'commerce_product',
'commerce_shipping',
'commerce_store',
'migrate_plus',
'path',
'path_alias',
'physical',
];
protected function setUp() {
parent::setUp();
$this
->migrateOrders();
$this
->installEntitySchema('commerce_log');
$this
->executeMigrations([
'commerce1_message',
]);
}
public function assertLog(array $log) {
$log_instance = Log::load($log['id']);
$this
->assertInstanceOf(Log::class, $log_instance);
$this
->assertSame($log['category_id'], $log_instance
->getCategoryId());
$this
->assertSame($log['label'], $log_instance
->label());
$this
->assertSame($log['source_entity_id'], $log_instance
->getSourceEntityId());
$this
->assertSame($log['created'], $log_instance
->getCreatedTime());
$this
->assertSame($log['template_id'], $log_instance
->getTemplateId());
}
public function testMessage() {
$log = [
'id' => 1,
'category_id' => 'commerce_order',
'label' => 'Order: Order placed',
'source_entity_id' => '1',
'created' => '1493287434',
'template_id' => 'order_placed',
];
$this
->assertLog($log);
$log = [
'id' => 2,
'category_id' => 'commerce_cart',
'label' => 'Cart: Added to cart',
'source_entity_id' => '1',
'created' => '1493287434',
'template_id' => 'cart_entity_added',
];
$this
->assertLog($log);
}
}