Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Oct 28, 2024
1 parent ad3f256 commit 6af61be
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 56 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline-7.4.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$input of function array_slice expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 1
path: src/lib/Server/Controller/Content.php

-
message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|null given\\.$#"
count: 4
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline-8.0.neon
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ parameters:
count: 1
path: src/lib/Input/Handler/Xml.php

-
message: "#^Parameter \\#1 \\$array of function array_slice expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 1
path: src/lib/Server/Controller/Content.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\ContentType\\> given\\.$#"
count: 1
Expand Down
40 changes: 0 additions & 40 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1015,16 +1015,6 @@ parameters:
count: 1
path: src/lib/Server/Controller/Content.php

-
message: "#^Parameter \\#3 \\$relations of class Ibexa\\\\Rest\\\\Server\\\\Values\\\\Version constructor expects array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 4
path: src/lib/Server/Controller/Content.php

-
message: "#^Parameter \\#5 \\$relations of class Ibexa\\\\Rest\\\\Server\\\\Values\\\\RestContent constructor expects array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>\\|null, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>\\|null given\\.$#"
count: 2
path: src/lib/Server/Controller/Content.php

-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Controller\\\\ContentType\\:\\:addContentTypeDraftFieldDefinition\\(\\) has parameter \\$contentTypeId with no type specified\\.$#"
count: 1
Expand Down Expand Up @@ -1660,16 +1650,6 @@ parameters:
count: 1
path: src/lib/Server/Controller/User.php

-
message: "#^Parameter \\#5 \\$relations of class Ibexa\\\\Rest\\\\Server\\\\Values\\\\RestUser constructor expects array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 5
path: src/lib/Server/Controller/User.php

-
message: "#^Parameter \\#5 \\$relations of class Ibexa\\\\Rest\\\\Server\\\\Values\\\\RestUserGroup constructor expects array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 10
path: src/lib/Server/Controller/User.php

-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Input\\\\Parser\\\\Aggregation\\\\AbstractRangeAggregationParser\\:\\:dispatchRanges\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -2760,11 +2740,6 @@ parameters:
count: 1
path: src/lib/Server/Output/ValueObjectVisitor/Location.php

-
message: "#^Parameter \\#5 \\$relations of class Ibexa\\\\Rest\\\\Server\\\\Values\\\\RestContent constructor expects array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>\\|null, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 1
path: src/lib/Server/Output/ValueObjectVisitor/Location.php

-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Output\\\\ValueObjectVisitor\\\\LocationList\\:\\:visit\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -2920,11 +2895,6 @@ parameters:
count: 1
path: src/lib/Server/Output/ValueObjectVisitor/RestExecutedView.php

-
message: "#^Parameter \\#5 \\$relations of class Ibexa\\\\Rest\\\\Server\\\\Values\\\\RestContent constructor expects array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>\\|null, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 1
path: src/lib/Server/Output/ValueObjectVisitor/RestExecutedView.php

-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Output\\\\ValueObjectVisitor\\\\RestFieldDefinition\\:\\:visit\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -3120,21 +3090,11 @@ parameters:
count: 1
path: src/lib/Server/Output/ValueObjectVisitor/User.php

-
message: "#^Parameter \\#5 \\$relations of class Ibexa\\\\Rest\\\\Server\\\\Values\\\\RestUser constructor expects array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 1
path: src/lib/Server/Output/ValueObjectVisitor/User.php

-
message: "#^Parameter \\#4 \\$mainLocation of class Ibexa\\\\Rest\\\\Server\\\\Values\\\\RestUserGroup constructor expects Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Location, Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Location\\|null given\\.$#"
count: 1
path: src/lib/Server/Output/ValueObjectVisitor/UserGroup.php

-
message: "#^Parameter \\#5 \\$relations of class Ibexa\\\\Rest\\\\Server\\\\Values\\\\RestUserGroup constructor expects array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 1
path: src/lib/Server/Output/ValueObjectVisitor/UserGroup.php

-
message: "#^Method Ibexa\\\\Rest\\\\Server\\\\Output\\\\ValueObjectVisitor\\\\UserGroupList\\:\\:visit\\(\\) has no return type specified\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/

namespace Ibexa\Contracts\Rest\Output\Exceptions;

use Ibexa\Contracts\Rest\Output\Generator;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Server/Controller/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
class Content extends RestController
{
public function __construct(private readonly RelationListHelper $relationListHelper, private readonly RelationListHelper $relationListHelper)
public function __construct(private readonly RelationListHelper $relationListHelper)
{
}

Expand Down
11 changes: 8 additions & 3 deletions tests/lib/Server/Output/ValueObjectVisitor/LocationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
use Ibexa\Contracts\Core\Repository\LocationService;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\Location as ApiLocation;
use Ibexa\Contracts\Core\Repository\Values\Content\RelationList;
use Ibexa\Core\Base\Exceptions\UnauthorizedException;
use Ibexa\Core\Helper\RelationListHelper;
use Ibexa\Core\Repository\Values\Content\Content;
use Ibexa\Core\Repository\Values\Content\Location;
use Ibexa\Core\Repository\Values\Content\VersionInfo;
Expand Down Expand Up @@ -77,9 +79,9 @@ public function testVisitLocationAttributesResolvesMainLocation(
$this->mockLoadLocation($location);

$this->contentServiceMock->expects(self::once())
->method('loadRelations')
->method('loadRelationList')
->with($versionInfo)
->willReturn([]);
->willReturn(new RelationList([]));

$visitor->visit(
$this->getVisitorMock(),
Expand Down Expand Up @@ -139,6 +141,9 @@ public function getDataForTestVisitLocationAttributesResolvesMainLocation(): ite

protected function internalGetVisitor(): ValueObjectVisitor\Location
{
return new ValueObjectVisitor\Location($this->locationServiceMock, $this->contentServiceMock);
return new ValueObjectVisitor\Location(
$this->locationServiceMock,
new RelationListHelper($this->contentServiceMock)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
use Ibexa\Contracts\Core\Repository\ContentTypeService;
use Ibexa\Contracts\Core\Repository\LocationService;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\RelationList;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;
use Ibexa\Core\Helper\RelationListHelper;
use Ibexa\Core\Repository\Values\Content;
use Ibexa\Core\Repository\Values\Content as ApiValues;
use Ibexa\Core\Repository\Values\ContentType\ContentType;
Expand Down Expand Up @@ -115,7 +117,7 @@ protected function internalGetVisitor()
{
return new ValueObjectVisitor\RestExecutedView(
$this->getLocationServiceMock(),
$this->getContentServiceMock(),
new RelationListHelper($this->getContentServiceMock())
);
}

Expand All @@ -133,7 +135,7 @@ public function getLocationServiceMock()
public function getContentServiceMock()
{
$contentService = $this->createMock(ContentService::class);
$contentService->method('loadRelations')->willReturn([]);
$contentService->method('loadRelationList')->willReturn(new RelationList([]));

return $contentService;
}
Expand Down

0 comments on commit 6af61be

Please sign in to comment.