Skip to content

Commit 25c708b

Browse files
committed
Add DI + tests
1 parent b221719 commit 25c708b

16 files changed

Lines changed: 268 additions & 143 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
/vendor/
22
composer.lock
33
.php_cs.cache
4+
.php_cs
5+
grumphp.yml
6+
phpunit.xml
7+
var

.php_cs.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ return PhpCsFixer\Config::create()
55
\Symfony\Component\Finder\Finder::create()
66
->in([
77
__DIR__ . '/src',
8-
__DIR__ . '/spec',
8+
__DIR__ . '/test',
99
])
1010
)
1111
->setRiskyAllowed(true)

CONTRIBUTING

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ will be closed (this is selected by default).
1111

1212
## Coverage
1313

14-
- All classes that interact solely with the core logic should be covered by Specs
14+
- All classes that interact solely with the core logic should be covered by Tests
1515

1616
## Code style / Formatting
1717

18-
- All code in the `src` and `spec` folder must follow the PSR-2 standard and should comply with the php-cs-fixer config.
18+
- All code in the `src` and `test` folder must follow the PSR-2 standard and should comply with the php-cs-fixer config.

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ return [
2525
];
2626
```
2727

28-
## Configuration
29-
30-
TODO
31-
32-
3328
## Supported response formats
3429

3530
- application/problem+json
@@ -68,7 +63,7 @@ Body:
6863
"status": 400,
6964
"type": "http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html",
7065
"title": "Bad Request",
71-
"detail": "It aint all bad ..."
66+
"detail": "It ain't all bad ..."
7267
}
7368
```
7469

composer.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"type": "library",
55
"require-dev": {
66
"friendsofphp/php-cs-fixer": "^2.12",
7+
"matthiasnoback/symfony-dependency-injection-test": "^3.0",
78
"phpro/grumphp": "^0.14.1",
8-
"phpspec/phpspec": "^4.3"
9+
"phpunit/phpunit": "^7.2"
910
},
1011
"license": "MIT",
1112
"authors": [
@@ -16,6 +17,7 @@
1617
],
1718
"require": {
1819
"php": "^7.2",
20+
"phpro/api-problem": "dev-basic-api-problem-implementation@dev",
1921
"symfony/dependency-injection": "^4.1",
2022
"symfony/event-dispatcher": "^4.1",
2123
"symfony/http-kernel": "^4.1"
@@ -27,5 +29,16 @@
2729
"psr-4": {
2830
"Phpro\\ApiProblemBundle\\": "src/"
2931
}
30-
}
32+
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"PhproTest\\ApiProblemBundle\\": "test/"
36+
}
37+
},
38+
"repositories": [
39+
{
40+
"type": "git",
41+
"url": "https://github.com/veewee/api-problem.git"
42+
}
43+
]
3144
}

config/services.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
5+
<services>
6+
<service
7+
id="Phpro\ApiProblemBundle\EventListener\JsonApiProblemExceptionListener"
8+
class="Phpro\ApiProblemBundle\EventListener\JsonApiProblemExceptionListener"
9+
>
10+
<argument key="$debug" >%kernel.debug%</argument>
11+
<tag name="kernel.event_listener" event="kernel.exception" method="onKernelException" />
12+
</service>
13+
</services>
14+
</container>

grumphp.yml.dist

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@ parameters:
55
phpcsfixer2:
66
config: ".php_cs.dist"
77
config_contains_finder: true
8-
phpspec:
9-
format: dot
8+
metadata:
9+
priority: 10000
10+
phpunit:
11+
metadata:
12+
priority: 9000
13+
clover_coverage:
14+
clover_file: var/coverage.xml
15+
level: 100
16+
metadata:
17+
priority: 8000
1018
composer:
1119
no_check_lock: true
20+
xmllint:
21+
load_from_net: true
22+
scheme_validation: true
23+
triggered_by: ['xml']

phpspec.yml.dist

Lines changed: 0 additions & 5 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit colors="true">
3+
<testsuites>
4+
<testsuite name="Unit">
5+
<directory>./test</directory>
6+
</testsuite>
7+
</testsuites>
8+
<filter>
9+
<whitelist processUncoveredFilesFromWhitelist="true">
10+
<directory suffix=".php">src</directory>
11+
</whitelist>
12+
</filter>
13+
<logging>
14+
<log type="coverage-clover" target="var/coverage.xml" />
15+
</logging>
16+
</phpunit>

spec/ApiProblemBundleSpec.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)