From 7f816e709d5b5db0a22f2f93280d301a1f69cbd2 Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Sun, 17 Jul 2022 23:26:10 +0200 Subject: [PATCH 1/2] Fix failing tests This tests started to fail with the 1.14 version of the driver --- docs/en/cookbook/validation-of-documents.rst | 4 ++-- docs/en/reference/annotations-reference.rst | 2 +- .../Doctrine/ODM/MongoDB/Tests/Functional/ValidationTest.php | 2 +- .../Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php | 2 +- .../ODM/MongoDB/Tests/Mapping/Driver/XmlDriverTest.php | 2 +- .../xml/TestDocuments.SchemaValidatedDocument.dcm.xml | 2 +- tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php | 4 ++-- tests/Documents/SchemaValidated.php | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/en/cookbook/validation-of-documents.rst b/docs/en/cookbook/validation-of-documents.rst index 0d43ed8060..cc25ed603a 100644 --- a/docs/en/cookbook/validation-of-documents.rst +++ b/docs/en/cookbook/validation-of-documents.rst @@ -197,7 +197,7 @@ the ``odm:schema:create`` or ``odm:schema:update`` command. }, "$or": [ { "phone": { "$type": "string" } }, - { "email": { "$regex": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } } }, + { "email": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } }, { "status": { "$in": [ "Unknown", "Incomplete" ] } } ] } @@ -241,7 +241,7 @@ the ``odm:schema:create`` or ``odm:schema:update`` command. }, "$or": [ { "phone": { "$type": "string" } }, - { "email": { "$regex": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } } }, + { "email": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } }, { "status": { "$in": [ "Unknown", "Incomplete" ] } } ] } diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst index 72b8a3834d..c30676fabb 100644 --- a/docs/en/reference/annotations-reference.rst +++ b/docs/en/reference/annotations-reference.rst @@ -1186,7 +1186,7 @@ for the related collection. }, "$or": [ { "phone": { "$type": "string" } }, - { "email": { "$regex": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } } }, + { "email": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } }, { "status": { "$in": [ "Unknown", "Incomplete" ] } } ] } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ValidationTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ValidationTest.php index a8c64a4e18..1d575c687e 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ValidationTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ValidationTest.php @@ -36,7 +36,7 @@ public function testCreateUpdateValidatedDocument(): void }, "$or": [ { "phone": { "$type": "string" } }, - { "email": { "$regex": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } } }, + { "email": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } }, { "status": { "$in": [ "Unknown", "Incomplete" ] } } ] } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php index 9a5ad1b933..d664a9c566 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php @@ -77,7 +77,7 @@ public function testClassMetadataInstanceSerialization(): void $cm->setLockField('lock'); $cm->setVersioned(true); $cm->setVersionField('version'); - $validatorJson = '{ "$and": [ { "email": { "$regex": { "$regularExpression" : { "pattern": "@mongodb\\\\.com$", "options": "" } } } } ] }'; + $validatorJson = '{ "$and": [ { "email": { "$regularExpression" : { "pattern": "@mongodb\\\\.com$", "options": "" } } } ] }'; $cm->setValidator(toPHP(fromJSON($validatorJson))); $cm->setValidationAction(ClassMetadata::SCHEMA_VALIDATION_ACTION_WARN); $cm->setValidationLevel(ClassMetadata::SCHEMA_VALIDATION_LEVEL_OFF); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/XmlDriverTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/XmlDriverTest.php index 88cfc0a846..457027520d 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/XmlDriverTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/XmlDriverTest.php @@ -132,7 +132,7 @@ public function testValidationMapping(): void }, "$or": [ { "phone": { "$type": "string" } }, - { "email": { "$regex": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } } }, + { "email": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } }, { "status": { "$in": [ "Unknown", "Incomplete" ] } } ] } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/fixtures/xml/TestDocuments.SchemaValidatedDocument.dcm.xml b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/fixtures/xml/TestDocuments.SchemaValidatedDocument.dcm.xml index a29e53043a..ba39378c01 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/fixtures/xml/TestDocuments.SchemaValidatedDocument.dcm.xml +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/fixtures/xml/TestDocuments.SchemaValidatedDocument.dcm.xml @@ -18,7 +18,7 @@ }, "$or": [ { "phone": { "$type": "string" } }, - { "email": { "$regex": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } } }, + { "email": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } }, { "status": { "$in": [ "Unknown", "Incomplete" ] } } ] } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php b/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php index ab3141fe1a..55bdf72d31 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php @@ -430,7 +430,7 @@ public function testUpdateDocumentValidator(array $expectedWriteOptions, ?int $m }, "$or": [ { "phone": { "$type": "string" } }, - { "email": { "$regex": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } } }, + { "email": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } }, { "status": { "$in": [ "Unknown", "Incomplete" ] } } ] } @@ -543,7 +543,7 @@ public function testCreateDocumentCollectionWithValidator(array $expectedWriteOp }, "$or": [ { "phone": { "$type": "string" } }, - { "email": { "$regex": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } } }, + { "email": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } }, { "status": { "$in": [ "Unknown", "Incomplete" ] } } ] } diff --git a/tests/Documents/SchemaValidated.php b/tests/Documents/SchemaValidated.php index 16ab4afd03..c796d14a87 100644 --- a/tests/Documents/SchemaValidated.php +++ b/tests/Documents/SchemaValidated.php @@ -30,7 +30,7 @@ class SchemaValidated }, "$or": [ { "phone": { "$type": "string" } }, - { "email": { "$regex": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } } }, + { "email": { "$regularExpression" : { "pattern": "@mongodb\\.com$", "options": "" } } }, { "status": { "$in": [ "Unknown", "Incomplete" ] } } ] } From 6c7d3b7feb6c9490abd4942eed8128e1314aca4b Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Wed, 20 Jul 2022 08:15:48 +0200 Subject: [PATCH 2/2] Remove test We were testing the annotation instantiation which is done by doctrine/annotations package. --- .../Mapping/Annotations/ValidationTest.php | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 tests/Doctrine/ODM/MongoDB/Tests/Mapping/Annotations/ValidationTest.php diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Annotations/ValidationTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Annotations/ValidationTest.php deleted file mode 100644 index 95db763308..0000000000 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Annotations/ValidationTest.php +++ /dev/null @@ -1,23 +0,0 @@ -expectException(TypeError::class); - $this->dm->getClassMetadata(WrongTypeForValidationValidator::class); - } -} - -/** @ODM\Validation(validator={"wrong"}) */ -class WrongTypeForValidationValidator -{ -}