Skip to content

Commit

Permalink
Merge branch '2.5' of https://github.com/sulu/sulu into 2.6
Browse files Browse the repository at this point in the history
 Conflicts:
	phpstan-baseline.neon
  • Loading branch information
alexander-schranz committed May 9, 2024
2 parents c4106eb + df87d1c commit e78ab14
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 161 deletions.
40 changes: 0 additions & 40 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12285,41 +12285,21 @@ parameters:
count: 1
path: src/Sulu/Bundle/HttpCacheBundle/Tests/Unit/EventSubscriber/InvalidationSubscriberTest.php

-
message: "#^Method Sulu\\\\Bundle\\\\HttpCacheBundle\\\\Tests\\\\Unit\\\\EventSubscriber\\\\InvalidationSubscriberTest\\:\\:testInvalidateDocumentBeforePublishing\\(\\) has parameter \\$request with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/HttpCacheBundle/Tests/Unit/EventSubscriber/InvalidationSubscriberTest.php

-
message: "#^Method Sulu\\\\Bundle\\\\HttpCacheBundle\\\\Tests\\\\Unit\\\\EventSubscriber\\\\InvalidationSubscriberTest\\:\\:testInvalidateDocumentBeforePublishing\\(\\) has parameter \\$scheme with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/HttpCacheBundle/Tests/Unit/EventSubscriber/InvalidationSubscriberTest.php

-
message: "#^Method Sulu\\\\Bundle\\\\HttpCacheBundle\\\\Tests\\\\Unit\\\\EventSubscriber\\\\InvalidationSubscriberTest\\:\\:testInvalidateDocumentBeforeRemoving\\(\\) has parameter \\$request with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/HttpCacheBundle/Tests/Unit/EventSubscriber/InvalidationSubscriberTest.php

-
message: "#^Method Sulu\\\\Bundle\\\\HttpCacheBundle\\\\Tests\\\\Unit\\\\EventSubscriber\\\\InvalidationSubscriberTest\\:\\:testInvalidateDocumentBeforeRemoving\\(\\) has parameter \\$scheme with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/HttpCacheBundle/Tests/Unit/EventSubscriber/InvalidationSubscriberTest.php

-
message: "#^Method Sulu\\\\Bundle\\\\HttpCacheBundle\\\\Tests\\\\Unit\\\\EventSubscriber\\\\InvalidationSubscriberTest\\:\\:testInvalidateDocumentBeforeRemovingLocale\\(\\) has parameter \\$request with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/HttpCacheBundle/Tests/Unit/EventSubscriber/InvalidationSubscriberTest.php

-
message: "#^Method Sulu\\\\Bundle\\\\HttpCacheBundle\\\\Tests\\\\Unit\\\\EventSubscriber\\\\InvalidationSubscriberTest\\:\\:testInvalidateDocumentBeforeRemovingLocale\\(\\) has parameter \\$scheme with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/HttpCacheBundle/Tests/Unit/EventSubscriber/InvalidationSubscriberTest.php

-
message: "#^Method Sulu\\\\Bundle\\\\HttpCacheBundle\\\\Tests\\\\Unit\\\\EventSubscriber\\\\InvalidationSubscriberTest\\:\\:testInvalidateDocumentBeforeUnpublishing\\(\\) has parameter \\$request with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/HttpCacheBundle/Tests/Unit/EventSubscriber/InvalidationSubscriberTest.php

-
message: "#^Method Sulu\\\\Bundle\\\\HttpCacheBundle\\\\Tests\\\\Unit\\\\EventSubscriber\\\\InvalidationSubscriberTest\\:\\:testInvalidateDocumentBeforeUnpublishing\\(\\) has parameter \\$scheme with no type specified\\.$#"
count: 1
Expand Down Expand Up @@ -34870,11 +34850,6 @@ parameters:
count: 1
path: src/Sulu/Component/Contact/Tests/Unit/SmartContent/AccountDataProviderTest.php

-
message: "#^Method Sulu\\\\Component\\\\Contact\\\\Tests\\\\Unit\\\\SmartContent\\\\AccountDataProviderTest\\:\\:createAccount\\(\\) has no return type specified\\.$#"
count: 1
path: src/Sulu/Component/Contact/Tests/Unit/SmartContent/AccountDataProviderTest.php

-
message: "#^Method Sulu\\\\Component\\\\Contact\\\\Tests\\\\Unit\\\\SmartContent\\\\AccountDataProviderTest\\:\\:createAccount\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
Expand Down Expand Up @@ -41815,16 +41790,6 @@ parameters:
count: 1
path: src/Sulu/Component/Content/Tests/Unit/Extension/ExtensionManagerTest.php

-
message: "#^Method Sulu\\\\Component\\\\Content\\\\Tests\\\\Unit\\\\Extension\\\\ExtensionManagerTest\\:\\:getExtension\\(\\) has no return type specified\\.$#"
count: 1
path: src/Sulu/Component/Content/Tests/Unit/Extension/ExtensionManagerTest.php

-
message: "#^Method Sulu\\\\Component\\\\Content\\\\Tests\\\\Unit\\\\Extension\\\\ExtensionManagerTest\\:\\:getExtension\\(\\) has parameter \\$name with no type specified\\.$#"
count: 1
path: src/Sulu/Component/Content/Tests/Unit/Extension/ExtensionManagerTest.php

-
message: "#^Method Sulu\\\\Component\\\\Content\\\\Tests\\\\Unit\\\\Extension\\\\ExtensionManagerTest\\:\\:getProvider\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -46510,11 +46475,6 @@ parameters:
count: 1
path: src/Sulu/Component/Media/Tests/Unit/SmartContent/MediaDataProviderTest.php

-
message: "#^Method Sulu\\\\Component\\\\Media\\\\Tests\\\\Unit\\\\SmartContent\\\\MediaDataProviderTest\\:\\:createMedia\\(\\) has no return type specified\\.$#"
count: 1
path: src/Sulu/Component/Media/Tests/Unit/SmartContent/MediaDataProviderTest.php

-
message: "#^Method Sulu\\\\Component\\\\Media\\\\Tests\\\\Unit\\\\SmartContent\\\\MediaDataProviderTest\\:\\:createMedia\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Sulu\Bundle\AudienceTargetingBundle\Controller\TargetGroupEvaluationController;
use Sulu\Bundle\AudienceTargetingBundle\Entity\TargetGroupInterface;
use Sulu\Bundle\AudienceTargetingBundle\Entity\TargetGroup;
use Sulu\Bundle\AudienceTargetingBundle\Entity\TargetGroupRepositoryInterface;
use Sulu\Bundle\AudienceTargetingBundle\Entity\TargetGroupRuleInterface;
use Sulu\Bundle\AudienceTargetingBundle\TargetGroup\TargetGroupEvaluatorInterface;
use Sulu\Bundle\AudienceTargetingBundle\TargetGroup\TargetGroupStoreInterface;
use Sulu\Bundle\TestBundle\Testing\SetGetPrivatePropertyTrait;
use Symfony\Component\HttpFoundation\Request;

class TargetGroupEvaluationControllerTest extends TestCase
{
use ProphecyTrait;
use SetGetPrivatePropertyTrait;

/**
* @var ObjectProphecy<TargetGroupEvaluatorInterface>
Expand Down Expand Up @@ -82,21 +84,20 @@ public function testTargetGroupAction($header, $currentTargetGroup, $targetGroup

public function provideTargetGroup()
{
$targetGroup1 = $this->prophesize(TargetGroupInterface::class);
$targetGroup1 = new TargetGroup();

$targetGroup2 = $this->prophesize(TargetGroupInterface::class);
$targetGroup2->getId()->willReturn(2);

$targetGroup3 = $this->prophesize(TargetGroupInterface::class);
$targetGroup3->getId()->willReturn(3);
$targetGroup4 = $this->prophesize(TargetGroupInterface::class);
$targetGroup4->getId()->willReturn(4);
$targetGroup2 = new TargetGroup();
self::setPrivateProperty($targetGroup2, 'id', 2);
$targetGroup3 = new TargetGroup();
self::setPrivateProperty($targetGroup3, 'id', 3);
$targetGroup4 = new TargetGroup();
self::setPrivateProperty($targetGroup4, 'id', 4);

return [
['X-Sulu-Target-Group-Hash', null, $targetGroup1->reveal(), null],
['X-Sulu-Target-Group-Hash', null, $targetGroup2->reveal(), 2],
['X-Sulu-Target-Group-Hash', null, $targetGroup1, null],
['X-Sulu-Target-Group-Hash', null, $targetGroup2, 2],
['X-Sulu-Target-Group', null, null, 0],
['X-Sulu-Target-Group', $targetGroup3->reveal(), $targetGroup4->reveal(), 4],
['X-Sulu-Target-Group', $targetGroup3, $targetGroup4, 4],
];
}

Expand Down Expand Up @@ -129,14 +130,14 @@ public function testTargetGroupHitAction($oldTargetGroup, $newTargetGroup, $newT

public function provideTargetGroupHit()
{
$oldTargetGroup1 = $this->prophesize(TargetGroupInterface::class);
$oldTargetGroup1->getId()->willReturn(1);
$newTargetGroup1 = $this->prophesize(TargetGroupInterface::class);
$newTargetGroup1->getId()->willReturn(2);
$oldTargetGroup1 = new TargetGroup();
self::setPrivateProperty($oldTargetGroup1, 'id', 1);
$newTargetGroup1 = new TargetGroup();
self::setPrivateProperty($newTargetGroup1, 'id', 2);

return [
[$oldTargetGroup1->reveal(), $newTargetGroup1->reveal(), 2],
[$oldTargetGroup1->reveal(), null, null],
[$oldTargetGroup1, $newTargetGroup1, 2],
[$oldTargetGroup1, null, null],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Sulu\Bundle\AudienceTargetingBundle\Entity\TargetGroup;
use Sulu\Bundle\AudienceTargetingBundle\Entity\TargetGroupInterface;
use Sulu\Bundle\AudienceTargetingBundle\Entity\TargetGroupRepositoryInterface;
use Sulu\Bundle\AudienceTargetingBundle\Entity\TargetGroupRuleInterface;
use Sulu\Bundle\AudienceTargetingBundle\EventListener\TargetGroupSubscriber;
use Sulu\Bundle\AudienceTargetingBundle\TargetGroup\TargetGroupEvaluatorInterface;
use Sulu\Bundle\AudienceTargetingBundle\TargetGroup\TargetGroupStoreInterface;
use Sulu\Bundle\TestBundle\Testing\SetGetPrivatePropertyTrait;
use Sulu\Component\Content\Compat\Structure\StructureBridge;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand All @@ -35,6 +37,7 @@
class TargetGroupSubscriberTest extends TestCase
{
use ProphecyTrait;
use SetGetPrivatePropertyTrait;

/**
* @var ObjectProphecy<Environment>
Expand Down Expand Up @@ -252,15 +255,15 @@ public function testSetTargetGroupFromEvaluation($evaluatedTargetGroup, $result)

public function provideSetTargetGroupFromEvaluation()
{
$targetGroup1 = $this->prophesize(TargetGroupInterface::class);
$targetGroup1->getId()->willReturn(1);
$targetGroup1 = new TargetGroup();
self::setPrivateProperty($targetGroup1, 'id', 1);

$targetGroup2 = $this->prophesize(TargetGroupInterface::class);
$targetGroup2->getId()->willReturn(3);
$targetGroup2 = new TargetGroup();
self::setPrivateProperty($targetGroup2, 'id', 3);

return [
[$targetGroup1->reveal(), 1],
[$targetGroup2->reveal(), 3],
[$targetGroup1, 1],
[$targetGroup2, 3],
[null, 0],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,22 @@ public function setUp(): void
public function provideRequest()
{
return [
[null, 'http'],
[$this->prophesize(Request::class), 'http'],
[$this->prophesize(Request::class), 'https'],
[false, 'http'],
[true, 'http'],
[true, 'https'],
];
}

/**
* @dataProvider provideRequest
*/
public function testInvalidateDocumentBeforePublishing($request, $scheme): void
public function testInvalidateDocumentBeforePublishing(bool $hasRequest, $scheme): void
{
$documentUuid = '743389e6-2ac5-4673-9835-3e709a27a03d';

if ($request) {
$request = null;
if ($hasRequest) {
$request = $this->prophesize(Request::class);
$request->getScheme()->willReturn($scheme);
$this->requestStack->getCurrentRequest()->willReturn($request->reveal());
}
Expand Down Expand Up @@ -287,12 +289,15 @@ public function testInvalidateDocumentBeforePublishingWrongDocument(): void
/**
* @dataProvider provideRequest
*/
public function testInvalidateDocumentBeforeUnpublishing($request, $scheme): void
public function testInvalidateDocumentBeforeUnpublishing(bool $hasRequest, $scheme): void
{
$documentUuid = '743c89e6-2ac5-7777-9835-3e709a27a03d';

if ($request) {
$request = null;
if ($hasRequest) {
$request = $this->prophesize(Request::class);
$request->getScheme()->willReturn($scheme);

$this->requestStack->getCurrentRequest()->willReturn($request->reveal());
}

Expand Down Expand Up @@ -400,11 +405,13 @@ public function testInvalidateDocumentBeforeUnpublishingWrongDocument(): void
/**
* @dataProvider provideRequest
*/
public function testInvalidateDocumentBeforeRemoving($request, $scheme): void
public function testInvalidateDocumentBeforeRemoving(bool $hasRequest, $scheme): void
{
$documentUuid = '743c89e6-2ac5-7777-1234-3e709a27a0bb';

if ($request) {
$request = null;
if ($hasRequest) {
$request = $this->prophesize(Request::class);
$request->getScheme()->willReturn($scheme);
$this->requestStack->getCurrentRequest()->willReturn($request->reveal());
}
Expand Down Expand Up @@ -493,11 +500,13 @@ public function testInvalidateDocumentBeforeRemoving($request, $scheme): void
/**
* @dataProvider provideRequest
*/
public function testInvalidateDocumentBeforeRemovingLocale($request, $scheme): void
public function testInvalidateDocumentBeforeRemovingLocale(bool $hasRequest, $scheme): void
{
$documentUuid = '743c89e6-2ac5-7777-1234-3e709a27a0bb';

if ($request) {
$request = null;
if ($hasRequest) {
$request = $this->prophesize(Request::class);
$request->getScheme()->willReturn($scheme);
$this->requestStack->getCurrentRequest()->willReturn($request->reveal());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use Sulu\Bundle\MediaBundle\Media\TypeManager\TypeManagerInterface;
use Sulu\Bundle\SecurityBundle\Entity\User;
use Sulu\Bundle\TagBundle\Tag\TagManagerInterface;
use Sulu\Bundle\TestBundle\Testing\SetGetPrivatePropertyTrait;
use Sulu\Component\PHPCR\PathCleanupInterface;
use Sulu\Component\Security\Authentication\UserInterface as SuluUserInterface;
use Sulu\Component\Security\Authentication\UserRepositoryInterface;
Expand All @@ -55,6 +56,7 @@
class MediaManagerTest extends TestCase
{
use ProphecyTrait;
use SetGetPrivatePropertyTrait;

/**
* @var MediaManager
Expand Down Expand Up @@ -524,11 +526,11 @@ public function provideGetByIds()
$media2 = $this->createMedia(2);
$media3 = $this->createMedia(3);

$user = $this->prophesize(SuluUserInterface::class);
$user = new User();

return [
[[1, 2, 3], null, null, [$media1, $media2, $media3], [$media1, $media2, $media3]],
[[2, 1, 3], $user->reveal(), 64, [$media1, $media2, $media3], [$media2, $media1, $media3]],
[[2, 1, 3], $user, 64, [$media1, $media2, $media3], [$media2, $media1, $media3]],
[[4, 1, 2], null, null, [$media1, $media2], [$media1, $media2]],
];
}
Expand All @@ -552,11 +554,8 @@ public function provideSpecialCharacterUrl()

protected function createMedia($id)
{
$mediaIdReflection = new \ReflectionProperty(Media::class, 'id');
$mediaIdReflection->setAccessible(true);

$media = new Media();
$mediaIdReflection->setValue($media, $id);
self::setPrivateProperty($media, 'id', $id);

$file = new File();
$fileVersion = new FileVersion();
Expand Down

0 comments on commit e78ab14

Please sign in to comment.