public function WorkspaceControllerTest::testAddForm in Workspace 8
File
- tests/
src/ Functional/ WorkspaceControllerTest.php, line 53
Class
- WorkspaceControllerTest
- Test the WorkspaceController.
Namespace
Drupal\Tests\workspace\FunctionalCode
public function testAddForm() {
$types = WorkspaceType::loadMultiple();
$type = reset($types);
$this
->assertInstanceOf(WorkspaceType::class, $type);
$workspace_id = $this->controller
->getDefaultWorkspaceId();
$workspace = Workspace::load($workspace_id);
$workspace_pointer_id = WorkspacePointer::loadFromWorkspace($workspace)
->id();
$form = $this->controller
->addForm($type);
$this
->assertEquals($form['upstream']['widget']['#value'], $workspace_pointer_id);
$this
->config('workspace.settings')
->set('upstream', 0)
->save();
$form = $this->controller
->addForm($type);
$this
->assertEquals($form['upstream']['widget']['#value'], $workspace_pointer_id);
$this
->config('workspace.settings')
->set('upstream', $workspace_pointer_id)
->save();
$form = $this->controller
->addForm($type);
$this
->assertEquals($form['upstream']['widget']['#value'], $workspace_pointer_id);
$this
->config('workspace.settings')
->set('upstream', 12345)
->save();
$form = $this->controller
->addForm($type);
$this
->assertNull($form['upstream']['widget']['#value']);
$test_workspace = Workspace::create([
'type' => 'test',
'machine_name' => 'test',
'label' => 'Test',
]);
$test_workspace
->save();
$test_workspace_pointer_id = WorkspacePointer::loadFromWorkspace($test_workspace)
->id();
$this
->config('workspace.settings')
->set('upstream', $test_workspace_pointer_id)
->save();
$form = $this->controller
->addForm($type);
$this
->assertEquals($form['upstream']['widget']['#value'], $test_workspace_pointer_id);
}