public function PlanCRUDTest::testCreatePlan in farmOS 2.x
Create plan entity.
File
- modules/
core/ plan/ tests/ src/ Functional/ PlanCRUDTest.php, line 35
Class
- PlanCRUDTest
- Tests the plan CRUD.
Namespace
Drupal\Tests\plan\FunctionalCode
public function testCreatePlan() {
$assert_session = $this
->assertSession();
$name = $this
->randomMachineName();
$edit = [
'name[0][value]' => $name,
];
$this
->drupalPostForm('plan/add/default', $edit, $this
->t('Save'));
$result = \Drupal::entityTypeManager()
->getStorage('plan')
->getQuery()
->accessCheck(TRUE)
->range(0, 1)
->execute();
$plan_id = reset($result);
$plan = Plan::load($plan_id);
$this
->assertEquals($plan
->get('name')->value, $name, 'plan has been saved.');
$assert_session
->pageTextContains("Saved plan: {$name}");
$assert_session
->pageTextContains($name);
}