Skip to content

Commit

Permalink
SYLIUS-274: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
timmess committed Jan 4, 2024
1 parent 1d3888a commit 18aecf5
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/PHPUnit/MulitChannelMaintenanceTest.php
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();
}
}

0 comments on commit 18aecf5

Please sign in to comment.