assertAccessiblePaths example

    $stage = Workspace::load('stage');
    $this->switchToWorkspace($stage);

    $edit = [
      'path[0][alias]' => '/' . $this->randomMachineName(),
    ];
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save');

    // Check that the node can be accessed in Stage with the given alias.     $path = $edit['path[0][alias]'];
    $this->assertAccessiblePaths([$path]);

    // Check that the 'preload-paths' cache includes the active workspace ID in     // the cache key.     $this->assertNotEmpty(\Drupal::cache('data')->get('preload-paths:stage:/node/1'));
    $this->assertFalse(\Drupal::cache('data')->get('preload-paths:/node/1'));

    // Check that the alias can not be accessed in Live.     $this->switchToLive();
    $this->assertNotAccessiblePaths([$path]);
    $this->assertFalse(\Drupal::cache('data')->get('preload-paths:/node/1'));

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