Skip to content

Commit 9bf9b06

Browse files
committed
add phpunit and configure travis
1 parent 628792a commit 9bf9b06

File tree

15 files changed

+3009
-25
lines changed

15 files changed

+3009
-25
lines changed

.editorconfig

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
; see https://editorconfig.org/
2+
; top-most EditorConfig file
3+
root = true
4+
5+
[*]
6+
end_of_line = LF
7+
indent_style = space
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
charset = utf-8
11+
12+
[*.php]
13+
indent_size = 4
14+
15+
[{*.yml,$.yaml}]
16+
indent_size = 4
17+
18+
[docs/**openapi.yml]
19+
indent_size = 2
20+
21+
[*.json]
22+
indent_size = 4
23+
24+
[*.feature]
25+
indent_size = 2
26+
27+
[{.travis.yml,package.json}]
28+
# The indent size used in the `package.json` file cannot be changed
29+
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
30+
indent_size = 2
31+
32+
[Makefile]
33+
indent_style = tab

.env.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS='App\Kernel'
3+
APP_SECRET='$ecretf0rt3st'
4+
SYMFONY_DEPRECATIONS_HELPER=999999

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,19 @@
88
/var/
99
/vendor/
1010
###< symfony/framework-bundle ###
11+
12+
###> phpunit/phpunit ###
13+
/phpunit.xml
14+
.phpunit.result.cache
15+
###< phpunit/phpunit ###
16+
17+
###> symfony/phpunit-bridge ###
18+
.phpunit
19+
.phpunit.result.cache
20+
/phpunit.xml
21+
###< symfony/phpunit-bridge ###
22+
23+
###> friendsofphp/php-cs-fixer ###
24+
/.php_cs
25+
/.php_cs.cache
26+
###< friendsofphp/php-cs-fixer ###

.php_cs.dist

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__)
5+
->exclude('var')
6+
->exclude('public/bundles')
7+
->exclude('public/build')
8+
// exclude files generated by Symfony Flex recipes
9+
->notPath('bin/console')
10+
->notPath('public/index.php')
11+
;
12+
13+
return (new PhpCsFixer\Config())
14+
->setRiskyAllowed(true)
15+
->setRules([
16+
'@Symfony' => true,
17+
'@Symfony:risky' => true,
18+
'linebreak_after_opening_tag' => true,
19+
'mb_str_functions' => true,
20+
'no_php4_constructor' => true,
21+
'no_unreachable_default_argument_value' => true,
22+
'no_useless_else' => true,
23+
'no_useless_return' => true,
24+
'php_unit_strict' => true,
25+
'phpdoc_order' => true,
26+
'strict_comparison' => true,
27+
'strict_param' => true,
28+
])
29+
->setFinder($finder)
30+
;

.travis.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Ensure that PHP is installed in Travis' build environment. Travis provides several versions of
2+
# PHP like 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, etc., each of them including XDebug and PHPUnit.
3+
language: php
4+
sudo: false
5+
6+
# Travis can cache content between builds. This speeds up the build process and saves resources.
7+
cache:
8+
yarn: true
9+
directories:
10+
# Cache composer packages so "composer install" is faster.
11+
- $HOME/.composer/cache/files
12+
13+
# Defines all jobs which Travis will run in parallel. For each PHP version we support we will run one job.
14+
jobs:
15+
# With fast finishing enabled, Travis CI will mark your build as finished as soon as one of two
16+
# conditions are met: The only remaining jobs are allowed to fail, or a job has already failed. In
17+
# these cases, the status of the build can already be determined, so there’s no need to wait around
18+
fast_finish: true
19+
include:
20+
- php: 7.4
21+
22+
before_install:
23+
- phpenv config-rm xdebug.ini || true
24+
25+
install:
26+
- composer install
27+
28+
script:
29+
- ./vendor/bin/phpunit
30+
# this checks that the source code follows the Symfony Code Syntax rules
31+
- './vendor/bin/php-cs-fixer --config=.php_cs.dist fix --diff --dry-run -v'
32+
# this checks that the YAML config files contain no syntax errors
33+
- ./bin/console lint:yaml config --parse-tags
34+
# This checks that arguments injected into services match type declarations.
35+
- ./bin/console lint:container
36+
# this checks that the composer.json and composer.lock files are valid
37+
- composer validate --strict

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# set default shell
2+
SHELL := $(shell which bash)
3+
4+
# default shell options
5+
.SHELLFLAGS = -c
6+
7+
.SILENT: ; # no need for @
8+
.ONESHELL: ; # recipes execute in same shell
9+
.NOTPARALLEL: ; # wait for this target to finish
10+
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
11+
12+
.PHONY: help
13+
14+
help: ## Show Help
15+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
16+
17+
serve: ## Run local dev server
18+
symfony serve -d
19+
20+
log: ## Follow logs on local dev server
21+
symfony server:log
22+
23+
stop: ## Stop local dev server
24+
symfony server:stop
25+
26+
test: ## Run phpunit
27+
vendor/bin/phpunit
28+
29+
fix-style: ## Run php-cs-fixer
30+
vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ Forum PHP 2020 talk (in French) : [Trop de mock tue le test : ce que l'archi hex
77
- Local : [docs/openapi.yml](docs/openapi.yml)
88
- Github Pages : https://jmlamodiere.github.io/tdd-demo-forumphp2020
99
- Swaggger Hub : https://app.swaggerhub.com/apis/JMLamodiere/tdd-demo_forum_php_2020/1.0.0
10+
11+
## Makefile
12+
13+
Run `make` or `make help` to see available commands.

composer.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
2+
"name": "jmlamodiere/tdd-demo-forumphp2020",
3+
"description": "TDD Demo - ForumPHP 2020",
24
"type": "project",
3-
"license": "proprietary",
5+
"license": "MIT",
46
"require": {
5-
"php": ">=7.1.3",
7+
"php": ">=7.4.0",
68
"ext-ctype": "*",
79
"ext-iconv": "*",
810
"symfony/console": "4.4.*",
@@ -12,9 +14,15 @@
1214
"symfony/yaml": "4.4.*"
1315
},
1416
"require-dev": {
15-
"nelmio/cors-bundle": "^2.1"
17+
"friendsofphp/php-cs-fixer": "^2.16",
18+
"nelmio/cors-bundle": "^2.1",
19+
"phpunit/phpunit": "^9.4",
20+
"symfony/phpunit-bridge": "^5.1"
1621
},
1722
"config": {
23+
"platform": {
24+
"php": "7.4.3"
25+
},
1826
"preferred-install": {
1927
"*": "dist"
2028
},
@@ -41,7 +49,7 @@
4149
"scripts": {
4250
"auto-scripts": {
4351
"cache:clear": "symfony-cmd",
44-
"assets:install %PUBLIC_DIR%": "symfony-cmd"
52+
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
4553
},
4654
"post-install-cmd": [
4755
"@auto-scripts"

0 commit comments

Comments
 (0)