Skip to content

[Validator] Fix tests #32372

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

Merged
merged 1 commit into from
Jul 4, 2019
Merged

[Validator] Fix tests #32372

merged 1 commit into from
Jul 4, 2019

Conversation

ogizanagi
Copy link
Contributor

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets relates to #32265
License MIT
Doc PR N/A

Fixes the following tests currently failing on master, as well as a bug where a null code was printed:

1) Symfony\Component\Validator\Tests\ConstraintViolationListTest::testToString
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 'Root:\n
-    Error 1\n
+    Error 1 (code )\n
 Root.foo.bar:\n
-    Error 2\n
+    Error 2 (code )\n
 Root[baz]:\n
-    Error 3\n
+    Error 3 (code )\n
 foo.bar:\n
-    Error 4\n
+    Error 4 (code )\n
 [baz]:\n
-    Error 5\n
+    Error 5 (code )\n

2) Symfony\Component\Validator\Tests\ConstraintViolationTest::testToStringHandlesArrays
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Root.property.path:
-    Array'
+    Array (code )'

3) Symfony\Component\Validator\Tests\ConstraintViolationTest::testToStringHandlesArrayRoots
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Array.some_value:
-    42 cannot be used here'
+    42 cannot be used here (code )'

4) Symfony\Component\Validator\Tests\ConstraintViolationTest::testToStringOmitsEmptyCodes
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Array.some_value:
-    42 cannot be used here'
+    42 cannot be used here (code )'

5) Symfony\Component\Validator\Tests\ConstraintViolationTest::testNonStringCode
Failed asserting that '42' is identical to 42.

6) Symfony\Component\Validator\Tests\Violation\ConstraintViolationBuilderTest::testNonStringCode
Failed asserting that '42' is identical to 42.

@nicolas-grekas
Copy link
Member

Thank you @ogizanagi.

@nicolas-grekas nicolas-grekas merged commit 22c58f5 into symfony:master Jul 4, 2019
nicolas-grekas added a commit that referenced this pull request Jul 4, 2019
This PR was merged into the 5.0-dev branch.

Discussion
----------

[Validator] Fix tests

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | relates to #32265   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

Fixes the following tests currently failing on master, as well as a bug where a null code was printed:

```diff
1) Symfony\Component\Validator\Tests\ConstraintViolationListTest::testToString
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 'Root:\n
-    Error 1\n
+    Error 1 (code )\n
 Root.foo.bar:\n
-    Error 2\n
+    Error 2 (code )\n
 Root[baz]:\n
-    Error 3\n
+    Error 3 (code )\n
 foo.bar:\n
-    Error 4\n
+    Error 4 (code )\n
 [baz]:\n
-    Error 5\n
+    Error 5 (code )\n

2) Symfony\Component\Validator\Tests\ConstraintViolationTest::testToStringHandlesArrays
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Root.property.path:
-    Array'
+    Array (code )'

3) Symfony\Component\Validator\Tests\ConstraintViolationTest::testToStringHandlesArrayRoots
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Array.some_value:
-    42 cannot be used here'
+    42 cannot be used here (code )'

4) Symfony\Component\Validator\Tests\ConstraintViolationTest::testToStringOmitsEmptyCodes
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Array.some_value:
-    42 cannot be used here'
+    42 cannot be used here (code )'

5) Symfony\Component\Validator\Tests\ConstraintViolationTest::testNonStringCode
Failed asserting that '42' is identical to 42.

6) Symfony\Component\Validator\Tests\Violation\ConstraintViolationBuilderTest::testNonStringCode
Failed asserting that '42' is identical to 42.
```

Commits
-------

22c58f5 [Validator] Fix tests
@ogizanagi ogizanagi deleted the fix/validator/tests branch July 4, 2019 15:43
fabpot added a commit that referenced this pull request Jul 5, 2019
…o false & make it optional (ogizanagi)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[Validator] Change Length::$allowEmptyString default to false & make it optional

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | yes     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | should pass after #32372    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #31528   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | ~TODO: change default value and mention it's optional~ Done. Thx @javiereguiluz

Commits
-------

26b804e [Validator] Change Length::$allowEmptyString default to false & make it optional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants