-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM php:8.1-fpm | ||
|
||
RUN apt-get update && \ | ||
apt-get -y install --no-install-recommends curl gnupg gnupg2 git wget curl libpng-dev libjpeg62-turbo-dev net-tools \ | ||
libssl-dev libcurl4-openssl-dev pkg-config libxml2-dev zlib1g-dev \ | ||
libpq-dev openssh-client libzip-dev libfreetype6-dev libonig-dev | ||
|
||
RUN docker-php-ext-install bcmath curl xml mbstring zip intl gd | ||
|
||
# Install xdebug | ||
RUN pecl install xdebug | ||
RUN echo "xdebug.mode=debug,coverage\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ | ||
"xdebug.start_with_request=yes\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ | ||
"xdebug.discover_client_host=1\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ | ||
"xdebug.client_host=\"host.docker.internal\"\n" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini | ||
RUN docker-php-ext-enable xdebug | ||
|
||
# Install composer | ||
RUN curl -sS https://getcomposer.org/installer -o composer-setup.php \ | ||
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer | ||
|
||
# Install infection | ||
RUN wget https://github.com/infection/infection/releases/download/0.26.10/infection.phar \ | ||
&& chmod +x infection.phar \ | ||
&& mv infection.phar /usr/local/bin/infection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#upload_max_filesize = 1M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
.idea | ||
composer.lock | ||
vendor/ | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.PHONY: help start stop | ||
|
||
.DEFAULT_GOAL := help | ||
|
||
help: # Show Help | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) | ||
|
||
install: ## First entry command to install all the necessary | ||
make startd | ||
make composer-install | ||
|
||
start: ## Start docker-compose | ||
@docker-compose up | ||
|
||
startd: ## Startd | ||
@docker-compose up -d | ||
|
||
stop: ## Stop | ||
@docker-compose stop | ||
|
||
composer-install: ## Install composer dependencies | ||
@docker exec php sh -c "XDEBUG_MODE=off composer install" | ||
|
||
test: ## Execute PHPUnite test | ||
@docker exec php sh -c "XDEBUG_MODE=off php ./vendor/bin/phpunit -c phpunit.xml.dist" | ||
|
||
coverage-text: ## Execute phpunit coverage in text format | ||
@docker exec php sh -c "XDEBUG_MODE=coverage php -n -dzend_extension=xdebug ./vendor/phpunit/phpunit/phpunit --coverage-text" | ||
|
||
infection: ## Execute Infection | ||
@docker exec php sh -c "XDEBUG_MODE=coverage infection --threads=1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "victormln/docker-php-testing", | ||
"type": "template", | ||
"description": "A project template to have PHP 8.1 and testing tools (PHPUnit + Infection)", | ||
"keywords": ["template"], | ||
"homepage": "https://victormln.gitlab.io", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Víctor Molina", | ||
"email": "victor.molinaf@gmail.com", | ||
"homepage": "https://victormln.gitlab.io" | ||
} | ||
], | ||
"autoload":{ | ||
"psr-4":{ | ||
"Victormln\\DockerPHPTesting\\":"src/" | ||
} | ||
}, | ||
"autoload-dev":{ | ||
"psr-4":{ | ||
"Victormln\\DockerPHPTesting\\Tests\\":"tests/" | ||
} | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: "3.7" | ||
|
||
services: | ||
|
||
php: | ||
build: ./.docker/php | ||
container_name: php | ||
working_dir: /var/www/php | ||
volumes: | ||
- .:/var/www/php:cached | ||
- ./.docker/php/php.ini:/usr/local/etc/php/php.ini:cached |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/infection/infection/0.26.10/resources/schema.json", | ||
"source": { | ||
"directories": [ | ||
"src" | ||
] | ||
}, | ||
"mutators": { | ||
"@default": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html --> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
colors="true" | ||
executionOrder="random" | ||
> | ||
<testsuites> | ||
<testsuite name="Unit Test"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
</coverage> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Victormln\DockerPHPTesting; | ||
|
||
final class Id | ||
{ | ||
public function __construct(private readonly string $id) | ||
{ | ||
} | ||
|
||
public function value(): string | ||
{ | ||
return $this->id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Victormln\DockerPHPTesting\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Victormln\DockerPHPTesting\Id; | ||
|
||
class IdTest extends TestCase | ||
{ | ||
private const EXPECTED_ID = '8b82112f-67ed-46bf-9c60-0c8cf169aabb'; | ||
|
||
public function test_Id_is_created(): void | ||
{ | ||
$id = new Id(self::EXPECTED_ID); | ||
|
||
self::assertSame(self::EXPECTED_ID, $id->value()); | ||
} | ||
} |