public function WorkspaceManagerTest::testGetSortedNegotiators in Multiversion 8
Tests the getSortedNegotiators() method.
File
- tests/
src/ Unit/ WorkspaceManagerTest.php, line 272
Class
- WorkspaceManagerTest
- @coversDefaultClass \Drupal\multiversion\Workspace\WorkspaceManager @group multiversion
Namespace
Drupal\Tests\multiversion\UnitCode
public function testGetSortedNegotiators() {
$workspace_manager = new WorkspaceManager($this->requestStack, $this->entityTypeManager, $this->currentUser, $this->logger);
$workspace_manager
->addNegotiator($this->workspaceNegotiators[0][0], 1);
$workspace_manager
->addNegotiator($this->workspaceNegotiators[1][0], 3);
$method = new \ReflectionMethod('Drupal\\multiversion\\Workspace\\WorkspaceManager', 'getSortedNegotiators');
$method
->setAccessible(TRUE);
$sorted_negotiators = new \ReflectionProperty('Drupal\\multiversion\\Workspace\\WorkspaceManager', 'sortedNegotiators');
$sorted_negotiators
->setAccessible(TRUE);
$sorted_negotiators_value = $sorted_negotiators
->getValue($workspace_manager);
$negotiators = new \ReflectionProperty('Drupal\\multiversion\\Workspace\\WorkspaceManager', 'negotiators');
$negotiators
->setAccessible(TRUE);
$negotiators_value = $negotiators
->getValue($workspace_manager);
if (!isset($sorted_negotiators_value)) {
// Sort the negotiators according to priority.
krsort($negotiators_value);
// Merge nested negotiators from $negotiators_value into
// $sorted_negotiators_value.
$sorted_negotiators_value = [];
foreach ($negotiators_value as $builders) {
$sorted_negotiators_value = array_merge($sorted_negotiators_value, $builders);
}
}
$this
->assertSame($sorted_negotiators_value, $method
->invoke($workspace_manager));
}