Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove reference to LiipThemeBundle and dispatch event instead (#7004)
- Loading branch information
Showing
5 changed files
with
147 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
src/Sulu/Bundle/PageBundle/Tests/Unit/Command/ValidateWebspacesCommandTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\PageBundle\Tests\Unit\Command; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\PhpUnit\ProphecyTrait; | ||
use Prophecy\Prophecy\ObjectProphecy; | ||
use Sulu\Bundle\PageBundle\Command\ValidateWebspacesCommand; | ||
use Sulu\Bundle\PreviewBundle\Preview\Events; | ||
use Sulu\Bundle\PreviewBundle\Preview\Events\PreRenderEvent; | ||
use Sulu\Component\Content\Compat\StructureManagerInterface; | ||
use Sulu\Component\Content\Metadata\Factory\StructureMetadataFactory; | ||
use Sulu\Component\Content\Metadata\Factory\StructureMetadataFactoryInterface; | ||
use Sulu\Component\Localization\Localization; | ||
use Sulu\Component\Webspace\Analyzer\Attributes\RequestAttributes; | ||
use Sulu\Component\Webspace\Manager\WebspaceCollection; | ||
use Sulu\Component\Webspace\Manager\WebspaceManagerInterface; | ||
use Sulu\Component\Webspace\StructureProvider\WebspaceStructureProvider; | ||
use Sulu\Component\Webspace\Webspace; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use Twig\Environment; | ||
|
||
class ValidateWebspacesCommandTest extends TestCase | ||
{ | ||
use ProphecyTrait; | ||
|
||
/** | ||
* @var ObjectProphecy<Environment> | ||
*/ | ||
private $twig; | ||
|
||
/** | ||
* @var ObjectProphecy<StructureMetadataFactory> | ||
*/ | ||
private $structureMetadataFactory; | ||
|
||
/** | ||
* @var ObjectProphecy<StructureManagerInterface> | ||
*/ | ||
private $structureManager; | ||
|
||
/** | ||
* @var ObjectProphecy<WebspaceStructureProvider> | ||
*/ | ||
private $structureProvider; | ||
|
||
/** | ||
* @var ObjectProphecy<WebspaceManagerInterface> | ||
*/ | ||
private $webspaceManager; | ||
|
||
/** | ||
* @var ObjectProphecy<EventDispatcherInterface> | ||
*/ | ||
private $eventDispatcher; | ||
|
||
/** | ||
* @var ValidateWebspacesCommand | ||
*/ | ||
private $validateWebspacesCommand; | ||
|
||
/** | ||
* @var ObjectProphecy<InputInterface> | ||
*/ | ||
private $input; | ||
|
||
/** | ||
* @var ObjectProphecy<OutputInterface> | ||
*/ | ||
private $output; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->twig = $this->prophesize(Environment::class); | ||
$this->structureMetadataFactory = $this->prophesize(StructureMetadataFactoryInterface::class); | ||
$this->structureManager = $this->prophesize(StructureManagerInterface::class); | ||
$this->structureProvider = $this->prophesize(WebspaceStructureProvider::class); | ||
$this->webspaceManager = $this->prophesize(WebspaceManagerInterface::class); | ||
$this->eventDispatcher = $this->prophesize(EventDispatcherInterface::class); | ||
|
||
$this->validateWebspacesCommand = new ValidateWebspacesCommand( | ||
$this->twig->reveal(), | ||
$this->structureMetadataFactory->reveal(), | ||
null, | ||
$this->structureManager->reveal(), | ||
$this->structureProvider->reveal(), | ||
$this->webspaceManager->reveal(), | ||
$this->eventDispatcher->reveal() | ||
); | ||
|
||
$this->input = $this->prophesize(InputInterface::class); | ||
$this->output = $this->prophesize(OutputInterface::class); | ||
} | ||
|
||
public function testExecute(): void | ||
{ | ||
$webspace = new Webspace(); | ||
$webspace->setKey('sulu_io'); | ||
$webspace->addLocalization(new Localization('de')); | ||
|
||
$this->structureManager->getStructures()->willReturn([]); | ||
$this->webspaceManager->getWebspaceCollection()->willReturn(new WebspaceCollection([$webspace])); | ||
|
||
$executeMethod = new \ReflectionMethod(ValidateWebspacesCommand::class, 'execute'); | ||
$executeMethod->setAccessible(true); | ||
|
||
$this->eventDispatcher->dispatch(new PreRenderEvent(new RequestAttributes([ | ||
'webspace' => $webspace, | ||
])), Events::PRE_RENDER) | ||
->shouldBeCalled(); | ||
|
||
$executeMethod->invoke($this->validateWebspacesCommand, $this->input->reveal(), $this->output->reveal()); | ||
} | ||
} |