Skip to content

Commit d53fede

Browse files
author
Thibaud Fabre
committed
Add activator for Phinject integration
1 parent 5921711 commit d53fede

20 files changed

Lines changed: 425 additions & 82 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
composer.phar
22
vendor/
3+
tests/output
34

45
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
56
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file

.scrutinizer.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# .scrutinizer.yml
2+
3+
filter:
4+
paths: [ src/* ]
5+
6+
before_commands:
7+
- "composer install --prefer-source"
8+
9+
tools:
10+
external_code_coverage: true
11+
php_cpd: true
12+
php_pdepend: true
13+
php_code_coverage: true
14+
php_analyzer: true
15+
16+
changetracking:
17+
bug_patterns: ["\bfix(?:es|ed)?\b"]
18+
feature_patterns: ["\badd(?:s|ed)?\b", "\bimplement(?:s|ed)?\b"]

.travis.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- hhvm
8+
9+
env:
10+
- PHP_CURRENT='5.6'
11+
12+
before_script:
13+
- composer selfupdate
14+
- composer install --dev
15+
16+
script:
17+
- make phpunit
18+
- if [ $(phpenv version-name) = $PHP_CURRENT ]; then make test-upload; fi
19+
- if [ $(phpenv version-name) = $PHP_CURRENT ]; then make phpcs bugfree; fi
20+
21+
after_script:
22+
- make clean
23+
24+
matrix:
25+
fast_finish: true
26+
27+
notifications:
28+
webhooks:
29+
urls:
30+
- http://derricks.io/repositories/buildhook/
31+
on_success: always
32+
on_failure: always
33+
on_start: always

Makefile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# If the first argument is one of the supported commands...
2+
SUPPORTED_COMMANDS := "install"
3+
SUPPORTS_MAKE_ARGS := $(findstring $(firstword $(MAKECMDGOALS)), $(SUPPORTED_COMMANDS))
4+
ifneq "$(SUPPORTS_MAKE_ARGS)" ""
5+
# use the rest as arguments for the command
6+
COMMAND_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
7+
# ...and turn them into do-nothing targets
8+
$(eval $(COMMAND_ARGS):;@:)
9+
endif
10+
11+
test: phpunit phpcs bugfree phpmd
12+
test-analysis: phpcs bugfree phpmd
13+
test-upload: scrutinizer
14+
15+
install:
16+
make -f Makefile.docker -- composer install $(COMMAND_ARGS)
17+
18+
update:
19+
20+
.PHONY: test test-analysis test-upload pretest phpunit phpcs phpmd bugfree ocular scrutinizer clean clean-env clean-deps
21+
22+
pretest:
23+
composer install --dev
24+
25+
phpunit: pretest
26+
[ ! -d tests/output ] || mkdir -p tests/output
27+
vendor/bin/phpunit --coverage-text --coverage-clover=tests/output/coverage.clover
28+
29+
ifndef STRICT
30+
STRICT = 0
31+
endif
32+
33+
ifeq "$(STRICT)" "1"
34+
phpcs: pretest
35+
vendor/bin/phpcs --standard=PSR2 src
36+
else
37+
phpcs: pretest
38+
vendor/bin/phpcs --standard=PSR2 -n src
39+
endif
40+
41+
phpcbf: pretest
42+
vendor/bin/phpcbf --standard=PSR2 src
43+
44+
bugfree: pretest
45+
[ ! -f bugfree.json ] || vendor/bin/bugfree generateConfig
46+
vendor/bin/bugfree lint src -c bugfree.json
47+
48+
phpmd: pretest
49+
vendor/bin/phpmd src/ text design,naming,cleancode,codesize,controversial,unusedcode
50+
51+
ocular:
52+
[ ! -f ocular.phar ] && wget https://scrutinizer-ci.com/ocular.phar
53+
54+
ifdef OCULAR_TOKEN
55+
scrutinizer: ocular
56+
@php ocular.phar code-coverage:upload --format=php-clover tests/output/coverage.clover --access-token=$(OCULAR_TOKEN);
57+
else
58+
scrutinizer: ocular
59+
php ocular.phar code-coverage:upload --format=php-clover tests/output/coverage.clover;
60+
endif
61+
62+
clean: clean-env clean-deps
63+
64+
clean-env:
65+
rm -rf coverage.clover
66+
rm -rf ocular.phar
67+
rm -rf tests/output/
68+
69+
clean-deps:
70+
rm -rf vendor/

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "aztech/layers",
33
"description": "Stackable HTTP layers",
44
"require": {
5-
"aztech/phinject": "~0.1",
5+
"aztech/phinject": "~0.2.5",
66
"aztech/php-utils": "~1.0",
77
"league/fractal": "~0.10",
88
"rhumsaa/uuid": "~2.8",

composer.lock

Lines changed: 102 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<phpunit bootstrap="vendor/autoload.php"
2+
colors="true"
3+
convertErrorsToExceptions="true"
4+
convertWarningsToExceptions="true"
5+
convertNoticesToExceptions="true"
6+
>
7+
<testsuites>
8+
<testsuite name="All tests">
9+
<directory suffix=".php">tests/unit</directory>
10+
</testsuite>
11+
</testsuites>
12+
<logging>
13+
<log type="coverage-html" target="./tests/output/Coverage/"
14+
charset="UTF-8" yui="true" highlight="true" />
15+
<log type="junit" target="./tests/output/Results/Results.xml"
16+
logIncompleteSkipped="true" />
17+
</logging>
18+
<filter>
19+
<whitelist addUncoveredFilesFromWhitelist="true">
20+
<directory suffix=".php">src/</directory>
21+
<exclude>
22+
23+
</exclude>
24+
</whitelist>
25+
</filter>
26+
</phpunit>

src/Elements/CallableLayer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ public function __invoke(Request $request)
2626

2727
return $callable($request);
2828
}
29-
}
29+
}

src/Elements/ErrorHandlingLayer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public function __invoke(Request $request)
2121
$controller = $this->controller;
2222

2323
return $controller($request);
24-
}
25-
catch (\Exception $ex) {
24+
} catch (\Exception $ex) {
2625
error_log($ex);
2726

2827
throw new HttpException(500, $ex->getMessage());

0 commit comments

Comments
 (0)