Skip to content

Commit 49cf153

Browse files
authored
Improve (#9)
1 parent 78c7d05 commit 49cf153

File tree

7 files changed

+46
-9
lines changed

7 files changed

+46
-9
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ COVERAGE_OUTPUT_STYLE ?= html
66
BUILD_DIRECTORY ?= build
77
REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports
88
COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage
9+
BEHAT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/behat-coverage
910
COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml
1011

1112
## Commands options
@@ -88,15 +89,21 @@ codestyle: create-reports-directory
8889
coverage: create-coverage-directory
8990
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION}
9091

92+
behat-coverage: create-behat-coverage-directory
93+
composer required leanphp/behat-code-coverage
94+
./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --no-snippets --profile coverage
9195

9296

9397
# Internal commands
9498
create-coverage-directory:
9599
mkdir -p ${COVERAGE_DIRECTORY}
96100

101+
create-behat-coverage-directory:
102+
mkdir -p ${BEHAT_COVERAGE_DIRECTORY}
103+
97104
create-reports-directory:
98105
mkdir -p ${REPORTS_DIRECTORY}
99106

100107

101-
.PHONY: build install configure test test-technical test-functional codestyle coverage create-coverage-directory create-reports-directory
108+
.PHONY: build install configure test test-technical test-functional codestyle coverage behat-coverage create-coverage-directory create-behat-coverage-directory create-reports-directory
102109
.DEFAULT: build

behat.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,17 @@ default:
33
default:
44
contexts:
55
- Tests\Functional\BehatContext\ConstraintTransformerContext: ~
6+
coverage:
7+
extensions:
8+
LeanPHP\Behat\CodeCoverage\Extension:
9+
drivers:
10+
- local
11+
filter:
12+
whitelist:
13+
include:
14+
directories:
15+
'src': ~
16+
report:
17+
format: html
18+
options:
19+
target: build/behat-coverage

phpunit.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
processIsolation="false"
99

1010
stopOnRisky="true"
11-
1211
stopOnError="true"
1312
stopOnFailure="true"
1413

src/App/Helper/DocTypeHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class DocTypeHelper
2525

2626
/**
2727
* @param ConstraintPayloadDocHelper $constraintPayloadDocHelper
28+
* @param TypeGuesser $typeGuesser
2829
*/
2930
public function __construct(ConstraintPayloadDocHelper $constraintPayloadDocHelper, TypeGuesser $typeGuesser)
3031
{

src/App/Helper/StringDocHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
class StringDocHelper
1313
{
1414
/**
15-
* @param TypeDoc $doc
15+
* @param TypeDoc $doc
1616
* @param Constraint $constraint
17+
*
18+
* @throws \ReflectionException
1719
*/
1820
public function append(TypeDoc $doc, Constraint $constraint)
1921
{

src/Infra/Transformer/ConstraintToParamsDocTransformer.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class ConstraintToParamsDocTransformer
2727

2828
/**
2929
* @param DocTypeHelper $docTypeHelper
30+
* @param StringDocHelper $stringDocHelper
31+
* @param MinMaxHelper $minMaxHelper
3032
* @param ConstraintPayloadDocHelper $constraintPayloadDocHelper
3133
*/
3234
public function __construct(
@@ -45,6 +47,8 @@ public function __construct(
4547
* @param Constraint $constraint
4648
*
4749
* @return TypeDoc
50+
*
51+
* @throws \ReflectionException
4852
*/
4953
public function transform(Constraint $constraint) : TypeDoc
5054
{
@@ -55,6 +59,8 @@ public function transform(Constraint $constraint) : TypeDoc
5559
* @param Constraint[] $constraintList
5660
*
5761
* @return TypeDoc
62+
*
63+
* @throws \ReflectionException
5864
*/
5965
public function transformList(array $constraintList) : TypeDoc
6066
{
@@ -68,8 +74,10 @@ public function transformList(array $constraintList) : TypeDoc
6874
}
6975

7076
/**
71-
* @param TypeDoc $doc
72-
* @param Constraint $constraint
77+
* @param TypeDoc $doc
78+
* @param Constraint $constraint
79+
*
80+
* @throws \ReflectionException
7381
*/
7482
private function appendToDoc(TypeDoc $doc, Constraint $constraint) : void
7583
{
@@ -127,8 +135,10 @@ private function appendToDoc(TypeDoc $doc, Constraint $constraint) : void
127135
}
128136

129137
/**
130-
* @param TypeDoc $doc
138+
* @param TypeDoc $doc
131139
* @param Constraint $constraint
140+
*
141+
* @throws \ReflectionException
132142
*/
133143
private function appendCollectionDoc(TypeDoc $doc, Constraint $constraint) : void
134144
{
@@ -185,6 +195,8 @@ private function appendValidItemListDoc(TypeDoc $doc, Constraint $constraint) :
185195
/**
186196
* @param ArrayDoc $doc
187197
* @param Assert\All $constraint
198+
*
199+
* @throws \ReflectionException
188200
*/
189201
private function appendAllConstraintToDoc(ArrayDoc $doc, Assert\All $constraint) : void
190202
{

tests/Functional/App/Helper/StringDocHelperTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ public function setUp()
2727
public function testShouldDoNothingIfNotAStringDoc()
2828
{
2929
$doc = new TypeDoc();
30+
$constraint = $this->prophesize(Assert\Date::class);
3031

31-
$this->assertNull(
32-
$this->helper->append($doc, $this->prophesize(Assert\Date::class)->reveal())
33-
);
32+
$this->helper->append($doc, $constraint->reveal());
33+
34+
// there only to avoid "This test did not perform any assertions" issue
35+
$this->assertNull(null);
3436
}
3537

3638
/**

0 commit comments

Comments
 (0)