RoutingFixtures example

/** * The logger. */
  protected TestLogger $logger;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->fixtures = new RoutingFixtures();
    $this->state = new State(new KeyValueMemoryFactory());
    $this->logger = new TestLogger();
  }

  /** * Confirms that the dumper can be instantiated successfully. */
  public function testCreate() {
    $connection = Database::getConnection();
    $dumper = new MatcherDumper($connection$this->state, $this->logger);

    

  protected $matcher;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->fixtures = new RoutingFixtures();
    $this->matcher = new ContentTypeHeaderMatcher();
  }

  /** * Tests that routes are not filtered on safe requests. * * @dataProvider providerTestSafeRequestFilter */
  public function testSafeRequestFilter($method) {
    $collection = $this->fixtures->sampleRouteCollection();
    $collection->addCollection($this->fixtures->contentRouteCollection());

    

  protected TestLogger $logger;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->fixtures = new RoutingFixtures();
    $this->state = new State(new KeyValueMemoryFactory());
    $this->currentPath = new CurrentPathStack(new RequestStack());
    $this->cache = new MemoryBackend();
    $this->pathProcessor = \Drupal::service('path_processor_manager');
    $this->cacheTagsInvalidator = \Drupal::service('cache_tags.invalidator');
    $this->installEntitySchema('path_alias');

    $this->logger = new TestLogger();
  }

  /** * {@inheritdoc} */

  protected $matcher;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->fixtures = new RoutingFixtures();
    $this->matcher = new AcceptHeaderMatcher();
  }

  /** * Provides data for the Accept header filtering test. * * @see Drupal\Tests\Core\Routing\AcceptHeaderMatcherTest::testAcceptFiltering() */
  public function acceptFilterProvider() {
    return [
      // Check that JSON routes get filtered and prioritized correctly.
/** * Tests that provided routes by a module is put into the dumper/dispatcher. * * @see \Drupal\Core\Routing\RouteBuilder::rebuild() */
  public function testRebuildWithStaticModuleRoutes() {
    $this->lock->expects($this->once())
      ->method('acquire')
      ->with('router_rebuild')
      ->willReturn(TRUE);

    $routing_fixtures = new RoutingFixtures();
    $routes = $routing_fixtures->staticSampleRouteCollection();

    $this->yamlDiscovery->expects($this->once())
      ->method('findAll')
      ->willReturn(['test_module' => $routes]);

    $route_collection = $routing_fixtures->sampleRouteCollection();
    foreach ($route_collection->all() as $route) {
      $route->setOption('compiler_class', RouteCompiler::class);
    }
    $route_build_event = new RouteBuildEvent($route_collection);

    
Home | Imprint | This part of the site doesn't use cookies.