From dc98e7a6b9e2fd7134e0ca1fb1fb1b7d6b5ff07e Mon Sep 17 00:00:00 2001 From: Sagar Gurung <46086950+SagarGi@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:54:40 +0545 Subject: [PATCH] [tests-only][full-ci]Refactor check for no of items in json schema (#8632) * Refactor check for no of items in json schema * test(api): fix json schema --------- Co-authored-by: Saw-jan --- .../apiSharingNg/sharedWithMe.feature | 136 +++++++++--------- .../sharedWithMeSyncDisabled.feature | 136 +++++++++--------- .../features/bootstrap/FeatureContext.php | 10 +- 3 files changed, 141 insertions(+), 141 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/sharedWithMe.feature b/tests/acceptance/features/apiSharingNg/sharedWithMe.feature index ef405048d..895d3c263 100755 --- a/tests/acceptance/features/apiSharingNg/sharedWithMe.feature +++ b/tests/acceptance/features/apiSharingNg/sharedWithMe.feature @@ -3077,23 +3077,23 @@ Feature: an user gets the resources shared to them } } } - } - }, - "invitation": { - "type": "object", - "required": ["invitedBy"], - "properties": { - "invitedBy": { - "type": "object", - "required": ["user"], - "properties": { - "user": { - "type": "object", - "required": ["displayName", "id"], - "properties": { - "displayName": { - "type": "string", - "enum": ["Carol King"] + }, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["displayName", "id"], + "properties": { + "displayName": { + "type": "string", + "enum": ["Carol King"] + } } } } @@ -3206,23 +3206,23 @@ Feature: an user gets the resources shared to them } } } - } - }, - "invitation": { - "type": "object", - "required": ["invitedBy"], - "properties": { - "invitedBy": { - "type": "object", - "required": ["user"], - "properties": { - "user": { - "type": "object", - "required": ["displayName", "id"], - "properties": { - "displayName": { - "type": "string", - "enum": ["Alice Hansen"] + }, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["displayName", "id"], + "properties": { + "displayName": { + "type": "string", + "enum": ["Alice Hansen"] + } } } } @@ -3374,23 +3374,23 @@ Feature: an user gets the resources shared to them } } } - } - }, - "invitation": { - "type": "object", - "required": ["invitedBy"], - "properties": { - "invitedBy": { - "type": "object", - "required": ["user"], - "properties": { - "user": { - "type": "object", - "required": ["displayName", "id"], - "properties": { - "displayName": { - "type": "string", - "enum": ["Carol King"] + }, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["displayName", "id"], + "properties": { + "displayName": { + "type": "string", + "enum": ["Carol King"] + } } } } @@ -3503,23 +3503,23 @@ Feature: an user gets the resources shared to them } } } - } - }, - "invitation": { - "type": "object", - "required": ["invitedBy"], - "properties": { - "invitedBy": { - "type": "object", - "required": ["user"], - "properties": { - "user": { - "type": "object", - "required": ["displayName", "id"], - "properties": { - "displayName": { - "type": "string", - "enum": ["Alice Hansen"] + }, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["displayName", "id"], + "properties": { + "displayName": { + "type": "string", + "enum": ["Alice Hansen"] + } } } } diff --git a/tests/acceptance/features/apiSharingNg/sharedWithMeSyncDisabled.feature b/tests/acceptance/features/apiSharingNg/sharedWithMeSyncDisabled.feature index ffe55b748..97702093f 100644 --- a/tests/acceptance/features/apiSharingNg/sharedWithMeSyncDisabled.feature +++ b/tests/acceptance/features/apiSharingNg/sharedWithMeSyncDisabled.feature @@ -2352,23 +2352,23 @@ Feature: listing sharedWithMe when auto-sync is disabled } } } - } - }, - "invitation": { - "type": "object", - "required": ["invitedBy"], - "properties": { - "invitedBy": { - "type": "object", - "required": ["user"], - "properties": { - "user": { - "type": "object", - "required": ["displayName", "id"], - "properties": { - "displayName": { - "type": "string", - "enum": ["Carol King"] + }, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["displayName", "id"], + "properties": { + "displayName": { + "type": "string", + "enum": ["Carol King"] + } } } } @@ -2481,23 +2481,23 @@ Feature: listing sharedWithMe when auto-sync is disabled } } } - } - }, - "invitation": { - "type": "object", - "required": ["invitedBy"], - "properties": { - "invitedBy": { - "type": "object", - "required": ["user"], - "properties": { - "user": { - "type": "object", - "required": ["displayName", "id"], - "properties": { - "displayName": { - "type": "string", - "enum": ["Alice Hansen"] + }, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["displayName", "id"], + "properties": { + "displayName": { + "type": "string", + "enum": ["Alice Hansen"] + } } } } @@ -2649,23 +2649,23 @@ Feature: listing sharedWithMe when auto-sync is disabled } } } - } - }, - "invitation": { - "type": "object", - "required": ["invitedBy"], - "properties": { - "invitedBy": { - "type": "object", - "required": ["user"], - "properties": { - "user": { - "type": "object", - "required": ["displayName", "id"], - "properties": { - "displayName": { - "type": "string", - "enum": ["Carol King"] + }, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["displayName", "id"], + "properties": { + "displayName": { + "type": "string", + "enum": ["Carol King"] + } } } } @@ -2778,23 +2778,23 @@ Feature: listing sharedWithMe when auto-sync is disabled } } } - } - }, - "invitation": { - "type": "object", - "required": ["invitedBy"], - "properties": { - "invitedBy": { - "type": "object", - "required": ["user"], - "properties": { - "user": { - "type": "object", - "required": ["displayName", "id"], - "properties": { - "displayName": { - "type": "string", - "enum": ["Alice Hansen"] + }, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["displayName", "id"], + "properties": { + "displayName": { + "type": "string", + "enum": ["Alice Hansen"] + } } } } diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index 14112957a..57dfaa7c0 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -1252,15 +1252,16 @@ class FeatureContext extends BehatVariablesContext { $propNames = $schemaObj->getPropertyNames(); $props = $schemaObj->getProperties(); foreach ($propNames as $propName) { - switch ($props->type) { + $schema = $props->$propName; + switch ($schema->type) { case "array": - $this->validateSchemaArray($props->$propName); + $this->validateSchemaArray($schema); break; default: break; } // traverse for nested properties - $this->validateSchemaObject($props->$propName); + $this->validateSchemaObject($schema); } } @@ -1318,12 +1319,11 @@ class FeatureContext extends BehatVariablesContext { Assert::assertNotNull($element->oneOf, "'oneOf' is required to assert more than one elements"); } Assert::fail("'$validator' should be an object not an array"); - break; } Assert::assertFalse($value->allOf || $value->anyOf, "'allOf' and 'anyOf' are not allowed in array"); Assert::assertNotNull($value->oneOf, "'oneOf' is required to assert more than one elements"); Assert::assertTrue(\is_array($value->oneOf), "'oneOf' should be an array"); - Assert::assertEquals($schemaObj->maxItems, \count($value->oneOf), "There are more 'oneOf' elements than expected by 'maxItems'"); + Assert::assertEquals($schemaObj->maxItems, \count($value->oneOf), "Expected " . $schemaObj->maxItems . " 'oneOf' items but got " . \count($value->oneOf)); } Assert::assertTrue(\is_object($value), "'$validator' should be an object when expecting 1 element"); break;