PHP code example of previousnext / drupal-test-utils

1. Go to this page and download the library: Download previousnext/drupal-test-utils library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

previousnext / drupal-test-utils example snippets


use PNX\DrupalTestUtils\Traits\ConfigTrait;
use weitzman\DrupalTestTraits\ExistingSiteBase;

abstract class MyBaseClass extends ExistingSiteBase {

  /**
   * {@inheritdoc}
   */
  protected function tearDown(): void {
    $this->setConfigValues($this->originalConfiguration, FALSE);
    parent::tearDown();
  }

}

$this->setConfigValues([
  'system.logging' => [
    'error_level' => \ERROR_REPORTING_DISPLAY_VERBOSE,
  ],
]);

$node = $this->loadEntityByProperty('node', ['title' => 'Hello, World']);

$nodes = $this->loadEntityByProperty('node', ['type' => 'article'], FALSE);

$node = $this->getLastCreatedEntity('node');

/**
 * {@inheritdoc}
 */
protected function drupalGet($path, array $options = [], array $headers = []): string {
  $response = parent::drupalGet($path, $options, $headers);
  $this->detectUncacheableResponse($path, $options);
  return $response;
}

 protected static array $uncacheableDynamicPagePatterns = [
   '/user/login',
   '/big_pipe/no-js',
   '/batch',
   '/node/add/.*',
 ];