mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Behat] Use ChannelTransformer in DashboardContext
This commit is contained in:
parent
7641ba0f53
commit
d719c1bc81
3 changed files with 16 additions and 15 deletions
|
|
@ -15,10 +15,14 @@ namespace Sylius\Behat\Context\Transform;
|
|||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
|
||||
use Sylius\Component\Core\Model\ChannelInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class ChannelContext implements Context
|
||||
{
|
||||
/**
|
||||
* @param ChannelRepositoryInterface<ChannelInterface> $channelRepository
|
||||
*/
|
||||
public function __construct(private ChannelRepositoryInterface $channelRepository)
|
||||
{
|
||||
}
|
||||
|
|
@ -29,7 +33,7 @@ final class ChannelContext implements Context
|
|||
* @Transform /^channel to "([^"]+)"$/
|
||||
* @Transform :channel
|
||||
*/
|
||||
public function getChannelByName($channelName)
|
||||
public function getChannelByName(string $channelName)
|
||||
{
|
||||
$channels = $this->channelRepository->findByName($channelName);
|
||||
|
||||
|
|
@ -44,8 +48,10 @@ final class ChannelContext implements Context
|
|||
|
||||
/**
|
||||
* @Transform all channels
|
||||
*
|
||||
* @return array<ChannelInterface>
|
||||
*/
|
||||
public function getAllChannels()
|
||||
public function getAllChannels(): array
|
||||
{
|
||||
return $this->channelRepository->findAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Sylius\Behat\Context\Ui\Admin;
|
|||
use Behat\Behat\Context\Context;
|
||||
use FriendsOfBehat\PageObjectExtension\Page\UnexpectedPageException;
|
||||
use Sylius\Behat\Page\Admin\DashboardPageInterface;
|
||||
use Sylius\Component\Core\Formatter\StringInflector;
|
||||
use Sylius\Component\Core\Model\ChannelInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class DashboardContext implements Context
|
||||
|
|
@ -39,32 +39,26 @@ final class DashboardContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @When I view statistics for :name channel
|
||||
* @When I view statistics for :channel channel
|
||||
*
|
||||
* @throws UnexpectedPageException
|
||||
*/
|
||||
public function iViewStatisticsForChannel(string $channelName): void
|
||||
public function iViewStatisticsForChannel(ChannelInterface $channel): void
|
||||
{
|
||||
$channelName === 'United States' ?
|
||||
$channelName = 'WEB-US' : $channelName = StringInflector::nameToLowercaseCode($channelName);
|
||||
|
||||
$this->dashboardPage->open(['channel' => $channelName]);
|
||||
$this->dashboardPage->open(['channel' => $channel->getCode()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^I view statistics for "([^"]+)" channel and (current|previous|next) year split by (month|day)$/
|
||||
* @When /^I view statistics for ("[^"]+" channel) and (current|previous|next) year split by (month|day)$/
|
||||
*
|
||||
* @throws UnexpectedPageException
|
||||
*/
|
||||
public function iViewStatisticsForChannelAndYear(
|
||||
string $channelName,
|
||||
ChannelInterface $channel,
|
||||
string $period,
|
||||
string $interval,
|
||||
): void {
|
||||
$channelName === 'United States'
|
||||
? $channelName = 'WEB-US' : $channelName = StringInflector::nameToLowercaseCode($channelName);
|
||||
|
||||
$this->dashboardPage->open(['channel' => $channelName]);
|
||||
$this->dashboardPage->open(['channel' => $channel->getCode()]);
|
||||
|
||||
match ($interval) {
|
||||
'month' => $this->dashboardPage->chooseYearSplitByMonthsInterval(),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ default:
|
|||
- sylius.behat.context.setup.zone
|
||||
- Sylius\Calendar\Tests\Behat\Context\Setup\CalendarContext
|
||||
|
||||
- sylius.behat.context.transform.channel
|
||||
- sylius.behat.context.transform.customer
|
||||
- sylius.behat.context.transform.lexical
|
||||
- sylius.behat.context.transform.order
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue