PHPackages                             thursdaybw/dtt\_multi\_device\_test\_base - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. thursdaybw/dtt\_multi\_device\_test\_base

ActiveLibrary[Testing &amp; Quality](/categories/testing)

thursdaybw/dtt\_multi\_device\_test\_base
=========================================

Reusable base classes for running Drupal Test Traits (DTT) tests in multiple browser/device contexts — such as desktop, mobile, tablet, or anything Selenium supports.

10PHP

Since Jul 26Pushed 9mo agoCompare

[ Source](https://github.com/thursdaybw/dtt_multi_device_test_base)[ Packagist](https://packagist.org/packages/thursdaybw/dtt_multi_device_test_base)[ RSS](/packages/thursdaybw-dtt-multi-device-test-base/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

🧪 DTT Multi Device Test Base
============================

[](#-dtt-multi-device-test-base)

Reusable **base classes** for running [**Drupal Test Traits (DTT)**](https://github.com/weitzman/drupal-test-traits) tests in **multiple browser/device contexts** — such as desktop, mobile, tablet, or anything Selenium supports.

This package lets each PHPUnit test class declare its own use of a **device profile** defined in a shared yaml file.

It enables enabling true per-test responsive assertions like:

```
class HomepageMobileTest extends MobileTestBase {}
class HomepageDesktopTest extends DesktopTestBase {}
```

✅ Works even in a single test run — no need for multiple configs or CI matrix gymnastics.

It fills a gap that cannot be solved by multiple PHPUnit configs or CI matrix runs alone.

This gives you:

```
Multiple device profiles in one test suite

Semantically clear test classes like GenerateCaptionsMobileTest vs GenerateCaptionsDesktopTest

Flexibility beyond what DTT’s env-var-based driver loading allows

```

---

Features
--------

[](#features)

- `DeviceProfileTestBase` class:
    - Loads [Mink](https://mink.behat.org/) Selenium2Driver args from a YAML file
    - Allows subclasses to declare it's use of a a device profile like `'small_mobile'` or `'desktop'` via `getDeviceProfileKey()`
- Base class (`DeviceProfileTestBase`) that:
    - Loads custom Selenium2Driver capabilities from a YAML config file
- Includes `DesktopTestBase` and `MobileTestBase` ready to use
- Built on top of `ExistingSiteSelenium2DriverTestBase` from DTT
- Compatible with Composer-based Drupal installs
- Avoids test logic pollution like `if (mobile)` inside a shared test
- Supports fallback default profiles

---

💡 Why Not Just Use PHPUnit Configs?
-----------------------------------

[](#-why-not-just-use-phpunit-configs)

Multiple configs or CI matrixes **run the same tests in different environments** — but they **can’t change behavior per test class**.

This library allows distinct classes like:

- `GenerateCaptionsMobileTest` to assert mobile-only behavior
- `GenerateCaptionsDesktopTest` to assert desktop-only UI

That's fine for:

- "Run all tests in Chrome"
- "Run the same test in Firefox, too"

But it **doesn't allow** writing a test like:

```
class HomepageDesktopTest extends DesktopTestBase
class HomepageMobileTest extends MobileTestBase
```

These aren't alternate environments. They're **different tests** with different expectations.

Consider this use case:

```
GenerateCaptionsMobileTest asserts mobile behavior

GenerateCaptionsDesktopTest asserts desktop behavior

```

They are different tests with different expectations. Running the same class in different configs won't help, you'd either:

```
* Skip or fail assertions that don’t apply to the current env

* Or make the test logic messier with branching like if (MOBILE) {...}

```

Installation
------------

[](#installation)

### Require the Library

[](#require-the-library)

Until it's released on Packagist, use the VCS method.

in composer.json:

```
{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/thursdaybw/dtt_multi_device_test_base"
    }
  ],
}
```

Then:

```
composer require --dev thursdaybw/dtt_multi_device_test_base:dev-main
```

---

🧩 Dependencies
--------------

[](#-dependencies)

This module assumes you're already using [Drupal Test Traits (DTT)](https://github.com/weitzman/drupal-test-traits) and have it fully configured.

---

⚙️ Configuration
----------------

[](#️-configuration)

### 1. Ensure You're Using DTT's `bootstrap.php`

[](#1-ensure-youre-using-dtts-bootstrapphp)

You **must use DTT’s full bootstrap**, *not* `bootstrap-fast.php`, in your `phpunit.dtt.xml`:

```

```

🚫 `bootstrap-fast.php` is faster but skips full autoloading, which will break test class discovery for this module.

⚠️ bootstrap-fast.php may work but autoloading with boostrap-fast.php is untested.
----------------------------------------------------------------------------------

[](#️-bootstrap-fastphp-may-work-but-autoloading-with-boostrap-fastphp-is-untested)

The default file (`device_profiles.default.yaml`) is included, but you can create your own like this:

### 2. (optional) Configure the Device Profile YAML Path

[](#2-optional-configure-the-device-profile-yaml-path)

In your `phpunit.xml` or `phpunit.dtt.xml`:

```

```

✅ **Use a full path.**Relative paths to the project root do work but are flaky and PHPUnit may change the working directory under the hood, especially in IDEs or CI.

---

### 2. (optional) Create Your YAML Config

[](#2-optional-create-your-yaml-config)

Example `dtt_device_profiles.yaml`:

```
small_mobile:
  - "chrome"
  - chromeOptions:
      mobileEmulation: { deviceName: "Pixel 2" }
      args: ["--window-size=412,732", "--disable-gpu", "--no-sandbox"]
  - "http://selenium-chrome:4444/wd/hub"

desktop:
  - "chrome"
  - chromeOptions:
      args: ["--window-size=1920,1080", "--disable-gpu", "--no-sandbox"]
  - "http://selenium-chrome:4444/wd/hub"
```

---

Usage
-----

[](#usage)

Extend the provided base classes that use the default config:

```
use thursdaybw\DttMultiDeviceTestBase\MobileTestBase;

class HomepageMobileTest extends MobileTestBase {
  public function testMobileNav() {
    $this->visit('/');
    $this->assertSession()->elementNotExists('css', '.desktop-nav');
  }
}
```

```
use thursdaybw\DttMultiDeviceTestBase\DesktopTestBase;

class HomepageDesktopTest extends DesktopTestBase {
  public function testDesktopNav() {
    $this->visit('/');
    $this->assertSession()->elementExists('css', '.desktop-nav');
  }
}

```

or Extend DeviceProfileTestBase in your test classes to use your own config:

```
use thursdaybw\DttMultiDeviceTestBase\DeviceProfieTestBase;

class MyMobileTest extends DeviceProfileTestBase {
  protected function getDeviceProfileKey(): string {
    return 'small_mobile'; # or whatever name you defined in your own yaml config
  }

  public function testMobileStuff() {
    $this->visit('/');
    $this->assertSession()->elementNotExists('css', '.desktop-nav');
  }
}
```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance41

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/df355dd4a4783792e3bbe74395e2550ae665a235307056ebbe106d6e4e4e24af?d=identicon)[thursdaybw](/maintainers/thursdaybw)

---

Top Contributors

[![thursdaybw](https://avatars.githubusercontent.com/u/8906871?v=4)](https://github.com/thursdaybw "thursdaybw (14 commits)")

### Embed Badge

![Health badge](/badges/thursdaybw-dtt-multi-device-test-base/health.svg)

```
[![Health](https://phpackages.com/badges/thursdaybw-dtt-multi-device-test-base/health.svg)](https://phpackages.com/packages/thursdaybw-dtt-multi-device-test-base)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M678](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M753](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M571](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.0k](/packages/orchestra-testbench)

PHPackages © 2026

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