->
method('condition'
) ->
willReturn($query);
$query->
expects($this->
exactly(5
)) ->
method('execute'
) ->
willReturn(['test', 'other_test', 'other_test_1', 'other_test_2'
]);
$this->storage->
expects($this->
exactly(5
)) ->
method('getQuery'
) ->
willReturn($query);
$block_form_controller =
new BlockForm($this->entityTypeManager,
$this->conditionManager,
$this->contextRepository,
$this->language,
$this->themeHandler,
$this->pluginFormFactory->
reveal());
// Ensure that the block with just one other instance gets the next available
// name suggestion.
$this->
assertEquals('test_2',
$block_form_controller->
getUniqueMachineName($blocks['test'
]));
// Ensure that the block with already three instances (_0, _1, _2) gets the
// 4th available name.
$this->
assertEquals('other_test_3',
$block_form_controller->
getUniqueMachineName($blocks['other_test'
]));
$this->
assertEquals('other_test_3',
$block_form_controller->
getUniqueMachineName($blocks['other_test_1'
]));
$this->
assertEquals('other_test_3',
$block_form_controller->
getUniqueMachineName($blocks['other_test_2'
]));