refreshVariables example

$value = (bool) $value;
      }

      $field->setValue($value);
    }

    // Submit form.     $this->prepareRequest();
    $submit_button->press();

    // Ensure that any changes to variables in the other thread are picked up.     $this->refreshVariables();

    // Check if there are any meta refresh redirects (like Batch API pages).     if ($this->checkForMetaRefresh()) {
      // We are finished with all meta refresh redirects, so reset the counter.       $this->metaRefreshCount = 0;
    }

    // Log only for WebDriverTestBase tests because for tests using     // DrupalTestBrowser we log with ::getResponseLogHandler.     if ($this->htmlOutputEnabled && !$this->isTestUsingGuzzleClient()) {
      $out = $this->getSession()->getPage()->getContent();
      

  protected function resetAll() {
    // Clear all database and static caches and rebuild data structures.     drupal_flush_all_caches();
    $this->container = \Drupal::getContainer();

    // Reset static variables and reload permissions.     $this->refreshVariables();
  }

  /** * Creates a mock request and sets it on the generator. * * This is used to manipulate how the generator generates paths during tests. * It also ensures that calls to $this->drupalGet() will work when running * from run-tests.sh because the URL generator no longer looks at the global * variables that are set there but relies on getting this information from a * request object. * * @param bool $clean_urls * Whether to mock the request using clean URLs. * @param array $override_server_vars * An array of server variables to override. * * @return \Symfony\Component\HttpFoundation\Request * The mocked request object. */
'search content',
      'administer nodes',
    ]);
    $this->drupalLogin($test_user);

    $this->node = $this->drupalCreateNode();

    $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();

    // Set up a dummy initial count of times the form has been submitted.     $this->submitCount = \Drupal::state()->get('search_embedded_form.submit_count');
    $this->refreshVariables();
  }

  /** * Tests that the embedded form appears and can be submitted. */
  public function testEmbeddedForm() {
    // First verify we can submit the form from the module's page.     $this->drupalGet('search_embedded_form');
    $this->submitForm(['name' => 'John'], 'Send away');
    $this->assertSession()->pageTextContains('Test form was submitted');
    $count = \Drupal::state()->get('search_embedded_form.submit_count');
    
// But if we use the basic auth authentication strategy, we should be able     // to see the page.     $url = $this->buildUrl('test/serialize/auth_with_perm');
    $response = \Drupal::httpClient()->get($url[
      'auth' => [$this->adminUser->getAccountName()$this->adminUser->pass_raw],
      'query' => [
        '_format' => 'json',
      ],
    ]);

    // Ensure that any changes to variables in the other thread are picked up.     $this->refreshVariables();

    $this->assertSession()->statusCodeEquals(200);
  }

  /** * Checks the behavior of the Serializer callback paths and row plugins. */
  public function testSerializerResponses() {
    // Test the serialize callback.     $view = Views::getView('test_serializer_display_field');
    $view->initDisplay();
    
$settings['body'] = [['value' => 'love cheesy pizza']];
      $this->drupalCreateNode($settings);
    }
    // Create another node and save it for later.     $settings['body'] = [['value' => 'Druplicon']];
    $node = $this->drupalCreateNode($settings);

    // Update the search index.     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();

    // Refresh variables after the treatment.     $this->refreshVariables();

    // Test that the correct number of pager links are found for keyword search.     $edit = ['keys' => 'love pizza'];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()->linkByHrefExists('page=1', 0, '2nd page link is found for keyword search.');
    $this->assertSession()->linkByHrefExists('page=2', 0, '3rd page link is found for keyword search.');
    $this->assertSession()->linkByHrefExists('page=3', 0, '4th page link is found for keyword search.');
    $this->assertSession()->linkByHrefNotExists('page=4', '5th page link is not found for keyword search.');

    // Test that the correct number of pager links are found for exact phrase search.

  public function testPhraseSearchPunctuation() {
    // cSpell:disable     $body_text = 'The Enricþment Center is cómmīŦŧęđ to the well BɆĬŇĜ of æll påŔťıçȉpǎǹţș. ';
    $body_text .= 'Also meklēt (see #731298)';
    $this->drupalCreateNode(['body' => [['value' => $body_text]]]);

    // Update the search index.     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();

    // Refresh variables after the treatment.     $this->refreshVariables();

    $edit = ['keys' => 'meklet'];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()->responseContains('<strong>meklēt</strong>');

    $edit = ['keys' => 'meklēt'];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()->responseContains('<strong>meklēt</strong>');

    


    $session->visit($url);

    // There are 2 alerts to accept before we can get the content of the page.     $session->getDriver()->getWebdriverSession()->accept_alert();
    $session->getDriver()->getWebdriverSession()->accept_alert();

    $out = $session->getPage()->getContent();

    // Ensure that any changes to variables in the other thread are picked up.     $this->refreshVariables();

    // Replace original page output with new output from redirected page(s).     if ($new = $this->checkForMetaRefresh()) {
      $out = $new;
      // We are finished with all meta refresh redirects, so reset the counter.       $this->metaRefreshCount = 0;
    }

    // Log only for WebDriverTestBase tests because for DrupalTestBrowser we log     // with ::getResponseLogHandler.     if ($this->htmlOutputEnabled && !$this->isTestUsingGuzzleClient()) {
      
    $this->isInstalled = TRUE;
  }

  /** * {@inheritdoc} * * FunctionalTestSetupTrait::refreshVariables() tries to operate on persistent * storage, which is only available after the installer completed. */
  protected function refreshVariables() {
    if ($this->isInstalled) {
      parent::refreshVariables();
    }
  }

}

  protected function makeApiRequest($method, Url $url, array $request_options) {
    $this->refreshVariables();
    $request_options[RequestOptions::HTTP_ERRORS] = FALSE;
    $request_options[RequestOptions::ALLOW_REDIRECTS] = FALSE;
    $request_options = $this->decorateWithXdebugCookie($request_options);
    $client = $this->getSession()->getDriver()->getClient()->getClient();
    return $client->request($method$url->setAbsolute(TRUE)->toString()$request_options);
  }

  /** * Adds the Xdebug cookie to the request options. * * @param array $request_options * The request options. * * @return array * Request options updated with the Xdebug cookie if present. */

  protected function stateSet(array $values) {
    // Set the new state values.     $this->container->get('state')->setMultiple($values);
    // Refresh in-memory static state/config caches and static variables.     $this->refreshVariables();
    // Refresh/rewrite language negotiation configuration, in order to pick up     // the manipulations performed by language_test module's info alter hooks.     $this->container->get('language_negotiator')->purgeConfiguration();
  }

  /** * Tests alterations to language types/negotiation info. */
  public function testInfoAlterations() {
    $this->stateSet([
      // Enable language_test type info.

  public function testPhraseSearchPunctuation() {
    $node = $this->drupalCreateNode(['body' => [['value' => "The bunny's ears were fluffy."]]]);
    // cSpell:disable-next-line     $this->drupalCreateNode(['body' => [['value' => 'Dignissim Aliquam &amp; Quieligo meus natu quae quia te. Damnum&copy; erat&mdash; neo pneum. Facilisi feugiat ibidem ratis.']]]);

    // Update the search index.     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();

    // Refresh variables after the treatment.     $this->refreshVariables();

    // Submit a phrase wrapped in double quotes to include the punctuation.     $edit = ['keys' => '"bunny\'s"'];
    $this->drupalGet('search/node');
    $this->submitForm($edit, 'Search');
    $this->assertSession()->pageTextContains($node->label());

    // Check if the author is linked correctly to the user profile page.     $username = $node->getOwner()->getAccountName();
    $this->assertSession()->linkExists($username);

    


  /** * Refreshes the state of the tester to be in sync with the testee. * * Should be called after every change made to: * - RestResourceConfig entities */
  protected function refreshTestStateAfterRestConfigChange() {
    // Ensure that the cache tags invalidator has its internal values reset.     // Otherwise the http_response cache tag invalidation won't work.     $this->refreshVariables();

    // Tests using this base class may trigger route rebuilds due to changes to     // RestResourceConfig entities. Ensure the test generates routes using an     // up-to-date router.     \Drupal::service('router.builder')->rebuildIfNeeded();
  }

  /** * Return the expected error message. * * @param string $method * The HTTP method (GET, POST, PATCH, DELETE). * * @return string * The error string. */
'required' => TRUE,
    ];

    $this->writeSettings($settings);
    $this->rebuildAll();

    $cache->set('rebuild_test', TRUE);
    \Drupal::state()->set('container_rebuild_test.count', 0);
    $this->drupalGet(Url::fromUri('base:core/rebuild.php'));
    $this->assertSession()->addressEquals(new Url('<front>'));
    $this->assertFalse($cache->get('rebuild_test'));
    $this->refreshVariables();
    $this->assertSame(1, \Drupal::state()->get('container_rebuild_test.count', 0));
    $this->drupalGet('/container_rebuild_test/module_test/module_test_system_info_alter');
    $this->assertSession()->pageTextContains('module_test: core/modules/system/tests/modules/module_test');
    $this->assertSession()->pageTextContains('module_test_system_info_alter: true');

    // Move a module to ensure it does not break the rebuild.     $file_system = new Filesystem();
    $file_system->mirror('core/modules/system/tests/modules/module_test', $this->siteDirectory . '/modules/module_test');
    \Drupal::state()->set('container_rebuild_test.count', 0);
    $this->drupalGet(Url::fromUri('base:core/rebuild.php'));
    $this->assertSession()->addressEquals(new Url('<front>'));
    
Home | Imprint | This part of the site doesn't use cookies.