Skip to content

Commit 70aa03a

Browse files
authored
Add FT & update UT (#7)
1 parent cf7b4c3 commit 70aa03a

File tree

65 files changed

+5064
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+5064
-167
lines changed

behat.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ default:
22
suites:
33
default:
44
contexts:
5-
- Tests\Functional\BehatContext\FeatureContext: ~
5+
- Tests\Functional\BehatContext\ConstraintTransformerContext: ~
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
Feature: ConstraintToParamsDocTransformer - NotBlank & Blank constraints
2+
3+
Scenario: Simple NotBlank constraint
4+
Given I have the following Constraint:
5+
"""
6+
use Symfony\Component\Validator\Constraints as ConstraintNS;
7+
return new ConstraintNS\NotBlank();
8+
"""
9+
When I transform constraint
10+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\TypeDoc"
11+
## Check others properties
12+
And constraint doc "getName" should return null
13+
And constraint doc "getDescription" should return null
14+
And constraint doc "getDefault" should return null
15+
And constraint doc "getExample" should return null
16+
And constraint doc "isRequired" should return false
17+
And constraint doc "isNullable" should return true
18+
19+
Scenario: Simple NotBlank constraint with string type specified
20+
Given I have the following Constraint:
21+
"""
22+
use Symfony\Component\Validator\Constraints as ConstraintNS;
23+
return new ConstraintNS\NotBlank([
24+
'payload' => [
25+
'documentation' => [
26+
'type' => 'string'
27+
]
28+
]
29+
]);
30+
"""
31+
When I transform constraint
32+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
33+
And constraint doc "getMinLength" should return the number 1
34+
## Check others properties
35+
And constraint doc "getName" should return null
36+
And constraint doc "getDescription" should return null
37+
And constraint doc "getDefault" should return null
38+
And constraint doc "getExample" should return null
39+
And constraint doc "isRequired" should return false
40+
And constraint doc "isNullable" should return true
41+
And constraint doc "getAllowedValueList" should return an empty array
42+
And constraint doc "getFormat" should return null
43+
And constraint doc "getMaxLength" should return null
44+
45+
Scenario: Simple NotBlank constraint with array type specified
46+
Given I have the following Constraint:
47+
"""
48+
use Symfony\Component\Validator\Constraints as ConstraintNS;
49+
return new ConstraintNS\NotBlank([
50+
'payload' => [
51+
'documentation' => [
52+
'type' => 'array'
53+
]
54+
]
55+
]);
56+
"""
57+
When I transform constraint
58+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\ArrayDoc"
59+
And constraint doc "getMinItem" should return the number 1
60+
## Check others properties
61+
And constraint doc "getName" should return null
62+
And constraint doc "getDescription" should return null
63+
And constraint doc "getDefault" should return null
64+
And constraint doc "getExample" should return null
65+
And constraint doc "isRequired" should return false
66+
And constraint doc "isNullable" should return true
67+
And constraint doc "getAllowedValueList" should return an empty array
68+
And constraint doc "getSiblingList" should return an empty array
69+
And constraint doc "getMaxItem" should return null
70+
And constraint doc "isAllowExtraSibling" should return false
71+
And constraint doc "isAllowMissingSibling" should return false
72+
And constraint doc "getItemValidation" should return null
73+
74+
Scenario: Simple Blank constraint with string type specified
75+
Given I have the following Constraint:
76+
"""
77+
use Symfony\Component\Validator\Constraints as ConstraintNS;
78+
return new ConstraintNS\Blank([
79+
'payload' => [
80+
'documentation' => [
81+
'type' => 'string'
82+
]
83+
]
84+
]);
85+
"""
86+
When I transform constraint
87+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
88+
And constraint doc "getMaxLength" should return the number 0
89+
## Check others properties
90+
And constraint doc "getName" should return null
91+
And constraint doc "getDescription" should return null
92+
And constraint doc "getDefault" should return null
93+
And constraint doc "getExample" should return null
94+
And constraint doc "isRequired" should return false
95+
And constraint doc "isNullable" should return true
96+
And constraint doc "getAllowedValueList" should return an empty array
97+
And constraint doc "getFormat" should return null
98+
And constraint doc "getMinLength" should return null
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
Feature: ConstraintToParamsDocTransformer - Fully configured NotBlank & Blank constraints
2+
3+
Scenario: Fully configured NotBlank constraint
4+
Given I have the following Constraint:
5+
"""
6+
use Symfony\Component\Validator\Constraints as ConstraintNS;
7+
return new ConstraintNS\NotBlank([
8+
'payload' => [
9+
'documentation' => [
10+
'description' => 'description',
11+
'default' => 'default',
12+
'example' => 'example',
13+
'required' => true,
14+
'nullable' => false
15+
]
16+
]
17+
]);
18+
"""
19+
When I transform constraint
20+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\TypeDoc"
21+
And constraint doc "getDescription" should return the value "description"
22+
And constraint doc "getDefault" should return the value "default"
23+
And constraint doc "getExample" should return the value "example"
24+
And constraint doc "isRequired" should return true
25+
And constraint doc "isNullable" should return false
26+
## Check others properties
27+
And constraint doc "getName" should return null
28+
And constraint doc "getAllowedValueList" should return an empty array
29+
30+
Scenario: Fully configured NotBlank constraint with string type specified
31+
Given I have the following Constraint:
32+
"""
33+
use Symfony\Component\Validator\Constraints as ConstraintNS;
34+
return new ConstraintNS\NotBlank([
35+
'payload' => [
36+
'documentation' => [
37+
'type' => 'string',
38+
'description' => 'description',
39+
'default' => 'default',
40+
'example' => 'example',
41+
'required' => true,
42+
'nullable' => false
43+
]
44+
]
45+
]);
46+
"""
47+
When I transform constraint
48+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
49+
And constraint doc "getMinLength" should return the number 1
50+
And constraint doc "getDescription" should return the value "description"
51+
And constraint doc "getDefault" should return the value "default"
52+
And constraint doc "getExample" should return the value "example"
53+
And constraint doc "isRequired" should return true
54+
And constraint doc "isNullable" should return false
55+
## Check others properties
56+
And constraint doc "getName" should return null
57+
And constraint doc "getAllowedValueList" should return an empty array
58+
And constraint doc "getFormat" should return null
59+
And constraint doc "getMaxLength" should return null
60+
61+
Scenario: Fully configured NotBlank constraint with array type specified
62+
Given I have the following Constraint:
63+
"""
64+
use Symfony\Component\Validator\Constraints as ConstraintNS;
65+
return new ConstraintNS\NotBlank([
66+
'payload' => [
67+
'documentation' => [
68+
'type' => 'array',
69+
'description' => 'description',
70+
'default' => 'default',
71+
'example' => 'example',
72+
'required' => true,
73+
'nullable' => false
74+
]
75+
]
76+
]);
77+
"""
78+
When I transform constraint
79+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\ArrayDoc"
80+
And constraint doc "getMinItem" should return the number 1
81+
And constraint doc "getDescription" should return the value "description"
82+
And constraint doc "getDefault" should return the value "default"
83+
And constraint doc "getExample" should return the value "example"
84+
And constraint doc "isRequired" should return true
85+
And constraint doc "isNullable" should return false
86+
## Check others properties
87+
And constraint doc "getName" should return null
88+
And constraint doc "getAllowedValueList" should return an empty array
89+
And constraint doc "getSiblingList" should return an empty array
90+
And constraint doc "getMaxItem" should return null
91+
And constraint doc "isAllowExtraSibling" should return false
92+
And constraint doc "isAllowMissingSibling" should return false
93+
And constraint doc "getItemValidation" should return null
94+
95+
Scenario: Fully configured Blank constraint with string type specified
96+
Given I have the following Constraint:
97+
"""
98+
use Symfony\Component\Validator\Constraints as ConstraintNS;
99+
return new ConstraintNS\Blank([
100+
'payload' => [
101+
'documentation' => [
102+
'type' => 'string',
103+
'description' => 'description',
104+
'default' => 'default',
105+
'example' => 'example',
106+
'required' => true,
107+
'nullable' => false
108+
]
109+
]
110+
]);
111+
"""
112+
When I transform constraint
113+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
114+
And constraint doc "getMaxLength" should return the number 0
115+
And constraint doc "getDescription" should return the value "description"
116+
And constraint doc "getDefault" should return the value "default"
117+
And constraint doc "getExample" should return the value "example"
118+
And constraint doc "isRequired" should return true
119+
And constraint doc "isNullable" should return false
120+
## Check others properties
121+
And constraint doc "getName" should return null
122+
And constraint doc "getAllowedValueList" should return an empty array
123+
And constraint doc "getFormat" should return null
124+
And constraint doc "getMinLength" should return null
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Feature: ConstraintToParamsDocTransformer - NotNull & IsNull constraints
2+
3+
Scenario: Simple IsNull constraint
4+
Given I have the following Constraint:
5+
"""
6+
use Symfony\Component\Validator\Constraints as ConstraintNS;
7+
return new ConstraintNS\IsNull();
8+
"""
9+
When I transform constraint
10+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\TypeDoc"
11+
And constraint doc "isNullable" should return true
12+
And constraint doc "getAllowedValueList" should return:
13+
"""
14+
[null]
15+
"""
16+
## Check others properties
17+
And constraint doc "getName" should return null
18+
And constraint doc "getDescription" should return null
19+
And constraint doc "getDefault" should return null
20+
And constraint doc "getExample" should return null
21+
And constraint doc "isRequired" should return false
22+
23+
Scenario: Simple NotNull constraint with string type specified
24+
Given I have the following Constraint:
25+
"""
26+
use Symfony\Component\Validator\Constraints as ConstraintNS;
27+
return new ConstraintNS\NotNull([
28+
'payload' => [
29+
'documentation' => [
30+
'type' => 'string'
31+
]
32+
]
33+
]);
34+
"""
35+
When I transform constraint
36+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
37+
And constraint doc "isNullable" should return false
38+
## Check others properties
39+
And constraint doc "getName" should return null
40+
And constraint doc "getDescription" should return null
41+
And constraint doc "getDefault" should return null
42+
And constraint doc "getExample" should return null
43+
And constraint doc "isRequired" should return false
44+
And constraint doc "getAllowedValueList" should return an empty array
45+
And constraint doc "getFormat" should return null
46+
And constraint doc "getMinLength" should return null
47+
And constraint doc "getMaxLength" should return null
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Feature: ConstraintToParamsDocTransformer - Fully configured NotNull & IsNull constraints
2+
3+
Scenario: Fully configured NotNull constraint
4+
Given I have the following Constraint:
5+
"""
6+
use Symfony\Component\Validator\Constraints as ConstraintNS;
7+
return new ConstraintNS\NotNull([
8+
'payload' => [
9+
'documentation' => [
10+
'description' => 'description',
11+
'default' => 'default',
12+
'example' => 'example',
13+
'required' => true,
14+
'nullable' => false
15+
]
16+
]
17+
]);
18+
"""
19+
When I transform constraint
20+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\TypeDoc"
21+
And constraint doc "getDescription" should return the value "description"
22+
And constraint doc "getDefault" should return the value "default"
23+
And constraint doc "getExample" should return the value "example"
24+
And constraint doc "isRequired" should return true
25+
And constraint doc "isNullable" should return false
26+
## Check others properties
27+
And constraint doc "getName" should return null
28+
And constraint doc "getAllowedValueList" should return an empty array
29+
30+
Scenario: Fully configured NotNull constraint with string type specified
31+
Given I have the following Constraint:
32+
"""
33+
use Symfony\Component\Validator\Constraints as ConstraintNS;
34+
return new ConstraintNS\NotNull([
35+
'payload' => [
36+
'documentation' => [
37+
'type' => 'string',
38+
'description' => 'description',
39+
'default' => 'default',
40+
'example' => 'example',
41+
'required' => true,
42+
'nullable' => false
43+
]
44+
]
45+
]);
46+
"""
47+
When I transform constraint
48+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
49+
And constraint doc "getDescription" should return the value "description"
50+
And constraint doc "getDefault" should return the value "default"
51+
And constraint doc "getExample" should return the value "example"
52+
And constraint doc "isRequired" should return true
53+
And constraint doc "isNullable" should return false
54+
## Check others properties
55+
And constraint doc "getName" should return null
56+
And constraint doc "getAllowedValueList" should return an empty array
57+
And constraint doc "getFormat" should return null
58+
And constraint doc "getMinLength" should return null
59+
And constraint doc "getMaxLength" should return null
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Feature: ConstraintToParamsDocTransformer - IsTrue & IsFalse constraints
2+
3+
Scenario: Simple IsTrue constraint
4+
Given I have the following Constraint:
5+
"""
6+
use Symfony\Component\Validator\Constraints as ConstraintNS;
7+
return new ConstraintNS\IsTrue();
8+
"""
9+
When I transform constraint
10+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\BooleanDoc"
11+
And constraint doc "getAllowedValueList" should return:
12+
"""
13+
[true, 1, "1"]
14+
"""
15+
And constraint doc "isNullable" should return false
16+
And constraint doc "getDefault" should return true
17+
And constraint doc "getExample" should return true
18+
## Check others properties
19+
And constraint doc "getName" should return null
20+
And constraint doc "getDescription" should return null
21+
And constraint doc "isRequired" should return false
22+
23+
Scenario: Simple IsFalse constraint
24+
Given I have the following Constraint:
25+
"""
26+
use Symfony\Component\Validator\Constraints as ConstraintNS;
27+
return new ConstraintNS\IsFalse();
28+
"""
29+
When I transform constraint
30+
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\BooleanDoc"
31+
And constraint doc "getAllowedValueList" should return:
32+
"""
33+
[false, 0, "0"]
34+
"""
35+
And constraint doc "isNullable" should return false
36+
And constraint doc "getDefault" should return false
37+
And constraint doc "getExample" should return false
38+
## Check others properties
39+
And constraint doc "getName" should return null
40+
And constraint doc "getDescription" should return null
41+
And constraint doc "isRequired" should return false

0 commit comments

Comments
 (0)