You are here

public function TagViewTest::testGetAdUnit in Doubleclick for Publishers (DFP) 8

@covers ::getAdUnit @dataProvider getAdUnitProvider

File

tests/src/Unit/View/TagViewTest.php, line 72
Contains \Drupal\Tests\dfp\Unit\View\TagViewTest.

Class

TagViewTest
@coversDefaultClass \Drupal\dfp\View\TagView @group dfp

Namespace

Drupal\Tests\dfp\Unit\View

Code

public function testGetAdUnit($tag_ad_unit, $default_ad_unit, $network_id, $expected_adunit) {
  $tag = $this
    ->prophesize(TagInterface::class);
  $tag
    ->adunit()
    ->willReturn($tag_ad_unit);
  $config_factory = $this
    ->getConfigFactoryStub([
    'dfp.settings' => [
      'adunit_pattern' => $default_ad_unit,
      'network_id' => $network_id,
    ],
  ]);
  $token = $this
    ->createMock(TokenInterface::class);
  $token
    ->method('replace')
    ->willReturnArgument(0);
  $module_handler = $this
    ->prophesize(ModuleHandlerInterface::class)
    ->reveal();
  $tag_view = new TagView($tag
    ->reveal(), $config_factory
    ->get('dfp.settings'), $token, $module_handler);
  $this
    ->assertSame($expected_adunit, $tag_view
    ->getAdUnit());
}