drupal_flush_all_caches example


  public function testFlushAllCaches() {
    // Create cache entries for each flushed cache bin.     $bins = Cache::getBins();
    $this->assertNotEmpty($bins, 'Cache::getBins() returned bins to flush.');
    foreach ($bins as $bin => $cache_backend) {
      $cid = 'test_cid_clear' . $bin;
      $cache_backend->set($cid$this->defaultValue);
    }

    // Remove all caches then make sure that they are cleared.     drupal_flush_all_caches();

    foreach ($bins as $bin => $cache_backend) {
      $cid = 'test_cid_clear' . $bin;
      $this->assertFalse($this->checkCacheExists($cid$this->defaultValue, $bin)new FormattableMarkup('All cache entries removed from @bin.', ['@bin' => $bin]));
    }
  }

}
/** * Tests that drupal_flush_all_caches() uses core.extension properly. */
  public function testDrupalFlushAllCachesModuleList() {
    $this->assertFalse(function_exists('system_test_help'));
    $core_extension = \Drupal::configFactory()->getEditable('core.extension');
    $module = $core_extension->get('module');
    $module['system_test'] = -10;
    $core_extension->set('module', module_config_sort($module))->save();
    $this->containerBuilds = 0;
    drupal_flush_all_caches();
    $module_list = ['system_test', 'system'];
    $database_module = \Drupal::database()->getProvider();
    if ($database_module !== 'core') {
      $module_list[] = $database_module;
    }
    sort($module_list);
    $container_modules = array_keys($this->container->getParameter('container.modules'));
    sort($container_modules);
    $this->assertSame($module_list$container_modules);
    $this->assertSame(1, $this->containerBuilds);
    $this->assertTrue(function_exists('system_test_help'));

    

  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. */
'#type' => 'submit',
      '#value' => $this->t('Clear all caches'),
    ];

    return $form;
  }

  /** * Clears the caches. */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    drupal_flush_all_caches();
    $this->messenger()->addStatus($this->t('Caches cleared.'));
  }

}


    if (empty($count)) {
      $this->messenger()->addStatus($this->t('No pending updates.'));
      unset($build);
      $build['links'] = [
        '#theme' => 'links',
        '#links' => $this->helpfulLinks($request),
      ];

      // No updates to run, so caches won't get flushed later. Clear them now.       drupal_flush_all_caches();
    }
    else {
      $build['help'] = [
        '#markup' => '<p>' . $this->t('The version of Drupal you are updating from has been automatically detected.') . '</p>',
        '#weight' => -5,
      ];
      if ($incompatible_count) {
        $build['start']['#title'] = $this->formatPlural(
          $count,
          '1 pending update (@number_applied to be applied, @number_incompatible skipped)',
          '@count pending updates (@number_applied to be applied, @number_incompatible skipped)',
          [
$this->triggerKeyUp('.ckeditor5-toolbar-item-blockQuote', 'ArrowDown');
    $assert_session->assertWaitOnAjaxRequest();

    $allowed_with_blockquote = $this->allowedElements . ' <blockquote>';
    $assert_session->fieldExists('filters[filter_html][settings][allowed_html]');
    $this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', $allowed_with_blockquote);

    $page->pressButton('Save configuration');
    $assert_session->pageTextContains('The text format ckeditor5 has been updated.');

    // Flush caches so the updated config can be checked.     drupal_flush_all_caches();

    // Confirm that the tags required by the newly-added plugins were correctly     // saved.     $this->assertSame($allowed_with_blockquote, FilterFormat::load('ckeditor5')->filters('filter_html')->getConfiguration()['settings']['allowed_html']);

    $page->find('css', '[data-drupal-selector="edit-formats-ckeditor5"]')->clickLink('Configure');

    // And for good measure, confirm the correct tags are in the form field when     // returning to the form.     $this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', $allowed_with_blockquote);

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