-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Synolia\SyliusMaintenancePlugin\PHPUnit; | ||
|
||
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface; | ||
use Sylius\Component\Core\Model\ChannelInterface; | ||
use Sylius\Component\Core\Test\Services\DefaultChannelFactory; | ||
use Symfony\Component\Yaml\Yaml; | ||
|
||
final class MulitChannelMaintenanceTest extends AbstractWebTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
/** @var ChannelRepositoryInterface $channelRepository */ | ||
$channelRepository = $this->manager->getRepository(ChannelInterface::class); | ||
/** @var DefaultChannelFactory $channelFactory */ | ||
$channelFactory = self::$kernel->getContainer()->get('sylius.behat.factory.default_channel'); | ||
|
||
// set hostname for actuel channel | ||
$channel = $channelRepository->findOneByCode('FASHION_WEB'); | ||
$channel->setHostname('fashion.localhost'); | ||
|
||
// create a new channel for maintenance | ||
$maintenanceChannel = $channelFactory->create('test', 'Test channel')['channel']; | ||
$maintenanceChannel->setHostname('test.localhost'); | ||
$this->manager->persist($maintenanceChannel); | ||
|
||
$this->manager->flush(); | ||
} | ||
|
||
public function testMaintenanceIsNotEnabledWhenFileIsNotEnabled(): void | ||
{ | ||
\file_put_contents( | ||
$this->file, | ||
Yaml::dump([ | ||
'channels' => [ | ||
'FASHION_WEB', | ||
'test', | ||
], | ||
'enabled' => true, | ||
]), | ||
|
||
); | ||
self::$client->request('GET', 'http://fashion.localhost/en_US/'); | ||
$this->assertSiteIsInMaintenance(); | ||
|
||
self::$client->request('GET', 'http://test.localhost/en_US/'); | ||
$this->assertSiteIsInMaintenance(); | ||
} | ||
} |