You are here

public function RoutingTransactionNameSubscriberTest::testSetsTransactionCallbackOnDynamicRoutes in New Relic 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/EventListener/RoutingTransactionNameSubscriberTest.php \Drupal\Tests\new_relic_rpm\Unit\EventListener\RoutingTransactionNameSubscriberTest::testSetsTransactionCallbackOnDynamicRoutes()
  2. 2.0.x tests/src/Unit/EventListener/RoutingTransactionNameSubscriberTest.php \Drupal\Tests\new_relic_rpm\Unit\EventListener\RoutingTransactionNameSubscriberTest::testSetsTransactionCallbackOnDynamicRoutes()

@covers ::addTransactionNamesToRoutes

File

tests/src/Unit/EventListener/RoutingTransactionNameSubscriberTest.php, line 37

Class

RoutingTransactionNameSubscriberTest
@coversDefaultClass \Drupal\new_relic_rpm\EventSubscriber\RoutingTransactionNameSubscriber @group new_relic_rpm

Namespace

Drupal\Tests\new_relic_rpm\Unit\EventListener

Code

public function testSetsTransactionCallbackOnDynamicRoutes() {
  $collection = new RouteCollection();
  $collection
    ->add('node.add', new Route('/node/add'));
  $event = new RouteBuildEvent($collection);
  $subscriber = new RoutingTransactionNameSubscriber();
  $subscriber
    ->addTransactionNamesToRoutes($event);
  $actualName = $collection
    ->get('node.add')
    ->getDefault('_transaction_name');
  $actualCallback = $collection
    ->get('node.add')
    ->getDefault('_transaction_name_callback');
  $this
    ->assertEquals('node.add', $actualName);
  $this
    ->assertTrue(is_callable($actualCallback));
}