public function NodeRevisionDeleteTest::testGetConfiguredContentTypes in Node Revision Delete 8
Tests the getConfiguredContentTypes() method.
@covers ::getConfiguredContentTypes @dataProvider providerGetConfiguredContentTypes
Parameters
array $expected: The expected result from calling the function.
array $third_party_settings: The content type third party settings.
array $content_types_list: A list with node types objects.
File
- tests/
src/ Unit/ NodeRevisionDeleteTest.php, line 476
Class
- NodeRevisionDeleteTest
- Tests the NodeRevisionDelete class methods.
Namespace
Drupal\Tests\node_revision_delete\UnitCode
public function testGetConfiguredContentTypes(array $expected, array $third_party_settings, array $content_types_list) {
// ImmutableConfig mock.
$config = $this
->createMock('Drupal\\Core\\Config\\ImmutableConfig');
// ImmutableConfig::get mock.
$config
->expects($this
->any())
->method('get')
->with('third_party_settings')
->willReturnOnConsecutiveCalls(...$third_party_settings);
$cant = count($content_types_list);
$map_node_type = [];
for ($i = 0; $i < $cant; $i++) {
$map_node_type[] = [
'node.type.' . $content_types_list[$i]
->id(),
$config,
];
}
// Mocking get method.
$this->configFactory
->expects($this
->any())
->method('get')
->will($this
->returnValueMap($map_node_type));
// EntityStorage mock.
$entity_storage = $this
->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
// loadMultiple mock.
$entity_storage
->expects($this
->any())
->method('loadMultiple')
->willReturn($content_types_list);
// Mocking getStorage method.
$this->entityTypeManager
->expects($this
->any())
->method('getStorage')
->with('node_type')
->willReturn($entity_storage);
// Testing the method.
$this
->assertEquals($expected, $this->nodeRevisionDelete
->getConfiguredContentTypes());
}