Commands Overview

osdd:phpunit

Sync phpunit.xml with all layer test suites.

osdd:phpunit reads phpunit.xml, discovers all valid layers, and adds a <testsuite> entry for each layer that has a tests/ directory but is not already registered.

Requires the DOM PHP extension.

Usage

Terminal
php artisan osdd:phpunit

What It Does

  1. Reads your existing phpunit.xml
  2. Adds a <source><exclude><directory>**/database/migrations</directory></exclude></source> block so every layer's migrations are excluded from code coverage
  3. Discovers all layers via LayersCollection::fromConfig()
  4. For each layer that has a tests/ directory and is not yet registered, injects a new <testsuite> block
  5. Writes the updated phpunit.xml back to disk

Both additions are idempotent — already-registered suites and an already-present migration exclusion are left untouched. The file is written even when no layers are discovered, so the coverage exclusion still lands.

Example Output

After running the command with two layers (functional/users and functional/orders), your phpunit.xml gains:

phpunit.xml
<testsuites>
    <testsuite name="Unit">
        <directory suffix="Test.php">./tests/Unit</directory>
    </testsuite>
    <testsuite name="Feature">
        <directory suffix="Test.php">./tests/Feature</directory>
    </testsuite>
    <!-- Added by osdd:phpunit -->
    <testsuite name="functional/users">
        <directory suffix="Test.php">./functional/users/tests</directory>
    </testsuite>
    <testsuite name="functional/orders">
        <directory suffix="Test.php">./functional/orders/tests</directory>
    </testsuite>
</testsuites>

<!-- Added by osdd:phpunit -->
<source>
    <exclude>
        <directory suffix=".php">**/database/migrations</directory>
    </exclude>
</source>

Running Layer Tests

Once registered, you can run a specific layer's tests:

Terminal
# Run a single layer's tests
./vendor/bin/phpunit --testsuite=functional/orders

# Run all tests including all layers
./vendor/bin/phpunit

Keeping It in Sync

Re-run osdd:phpunit any time you add a new layer with tests. The command is idempotent — already-registered suites are left unchanged.

Terminal
# Add a new layer
php artisan osdd:layer
# Add tests to the layer...

# Re-sync phpunit.xml
php artisan osdd:phpunit