public function OnlyOneAdminToolbarTest::testRebuildMenu in Allow a content type only once (Only One) 8
Tests the OnlyOneAdminToolbar::rebuildMenu() method.
@covers ::rebuildMenu @dataProvider providerRebuildMenu
Parameters
string $content_type: Content type machine name.
array $content_types_list: Array of content types machine names.
File
- modules/
onlyone_admin_toolbar/ tests/ src/ Unit/ OnlyOneAdminToolbarTest.php, line 64
Class
- OnlyOneAdminToolbarTest
- Tests the Language class methods.
Namespace
Drupal\Tests\onlyone_admin_toolbar\UnitCode
public function testRebuildMenu($content_type, array $content_types_list) {
// ImmutableConfig mock.
$config = $this
->createMock('Drupal\\Core\\Config\\ImmutableConfig');
// ImmutableConfig::get mock.
$config
->expects($this
->any())
->method('get')
->with('onlyone_node_types')
->willReturn($content_types_list);
// Mocking get method.
$this->configFactory
->expects($this
->any())
->method('get')
->with('onlyone.settings')
->willReturn($config);
// Mocking rebuild method.
$this->routeBuilder
->expects($this
->any())
->method('rebuild')
->willReturn(TRUE);
// Testing the function.
$this
->assertNull($this->onlyOneAdminToolbar
->rebuildMenu($content_type));
}