CurrentPathStack example

/** * Tests ActiveLinkResponseFilter only affects HTML responses. * * @covers ::onResponse */
  public function testOnlyHtml() {
    $session = new AnonymousUserSession();
    $language_manager = new LanguageManager(new LanguageDefault([]));
    $request_stack = new RequestStack();
    $request_stack->push(new Request());
    $current_path_stack = new CurrentPathStack($request_stack);

    // Make sure path matcher isn't called and we didn't get to the link logic.     $path_matcher = $this->prophesize(PathMatcherInterface::class);
    $path_matcher->isFrontPage()->shouldNotBeCalled();

    $subscriber = new ActiveLinkResponseFilter(
      $session,
      $current_path_stack,
      $path_matcher->reveal(),
      $language_manager
    );

    
$this->pluginManager = $this->container->get('plugin.manager.condition');

    // Set a mock alias manager in the container.     $this->aliasManager = new MockAliasManager();
    $this->container->set('path_alias.manager', $this->aliasManager);

    // Set the test request stack in the container.     $this->requestStack = new RequestStack();
    $this->container->set('request_stack', $this->requestStack);

    $this->currentPath = new CurrentPathStack($this->requestStack);
    $this->container->set('path.current', $this->currentPath);
  }

  /** * Tests the request path condition. */
  public function testConditions() {

    // Get the request path condition and test and configure it to check against     // different patterns and requests.
    

  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} */
  

  public function testGetArgument() {
    $view = $this->getMockBuilder('Drupal\views\ViewExecutable')
      ->disableOriginalConstructor()
      ->getMock();
    $display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
      ->disableOriginalConstructor()
      ->getMock();
    $current_path = new CurrentPathStack(new RequestStack());

    $request = new Request();
    $current_path->setPath('/test/example', $request);
    $view->expects($this->any())
      ->method('getRequest')
      ->willReturn($request);
    $alias_manager = $this->createMock(AliasManagerInterface::class);
    $alias_manager->expects($this->never())
      ->method('getAliasByPath');

    // Don't use aliases. Check against NULL and nonexistent path component
Home | Imprint | This part of the site doesn't use cookies.