docker-php icon indicating copy to clipboard operation
docker-php copied to clipboard

Add tests

Open jaydrogers opened this issue 3 years ago • 5 comments

Summary

  • It would be helpful to add tests

Order

It would be nice to have each image go through these steps:

  1. Setup (Pull base images & login to Docker)
  2. Build
  3. Test
  4. Push

What needs to be figured out yet

  • What is the best way to "test" that PHP is working?
  • Will it change on each deployment type (CLI, FPM, FPM-NGINX)

Helpful resources

Here's some code that was provided by Github for reference:

  # Run tests.
  # See also https://docs.docker.com/docker-hub/builds/automated-testing/
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Run tests
        run: |
          if [ -f docker-compose.test.yml ]; then
            docker-compose --file docker-compose.test.yml build
            docker-compose --file docker-compose.test.yml run sut
          else
            docker build . --file Dockerfile
          fi

  Push image to GitHub Packages.
  See also https://docs.docker.com/docker-hub/builds/

jaydrogers avatar Mar 09 '21 19:03 jaydrogers

What is the best way to "test" that PHP is working?

Run Laravel unit tests??

szepeviktor avatar Mar 09 '21 20:03 szepeviktor

What is the best way to "test" that PHP is working?

I would think just PHP commands would be sufficient, e.g. php -v, php -i, etc. They'll also let you assert that extensions are installed.

AkenRoberts avatar Mar 09 '21 23:03 AkenRoberts

Awesome! Thanks for the insight @AkenRoberts!

jaydrogers avatar Mar 09 '21 23:03 jaydrogers

I would think just PHP commands would be sufficient, e.g. php -v, php -i, etc.

That is like assuming an SQL server is okay by querying its version. Real life functional tests reveal real life problems.

szepeviktor avatar Mar 10 '21 04:03 szepeviktor

Right. Maybe more functional tests to ensure PHP is behaving would be useful for a container providing it. I don't see that immediately ('certainly PHP itself is well-tested'), but admittedly that could be naive.

Definitely choose the level of testing that ensures the value provided to end users is maintained. 👍🏼

AkenRoberts avatar Mar 10 '21 04:03 AkenRoberts