protected function SchedulerHooksTest::setUp in Scheduler 2.x
Overrides SchedulerBrowserTestBase::setUp
File
- tests/
src/ Functional/ SchedulerHooksTest.php, line 33
Class
- SchedulerHooksTest
- Tests the API hook functions of the Scheduler module.
Namespace
Drupal\Tests\scheduler\FunctionalCode
protected function setUp() : void {
parent::setUp();
// Load the custom node type. These entity types are enabled for Scheduler
// automatically as that is pre-configured in the {type}.yml files.
$customNodeName = 'scheduler_api_node_test';
$customNodetype = NodeType::load($customNodeName);
// Check that the custom node type has loaded OK.
$this
->assertNotNull($customNodetype, "Custom node type {$customNodeName} failed to load during setUp");
// Load the custom media type.
$customMediaName = 'scheduler_api_media_test';
$customMediatype = MediaType::load($customMediaName);
// Check that the custom media type has loaded OK.
$this
->assertNotNull($customMediatype, "Custom media type {$customMediaName} failed to load during setUp");
// Load the custom product type.
$customProductName = 'scheduler_api_product_test';
$customProductType = ProductType::load($customProductName);
// Check that the custom product type has loaded OK.
$this
->assertNotNull($customProductType, "Custom product type {$customProductName} failed to load during setUp");
// Create a web user that has permission to create and edit and schedule
// the custom entity types.
$this->webUser = $this
->drupalCreateUser([
"create {$customNodeName} content",
"edit any {$customNodeName} content",
'schedule publishing of nodes',
"create {$customMediaName} media",
"edit any {$customMediaName} media",
'schedule publishing of media',
"create {$customProductName} commerce_product",
"update any {$customProductName} commerce_product",
'schedule publishing of commerce_product',
// 'administer commerce_store' is needed to see and use any store, i.e
// cannot add a product without this. Is it a bug?
'administer commerce_store',
]);
$this->webUser
->set('name', 'Wenlock the Web user')
->save();
}