DEV Community

Backlog Slayer
Backlog Slayer

Posted on

4 2

PHP: Testing only changes

changes

Ref: [USATF Mid-Atlantic](https://mausatf.com/background-screening-process-changes/)

I recently found this awesome 😍 tool that let me run tests on only files that have been modified since the last commit, like I'm familiar with in the Jest framework.

Because I couldn't find a way to do this with PHPUnit Watcher or PHPUnit itself, and it worked for me with a few minor blocks, I have decided to share.

If you know how, please tell me in the comments.

The Blocker

The package's PHPUnit dependency was marked as ^6.0, so it wasn't working on my project, which had a dependency marked as ^7.0.

The Fix

I've made a fork here and I use its dev-master branch in my project by adding it to composer.json like:


"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/mykeels/WhatsChanged"
    }
],
"require-dev": {
    "icyapril/whats-changed": "dev-master"
}
Enter fullscreen mode Exit fullscreen mode

This is so that composer resolves the package from my GitHub fork rather than use the official package.

Usage

Now, when run ./vendor/bin/whatschanged, I get:

tests/Feature/AuthTest.php     OK (3 tests, 6 assertions)
tests/Feature/IntentTest.php   OK (5 tests, 21 assertions)
Enter fullscreen mode Exit fullscreen mode

rather than

image

🎉💃 Happy Coding!

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay