You are here

public function MenuTest::testMenuLinkAttribute in GraphQL 8.4

@covers \Drupal\graphql\Plugin\GraphQL\DataProducer\Menu\MenuLink\MenuLinkAttribute::resolve

File

tests/src/Kernel/DataProducer/MenuTest.php, line 144

Class

MenuTest
Data producers Menu test class.

Namespace

Drupal\Tests\graphql\Kernel\DataProducer

Code

public function testMenuLinkAttribute() : void {
  $attribute = 'target';
  $assert_happened = FALSE;
  foreach ($this->linkTree as $link_tree) {
    $options = $link_tree->link
      ->getOptions();
    if (!empty($options['attributes'][$attribute])) {
      $result = $this
        ->executeDataProducer('menu_link_attribute', [
        'link' => $link_tree->link,
        'attribute' => 'target',
      ]);
      $this
        ->assertEquals($options['attributes'][$attribute], $result);
      $assert_happened = TRUE;
    }
  }
  $this
    ->assertTrue($assert_happened, 'At least one menu attribute was tested');
}