public function ForumBreadcrumbBuilderBaseTest::testConstructor in Drupal 9
Same name and namespace in other branches
- 8 core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php \Drupal\Tests\forum\Unit\Breadcrumb\ForumBreadcrumbBuilderBaseTest::testConstructor()
Tests ForumBreadcrumbBuilderBase::__construct().
@covers ::__construct
File
- core/
modules/ forum/ tests/ src/ Unit/ Breadcrumb/ ForumBreadcrumbBuilderBaseTest.php, line 37
Class
- ForumBreadcrumbBuilderBaseTest
- @coversDefaultClass \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase @group forum
Namespace
Drupal\Tests\forum\Unit\BreadcrumbCode
public function testConstructor() {
// Make some test doubles.
$entity_type_manager = $this
->createMock(EntityTypeManagerInterface::class);
$config_factory = $this
->getConfigFactoryStub([
'forum.settings' => [
'IAmATestKey' => 'IAmATestValue',
],
]);
$forum_manager = $this
->createMock('Drupal\\forum\\ForumManagerInterface');
$translation_manager = $this
->createMock('Drupal\\Core\\StringTranslation\\TranslationInterface');
// Make an object to test.
$builder = $this
->getMockForAbstractClass('Drupal\\forum\\Breadcrumb\\ForumBreadcrumbBuilderBase', [
$entity_type_manager,
$config_factory,
$forum_manager,
$translation_manager,
]);
// Test that the constructor made a config object with our info in it.
$reflector = new \ReflectionClass($builder);
$ref_property = $reflector
->getProperty('config');
$ref_property
->setAccessible(TRUE);
$config = $ref_property
->getValue($builder);
$this
->assertEquals('IAmATestValue', $config
->get('IAmATestKey'));
}