Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Docker in order to fix php version #80

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM php:7-cli-alpine
LABEL authors="Mauro Chojrin"

RUN apk update && apk upgrade

RUN mkdir "/app/"

COPY . /app
RUN wget https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer -O - -q | php -- --quiet && \
mv composer.phar /usr/local/bin/composer

RUN apk add --no-cache --virtual .build-dependencies $PHPIZE_DEPS \
&& pecl install xdebug-3.1.0 \
&& docker-php-ext-enable xdebug \
&& pecl clear-cache \
&& apk del .build-dependencies

RUN echo "xdebug.mode = coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

WORKDIR /app
16 changes: 16 additions & 0 deletions php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,19 @@ When running the tests a coverage report should be generated automatically in si
to visualize it from the browser you can open the `coverage/report/index.html` file in a browser after running the tests.

Enjoy

# Note

This application is designed to work with PHP ~7.0. If you don't have this installed locally, a Dockerfile is provided. Assuming you have [Docker](https://docs.docker.com/get-docker/) installed, use the following instructions to get things going:

```shell
docker build . -t php-trip-service
docker run -it -v $(pwd):/app php-trip-service:latest php composer.phar install
```

And to execute the tests:

```shell
docker run -it -v $(pwd):/app php-trip-service:latest php bin/phpunit
```

2 changes: 1 addition & 1 deletion php/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<testsuites>
<testsuite name="TripService Kata Test Suite">
<directory>test/</directory>
<directory suffix="Should.php">test/</directory>
</testsuite>
</testsuites>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
use PHPUnit\Framework\TestCase;
use TripServiceKata\Trip\TripService;

class TripServiceTest extends TestCase
class TripServiceShould extends TestCase
{
/**
* @var TripService
*/
private $tripService;
private TripService $tripService;

protected function setUp()
protected function setUp(): void
{
$this->tripService = new TripService;
$this->tripService = new TripService();
}

/** @test */
public function it_does_something()
public function do_something()
{
$this->fail('This test has not been implemented yet.');
}
Expand Down