public function OnlyOneTest::testGetContentTypesList in Allow a content type only once (Only One) 8
Tests the content types label list with OnlyOne::getContentTypesList().
@covers ::getContentTypesList @dataProvider providerGetContentTypesList
Parameters
string $expected: The expected result from calling the function.
array $content_types_list: A list with content types objects.
File
- tests/
src/ Unit/ OnlyOneTest.php, line 129
Class
- OnlyOneTest
- Tests the OnlyOne class methods.
Namespace
Drupal\Tests\onlyone\UnitCode
public function testGetContentTypesList($expected, array $content_types_list) {
// 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 function.
$this
->assertEquals($expected, $this->onlyOne
->getContentTypesList());
}