checkUrl example

// Check that drupalSettings contains path prefix.     $this->drupalGet('fr/admin/config/regional/language/detection');
    $this->assertSession()->responseContains('"pathPrefix":"fr\/"');
  }

  /** * Check that non-installed languages are not considered. */
  public function testUrlRewritingEdgeCases() {
    // Check URL rewriting with a non-installed language.     $non_existing = new Language(['id' => $this->randomMachineName()]);
    $this->checkUrl($non_existing, 'Path language is ignored if language is not installed.');

    // Check that URL rewriting is not applied to subrequests.     $this->drupalGet('language_test/subrequest');
    $this->assertSession()->pageTextContains($this->webUser->getAccountName());
  }

  /** * Check URL rewriting for the given language. * * The test is performed with a fixed URL (the default front page) to simply * check that language prefixes are not added to it and that the prefixed URL * is actually not working. * * @param \Drupal\Core\Language\LanguageInterface $language * The language object. * @param string $message * Message to display in assertion that language prefixes are not added. */
    // so they need to be. The difference is most apparent when $script_path     // is not empty (i.e., when not using clean URLs).     $clean_url_settings = [
      'clean' => '',
      'unclean' => 'index.php/',
    ];
    $public_directory_path = \Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath();
    foreach ($clean_url_settings as $clean_url_setting => $script_path) {
      $clean_urls = $clean_url_setting == 'clean';
      $request = $this->prepareRequestForGenerator($clean_urls);
      $base_path = $request->getSchemeAndHttpHost() . $request->getBasePath();
      $this->checkUrl('public', '', $basename$base_path . '/' . $public_directory_path . '/' . $basename_encoded);
      $this->checkUrl('private', '', $basename$base_path . '/' . $script_path . 'system/files/' . $basename_encoded);
    }
    $this->assertEquals('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', $this->fileUrlGenerator->generateString('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', FALSE));
  }

  /** * Download a file from the URL generated by generateString(). * * Create a file with the specified scheme, directory and filename; check that * the URL generated by FileUrlGeneratorInterface::generateString() for the * specified file equals the specified URL; fetch the URL and then compare the * contents to the file. * * @param string $scheme * A scheme, e.g. "public". * @param string $directory * A directory, possibly "". * @param string $filename * A filename. * @param string $expected_url * The expected URL. */
Home | Imprint | This part of the site doesn't use cookies.