Skip to content

Improve FTs #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 33 additions & 18 deletions features/01_basic-constraints/blank-constraints.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ Feature: ConstraintToParamsDocTransformer - NotBlank & Blank constraints
return new ConstraintNS\NotBlank([
'payload' => [
'documentation' => [
'type' => 'string'
'type' => 'string',
'description' => 'description',
'default' => 'default',
'example' => 'example',
'required' => true,
'nullable' => false
]
]
]);
Expand All @@ -33,11 +38,11 @@ Feature: ConstraintToParamsDocTransformer - NotBlank & Blank constraints
And constraint doc "getMinLength" should return the number 1
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getDescription" should return null
And constraint doc "getDefault" should return null
And constraint doc "getExample" should return null
And constraint doc "isRequired" should return false
And constraint doc "isNullable" should return true
And constraint doc "getDescription" should return the value "description"
And constraint doc "getDefault" should return the value "default"
And constraint doc "getExample" should return the value "example"
And constraint doc "isRequired" should return true
And constraint doc "isNullable" should return false
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getFormat" should return null
And constraint doc "getMaxLength" should return null
Expand All @@ -49,7 +54,12 @@ Feature: ConstraintToParamsDocTransformer - NotBlank & Blank constraints
return new ConstraintNS\NotBlank([
'payload' => [
'documentation' => [
'type' => 'array'
'type' => 'array',
'description' => 'description',
'default' => 'default',
'example' => 'example',
'required' => true,
'nullable' => false
]
]
]);
Expand All @@ -59,11 +69,11 @@ Feature: ConstraintToParamsDocTransformer - NotBlank & Blank constraints
And constraint doc "getMinItem" should return the number 1
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getDescription" should return null
And constraint doc "getDefault" should return null
And constraint doc "getExample" should return null
And constraint doc "isRequired" should return false
And constraint doc "isNullable" should return true
And constraint doc "getDescription" should return the value "description"
And constraint doc "getDefault" should return the value "default"
And constraint doc "getExample" should return the value "example"
And constraint doc "isRequired" should return true
And constraint doc "isNullable" should return false
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getSiblingList" should return an empty array
And constraint doc "getMaxItem" should return null
Expand All @@ -78,7 +88,12 @@ Feature: ConstraintToParamsDocTransformer - NotBlank & Blank constraints
return new ConstraintNS\Blank([
'payload' => [
'documentation' => [
'type' => 'string'
'type' => 'string',
'description' => 'description',
'default' => 'default',
'example' => 'example',
'required' => true,
'nullable' => false
]
]
]);
Expand All @@ -88,11 +103,11 @@ Feature: ConstraintToParamsDocTransformer - NotBlank & Blank constraints
And constraint doc "getMaxLength" should return the number 0
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getDescription" should return null
And constraint doc "getDefault" should return null
And constraint doc "getExample" should return null
And constraint doc "isRequired" should return false
And constraint doc "isNullable" should return true
And constraint doc "getDescription" should return the value "description"
And constraint doc "getDefault" should return the value "default"
And constraint doc "getExample" should return the value "example"
And constraint doc "isRequired" should return true
And constraint doc "isNullable" should return false
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getFormat" should return null
And constraint doc "getMinLength" should return null
16 changes: 11 additions & 5 deletions features/01_basic-constraints/null-constraints.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ Feature: ConstraintToParamsDocTransformer - NotNull & IsNull constraints
return new ConstraintNS\NotNull([
'payload' => [
'documentation' => [
'type' => 'string'
'type' => 'string',
'description' => 'description',
'default' => 'default',
'example' => 'example',
'required' => true,
'nullable' => false
]
]
]);
Expand All @@ -37,10 +42,11 @@ Feature: ConstraintToParamsDocTransformer - NotNull & IsNull constraints
And constraint doc "isNullable" should return false
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getDescription" should return null
And constraint doc "getDefault" should return null
And constraint doc "getExample" should return null
And constraint doc "isRequired" should return false
And constraint doc "getDescription" should return the value "description"
And constraint doc "getDefault" should return the value "default"
And constraint doc "getExample" should return the value "example"
And constraint doc "isRequired" should return true
And constraint doc "isNullable" should return false
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getFormat" should return null
And constraint doc "getMinLength" should return null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Feature: ConstraintToParamsDocTransformer - Url constraint
Feature: ConstraintToParamsDocTransformer - Cidr constraint

Scenario: Simple Url constraint
Scenario: Simple Cidr constraint
Given I have the following Constraint:
"""
use Symfony\Component\Validator\Constraints as ConstraintNS;
return new ConstraintNS\Url();
return new ConstraintNS\Cidr();
"""
When I transform constraint
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
And constraint doc "getFormat" should return the value "url"
And constraint doc "getFormat" should return the value "cidr"
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getDescription" should return null
Expand All @@ -20,12 +20,11 @@ Feature: ConstraintToParamsDocTransformer - Url constraint
And constraint doc "getMinLength" should return null
And constraint doc "getMaxLength" should return null

Scenario: Fully configured Url constraint
Scenario: Fully configured Cidr constraint
Given I have the following Constraint:
"""
use Symfony\Component\Validator\Constraints as ConstraintNS;
return new ConstraintNS\Url([
'protocols' => ['http'],
return new ConstraintNS\Cidr([
'payload' => [
'documentation' => [
'description' => 'description',
Expand All @@ -39,7 +38,7 @@ Feature: ConstraintToParamsDocTransformer - Url constraint
"""
When I transform constraint
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
And constraint doc "getFormat" should return the value "url"
And constraint doc "getFormat" should return the value "cidr"
And constraint doc "getDescription" should return the value "description"
And constraint doc "getDefault" should return the value "default"
And constraint doc "getExample" should return the value "example"
Expand All @@ -50,3 +49,4 @@ Feature: ConstraintToParamsDocTransformer - Url constraint
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getMinLength" should return null
And constraint doc "getMaxLength" should return null

51 changes: 51 additions & 0 deletions features/02_string-constraints/css-color-constraint.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Feature: ConstraintToParamsDocTransformer - CssColor constraint

Scenario: Simple CssColor constraint
Given I have the following Constraint:
"""
use Symfony\Component\Validator\Constraints as ConstraintNS;
return new ConstraintNS\CssColor();
"""
When I transform constraint
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getDescription" should return null
And constraint doc "getDefault" should return null
And constraint doc "getExample" should return null
And constraint doc "isNullable" should return true
And constraint doc "isRequired" should return false
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getMinLength" should return null
And constraint doc "getMaxLength" should return null

Scenario: Fully configured CssColor constraint
Given I have the following Constraint:
"""
use Symfony\Component\Validator\Constraints as ConstraintNS;
return new ConstraintNS\CssColor([
'formats' => ConstraintNS\CssColor::HEX_LONG,
'payload' => [
'documentation' => [
'description' => 'description',
'default' => 'default',
'example' => 'example',
'required' => true,
'nullable' => false
]
]
]);
"""
When I transform constraint
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
And constraint doc "getDescription" should return the value "description"
And constraint doc "getDefault" should return the value "default"
And constraint doc "getExample" should return the value "example"
And constraint doc "isNullable" should return false
And constraint doc "isRequired" should return true
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getMinLength" should return null
And constraint doc "getMaxLength" should return null

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Feature: ConstraintToParamsDocTransformer - ExpressionLanguageSyntax constraint

Scenario: Simple ExpressionLanguageSyntax constraint
Given I have the following Constraint:
"""
use Symfony\Component\Validator\Constraints as ConstraintNS;
return new ConstraintNS\ExpressionLanguageSyntax();
"""
When I transform constraint
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getDescription" should return null
And constraint doc "getDefault" should return null
And constraint doc "getExample" should return null
And constraint doc "isNullable" should return true
And constraint doc "isRequired" should return false
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getMinLength" should return null
And constraint doc "getMaxLength" should return null

Scenario: Fully configured ExpressionLanguageSyntax constraint
Given I have the following Constraint:
"""
use Symfony\Component\Validator\Constraints as ConstraintNS;
return new ConstraintNS\ExpressionLanguageSyntax([
'payload' => [
'documentation' => [
'description' => 'description',
'default' => 'default',
'example' => 'example',
'required' => true,
'nullable' => false
]
]
]);
"""
When I transform constraint
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
And constraint doc "getDescription" should return the value "description"
And constraint doc "getDefault" should return the value "default"
And constraint doc "getExample" should return the value "example"
And constraint doc "isNullable" should return false
And constraint doc "isRequired" should return true
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getMinLength" should return null
And constraint doc "getMaxLength" should return null
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Feature: ConstraintToParamsDocTransformer - ExpressionSyntax constraint

Scenario: Simple ExpressionSyntax constraint
Given I have the following Constraint:
"""
use Symfony\Component\Validator\Constraints as ConstraintNS;
return new ConstraintNS\ExpressionSyntax();
"""
When I transform constraint
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getDescription" should return null
And constraint doc "getDefault" should return null
And constraint doc "getExample" should return null
And constraint doc "isNullable" should return true
And constraint doc "isRequired" should return false
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getMinLength" should return null
And constraint doc "getMaxLength" should return null

Scenario: Fully configured ExpressionSyntax constraint
Given I have the following Constraint:
"""
use Symfony\Component\Validator\Constraints as ConstraintNS;
return new ConstraintNS\ExpressionSyntax([
'payload' => [
'documentation' => [
'description' => 'description',
'default' => 'default',
'example' => 'example',
'required' => true,
'nullable' => false
]
]
]);
"""
When I transform constraint
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
And constraint doc "getDescription" should return the value "description"
And constraint doc "getDefault" should return the value "default"
And constraint doc "getExample" should return the value "example"
And constraint doc "isNullable" should return false
And constraint doc "isRequired" should return true
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getMinLength" should return null
And constraint doc "getMaxLength" should return null
52 changes: 52 additions & 0 deletions features/02_string-constraints/hostname-constraint.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Feature: ConstraintToParamsDocTransformer - Hostname constraint

Scenario: Simple Hostname constraint
Given I have the following Constraint:
"""
use Symfony\Component\Validator\Constraints as ConstraintNS;
return new ConstraintNS\Hostname();
"""
When I transform constraint
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
And constraint doc "getFormat" should return the value "hostname"
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getDescription" should return null
And constraint doc "getDefault" should return null
And constraint doc "getExample" should return null
And constraint doc "isNullable" should return true
And constraint doc "isRequired" should return false
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getMinLength" should return null
And constraint doc "getMaxLength" should return null

Scenario: Fully configured Hostname constraint
Given I have the following Constraint:
"""
use Symfony\Component\Validator\Constraints as ConstraintNS;
return new ConstraintNS\Hostname([
'payload' => [
'documentation' => [
'description' => 'description',
'default' => 'default',
'example' => 'example',
'required' => true,
'nullable' => false
]
]
]);
"""
When I transform constraint
Then I should have a constraint doc of class "Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc"
And constraint doc "getFormat" should return the value "hostname"
And constraint doc "getDescription" should return the value "description"
And constraint doc "getDefault" should return the value "default"
And constraint doc "getExample" should return the value "example"
And constraint doc "isNullable" should return false
And constraint doc "isRequired" should return true
## Check others properties
And constraint doc "getName" should return null
And constraint doc "getAllowedValueList" should return an empty array
And constraint doc "getMinLength" should return null
And constraint doc "getMaxLength" should return null

Loading