Skip to content
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

[Tests] Fixed FieldTest, RestContentTest, and RestUser(Group)Test #86

Merged
merged 9 commits into from
Apr 17, 2024

Conversation

alongosz
Copy link
Member

@alongosz alongosz commented Mar 27, 2024

🎫 Issue n/a

Description:

Fixed https://github.com/ibexa/rest/actions/runs/8439148113/job/23113060154.

1. Fixed incorrect section ID data type.

We've recently enforced strict type on sectionId to catch some bugs and here we've caught one.

1) Ibexa\Tests\Rest\Server\Output\ValueObjectVisitor\RestContentTest::testVisitWithoutEmbeddedVersion
TypeError: Cannot assign string to property Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo::$sectionId of type int

/home/andrew/packages/ibexa/rest/vendor/ibexa/core/src/contracts/Repository/Values/ValueObject.php:33
/home/andrew/packages/ibexa/rest/tests/lib/Server/Output/ValueObjectVisitor/RestContentTest.php:113
/home/andrew/packages/ibexa/rest/tests/lib/Server/Output/ValueObjectVisitor/RestContentTest.php:43

2) Ibexa\Tests\Rest\Server\Output\ValueObjectVisitor\RestContentTest::testVisitWithEmbeddedVersion
TypeError: Cannot assign string to property Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo::$sectionId of type int

/home/andrew/packages/ibexa/rest/vendor/ibexa/core/src/contracts/Repository/Values/ValueObject.php:33
/home/andrew/packages/ibexa/rest/tests/lib/Server/Output/ValueObjectVisitor/RestContentTest.php:113
/home/andrew/packages/ibexa/rest/tests/lib/Server/Output/ValueObjectVisitor/RestContentTest.php:411

3) Ibexa\Tests\Rest\Server\Output\ValueObjectVisitor\RestUserGroupTest::testVisitWithoutEmbeddedVersion
TypeError: Cannot assign string to property Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo::$sectionId of type int

/home/andrew/packages/ibexa/rest/vendor/ibexa/core/src/contracts/Repository/Values/ValueObject.php:33
/home/andrew/packages/ibexa/rest/tests/lib/Server/Output/ValueObjectVisitor/RestUserGroupTest.php:111
/home/andrew/packages/ibexa/rest/tests/lib/Server/Output/ValueObjectVisitor/RestUserGroupTest.php:28

4) Ibexa\Tests\Rest\Server\Output\ValueObjectVisitor\RestUserTest::testVisitWithoutEmbeddedVersion
TypeError: Cannot assign string to property Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo::$sectionId of type int

/home/andrew/packages/ibexa/rest/vendor/ibexa/core/src/contracts/Repository/Values/ValueObject.php:33
/home/andrew/packages/ibexa/rest/tests/lib/Server/Output/ValueObjectVisitor/RestUserTest.php:106
/home/andrew/packages/ibexa/rest/tests/lib/Server/Output/ValueObjectVisitor/RestUserTest.php:28
2. Fixed failing Field Value Object Visitor test

Ibexa\Tests\Rest\Server\Output\ValueObjectVisitor\FieldTest test was actually silently failing with a warning due to incorrect mocking of serializeContentFieldValue. It performs operations internally and applies results to an instance of REST XML Generator instead of returning a value. It wasn't visible because failOnWarning was not configured (fixed as well).
Instead we need to mock a bit behavior of field type services to properly mock hash that the generator will use.

There was 1 warning:

1) Ibexa\Tests\Rest\Server\Output\ValueObjectVisitor\FieldTest::testVisit
Method serializeContentFieldValue may not return value of type string, its return declaration is ": void"
  1. Fixed other incorrect int ID data types (the same way as the section ID): owner, content, main location, content type
  2. Refactored all related test cases to remove code duplication

@alongosz alongosz force-pushed the fix-incorrect-section-id branch from 8b82650 to f317269 Compare March 28, 2024 09:55
@alongosz alongosz marked this pull request as ready for review March 28, 2024 10:47
@alongosz alongosz changed the title [Tests] Fixed incorrect section ID data type [Tests] Fixed FieldTest, RestContentTest, and RestUser(Group)Test Mar 28, 2024
@alongosz alongosz force-pushed the fix-incorrect-section-id branch from b67f37c to 953eb28 Compare March 28, 2024 14:02
@alongosz alongosz force-pushed the fix-incorrect-section-id branch from 953eb28 to b69f6a9 Compare March 28, 2024 15:06
Copy link

Quality Gate Passed Quality Gate passed

Issues
12 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@alongosz alongosz requested review from Steveb-p, ciastektk, tischsoic, ViniTou and a team March 28, 2024 15:12
@alongosz alongosz requested a review from a team March 29, 2024 16:53
@Steveb-p Steveb-p merged commit 275fdd5 into 4.6 Apr 17, 2024
13 checks passed
@Steveb-p Steveb-p deleted the fix-incorrect-section-id branch April 17, 2024 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants