PHPackages                             previousnext/drupal-test-utils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. previousnext/drupal-test-utils

ActiveLibrary

previousnext/drupal-test-utils
==============================

Utility traits for Drupal testing.

0.0.4(1y ago)217.0k↓29.2%[3 PRs](https://github.com/previousnext/drupal-test-utils/pulls)GPL-2.0+PHPPHP ^8

Since Dec 13Pushed 1y ago4 watchersCompare

[ Source](https://github.com/previousnext/drupal-test-utils)[ Packagist](https://packagist.org/packages/previousnext/drupal-test-utils)[ RSS](/packages/previousnext-drupal-test-utils/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (8)Used By (0)

Drupal Test Utils
=================

[](#drupal-test-utils)

Utilities for testing Drupal!

ConfigTrait
-----------

[](#configtrait)

A trait to facilitate overriding config for the duration of a test.

### Usage

[](#usage)

Add the trait to your base class and override the tearDown method.

```
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();
  }

}
```

In a test case, call `$this->setConfigValues`:

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

EntityLoadTrait
---------------

[](#entityloadtrait)

A trait to assist with loading entities in tests.

### Usage

[](#usage-1)

Load one node with the title "Hello, World":

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

Load all article nodes:

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

Get the last created node. Useful for asserting on entities created via the UI:

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

ExpectsCacheableResponseTrait
-----------------------------

[](#expectscacheableresponsetrait)

A trait to add Dynamic Page Cache cacheability testing to every request in your Functional tests.

### Usage

[](#usage-2)

Once your trait is added to your test base class, you can check cachability by overriding the `drupalGet` function.

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

### Marking paths as uncacheable

[](#marking-paths-as-uncacheable)

There are some paths that are always uncacheable (i.e pages with forms like node/add). These paths can marked as uncacheable by adding the `$uncacheableDynamicPagePatterns` property to your tests. You can add a common set of these to your test base and add more specific paths in indivdual tests as these patterns will be gathered up the class hierarchy at run time.

Patterns are regular expressions matched with `preg_match`

E.g

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~174 days

Total

4

Last Release

728d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9fb4020bd7f47e4b88e336a1049bdd6e376a64125fd7070889de60e00c34ddce?d=identicon)[pnx-bot](/maintainers/pnx-bot)

![](https://www.gravatar.com/avatar/92d36d6b96f06f66b047afc697b73f2a66df922a642e714d380fb68d0458da40?d=identicon)[skpr](/maintainers/skpr)

---

Top Contributors

[![acbramley](https://avatars.githubusercontent.com/u/569927?v=4)](https://github.com/acbramley "acbramley (5 commits)")[![mstrelan](https://avatars.githubusercontent.com/u/665110?v=4)](https://github.com/mstrelan "mstrelan (3 commits)")

---

Tags

drupal

### Embed Badge

![Health badge](/badges/previousnext-drupal-test-utils/health.svg)

```
[![Health](https://phpackages.com/badges/previousnext-drupal-test-utils/health.svg)](https://phpackages.com/packages/previousnext-drupal-test-utils)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
