protected function WorkspaceManagerTest::setUp in Multiversion 8
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ WorkspaceManagerTest.php, line 96
Class
- WorkspaceManagerTest
- @coversDefaultClass \Drupal\multiversion\Workspace\WorkspaceManager @group multiversion
Namespace
Drupal\Tests\multiversion\UnitCode
protected function setUp() {
parent::setUp();
$this->entityTypeId = 'workspace';
$first_machine_name = $this
->randomMachineName();
$second_machine_name = $this
->randomMachineName();
$this->values = [
[
'machine_name' => $first_machine_name,
],
[
'machine_name' => $second_machine_name,
],
];
$this->entityType = $this
->getMock('Drupal\\multiversion\\Entity\\WorkspaceInterface');
$this->entityTypeManager = $this
->getMock('Drupal\\Core\\Entity\\EntityTypeManagerInterface');
$this->currentUser = $this
->getMock('Drupal\\Core\\Session\\AccountProxyInterface');
$this->logger = $this
->getMock('Psr\\Log\\LoggerInterface');
$this->block_manager = $this
->getMockBuilder('Drupal\\Core\\Block\\BlockManager')
->disableOriginalConstructor()
->getMock();
$this->entityTypeManager
->expects($this
->any())
->method('getDefinition')
->with($this->entityTypeId)
->will($this
->returnValue($this->entityType));
$this->requestStack = $this
->getMock('Symfony\\Component\\HttpFoundation\\RequestStack');
$container = new ContainerBuilder();
$container
->set('entity.manager', $this->entityTypeManager);
$container
->set('request_stack', $this->requestStack);
$container
->setParameter('workspace.default', 1);
\Drupal::setContainer($container);
foreach ($this->values as $value) {
$entity = $this
->getMockBuilder('Drupal\\multiversion\\Entity\\Workspace')
->disableOriginalConstructor()
->getMock();
$entity
->expects($this
->any())
->method('create')
->with($value)
->will($this
->returnValue($this->entityType));
$this->entities[] = $entity;
}
$this->workspaceNegotiators[] = [
$this
->getMock('Drupal\\multiversion\\Workspace\\DefaultWorkspaceNegotiator'),
];
$session_workspace_negotiator = $this
->getMockBuilder('Drupal\\multiversion\\Workspace\\SessionWorkspaceNegotiator')
->disableOriginalConstructor()
->getMock();
$this->workspaceNegotiators[] = [
$session_workspace_negotiator,
];
}