Testing with Docker
Docker makes testing existing behavior easier since this library only loads when the PECL OAuth extension is not loaded. This walkthrough assumes you have some familiarity with Docker.
- Checkout the code
- Install dependencies via composer
- Build the docker containers
- Run tests
Get a copy of the code directly from the repository and create a branch to do your development work in.
git clone git@github.com:giberti/ext-oauth-shim.git
cd ext-oauth-shim
git checkout -b my-feature-branch
Install the development dependencies, with composer. If you do not already have composer installed on your system, download composer first.
cd ext-oauth-shim
composer install
To avoid differences between development systems, the following Dockerfile
s provide an environment agnostic platform for testing the extension code. The two builds are identical except that one includes the PECL OAuth extension. Both containers will automatically run the PHPUnit tests when started.
This will build with PHP 7.1.x and PECL OAuth installed.
FROM php:7.1-cli
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y \
libpcre3-dev
RUN pecl install oauth \
&& docker-php-ext-enable oauth
WORKDIR /usr/src/project
CMD ["vendor/bin/phpunit"]
This will build with just the default PHP 7.1.x.
FROM php:7.1-cli
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y
WORKDIR /usr/src/project
CMD ["vendor/bin/phpunit"]
Both containers need to be built before they can be invoked. If you used a directory structure like ./phpunit-71-oauth
and ./phpunit-71
, you can build the containers from the parent directory using the following:
docker build -t phpunit-71-oauth ./phpunit-71-oauth
docker build -t phpunit-71 ./phpunit-71
Now as you actively develop, you can check that the tests are still passing by running the newly created containers and passing the git working directory as a volume to the container. The container will mount the volume each time it's run so you can simply re-run the following run command to run the tests.
docker run -v /path/to/repo/checkout/on/your/system:/usr/src/project phpunit-71-oauth:latest
docker run -v /path/to/repo/checkout/on/your/system:/usr/src/project phpunit-71:latest