ProductLoadEventTest.php in Ubercart 8.4
File
uc_product/tests/src/Unit/Integration/Event/ProductLoadEventTest.php
View source
<?php
namespace Drupal\Tests\uc_product\Unit\Integration\Event;
use Drupal\rules\Core\RulesEventManager;
use Drupal\Tests\rules\Unit\Integration\Event\EventTestBase;
class ProductLoadEventTest extends EventTestBase {
protected function setUp() : void {
parent::setUp();
$this
->enableModule('uc_product', [
'Drupal\\uc_product' => __DIR__ . '/../../../../../src',
]);
$this->moduleHandler
->getModuleDirectories()
->willReturn([
'uc_product' => __DIR__ . '/../../../../../',
]);
$this->eventManager = new RulesEventManager($this->moduleHandler
->reveal(), $this->entityTypeBundleInfo
->reveal());
}
public function testProductLoadEvent() {
$event = $this->eventManager
->createInstance('uc_product_load');
$product_context_definition = $event
->getContextDefinition('product');
$this
->assertSame('entity:node', $product_context_definition
->getDataType());
$this
->assertSame('Product', $product_context_definition
->getLabel());
}
}