|
| 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 |
0 commit comments