forked from Sylius/Sylius
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PriceHistory][UI] Add behat contexts and suites configuration
- Loading branch information
Showing
13 changed files
with
410 additions
and
137 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
src/Sylius/Behat/Context/Ui/Admin/ChannelPricingLogEntryContext.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,73 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Behat\Context\Ui\Admin; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Sylius\Behat\Page\Admin\ChannelPricingLogEntry\IndexPageInterface; | ||
use Sylius\Component\Core\Model\ProductVariantInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class ChannelPricingLogEntryContext implements Context | ||
{ | ||
public function __construct(private IndexPageInterface $indexPage) | ||
{ | ||
} | ||
|
||
/** | ||
* @When /^I go to the price history of a (variant with code "[^"]+")$/ | ||
*/ | ||
public function iGoToThePriceHistoryOfAVariant(ProductVariantInterface $productVariant): void | ||
{ | ||
$channelPricing = $productVariant->getChannelPricings()->first(); | ||
$product = $productVariant->getProduct(); | ||
|
||
$this->indexPage->open([ | ||
'productId' => $product->getId(), | ||
'variantId' => $productVariant->getId(), | ||
'channelPricingId' => $channelPricing->getId(), | ||
]); | ||
} | ||
|
||
/** | ||
* @Then I should see :count log entries in the catalog price history | ||
* @Then I should see a single log entry in the catalog price history | ||
*/ | ||
public function iShouldSeeLogEntriesInTheCatalogPriceHistoryForTheVariant(int $count = 1): void | ||
{ | ||
Assert::same($this->indexPage->countItems(), $count); | ||
} | ||
|
||
/** | ||
* @Then /^there should be a log entry on the (\d+)(?:|st|nd|rd|th) position with the "([^"]+)" selling price, "([^"]+)" original price and datetime of the price change$/ | ||
* @Then /^there should be a log entry on the (\d+)(?:|st|nd|rd|th) position with the "([^"]+)" selling price, no original price and datetime of the price change$/ | ||
*/ | ||
public function thereShouldBeALogEntryOnThePositionWithTheSellingPriceOriginalPriceAndDatetimeOfThePriceChange( | ||
int $position, | ||
string $price, | ||
string $originalPrice = '-', | ||
): void { | ||
Assert::true($this->indexPage->isLogEntryWithPriceAndOriginalPriceOnPosition($price, $originalPrice, $position)); | ||
} | ||
|
||
/** | ||
* @Then /^there should be a log entry with the "([^"]+)" selling price, "([^"]+)" original price and datetime of the price change$/ | ||
* @Then /^there should be a log entry with the "([^"]+)" selling price, no original price and datetime of the price change$/ | ||
*/ | ||
public function thereShouldBeALogEntryWithTheSellingPriceOriginalPriceAndDatetimeOfThePriceChange( | ||
string $price, | ||
string $originalPrice = '-', | ||
): void { | ||
Assert::true($this->indexPage->isLogEntryWithPriceAndOriginalPrice($price, $originalPrice)); | ||
} | ||
} |
Oops, something went wrong.