Skip to content

Commit

Permalink
chore: Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mitelg committed Nov 25, 2024
1 parent 34ad075 commit 9ea06e6
Show file tree
Hide file tree
Showing 19 changed files with 1,383 additions and 930 deletions.
2 changes: 1 addition & 1 deletion tests/Component/Api/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function createCategoryTree($categories)
}

if ($existsResponse['total'] > 1) {
throw new \RuntimeException(sprintf('There are multiple definitions for "%s" with parent id %i.',
throw new \RuntimeException(\sprintf('There are multiple definitions for "%s" with parent id %i.',
$category, $parentId));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Component/Form/FormFillerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ private function isCheckboxChecked(ContextAwarePage $page, string $inputName): b

private function selectLastElement(string $xpath): string
{
return sprintf('(%s)[last()]', $xpath);
return \sprintf('(%s)[last()]', $xpath);
}
}
2 changes: 1 addition & 1 deletion tests/Component/SpinTrait/SpinTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait SpinTrait
protected function spin($lambda, int $wait = 10): void
{
if (!$this->spinWithNoException($lambda, $wait)) {
throw new \Exception(sprintf('Spin function timed out after %s seconds', $wait));
throw new \Exception(\sprintf('Spin function timed out after %s seconds', $wait));
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Component/XpathBuilder/BackendXpathBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function getTabXpathByLabel(string $label): string
/**
* Return xpath to extJs icon by type
*
*@throws \Exception
* @throws \Exception
*/
public static function getIconXpathByType(string $type): string
{
Expand Down
12 changes: 6 additions & 6 deletions tests/Component/XpathBuilder/BaseXpathBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function contains(string $text): BaseXpathBuilder
return $this;
}

$this->xpath .= sprintf("[text()[contains(.,'%s')]]", $text);
$this->xpath .= \sprintf("[text()[contains(.,'%s')]]", $text);

return $this;
}
Expand All @@ -128,7 +128,7 @@ public static function getContainsAttributeString($string, string $attribute): s
}
$result = '';
foreach ($string as $part) {
$result .= sprintf("contains(concat(' ', normalize-space(@%s), ' '), ' %s ') and ", $attribute, $part);
$result .= \sprintf("contains(concat(' ', normalize-space(@%s), ' '), ' %s ') and ", $attribute, $part);
}

return rtrim($result, ' and ');
Expand Down Expand Up @@ -252,12 +252,12 @@ private function appendPartialPath(string $tag, string $prefix, array $condition
// Add conditions
$conditionString = $this->parseConditions($conditions);
if (!empty($conditionString)) {
$this->xpath .= sprintf('[%s]', trim($conditionString));
$this->xpath .= \sprintf('[%s]', trim($conditionString));
}

// Add index
if ($index !== null) {
$this->xpath .= sprintf('[%d]', $index);
$this->xpath .= \sprintf('[%d]', $index);
}

return $this;
Expand All @@ -270,9 +270,9 @@ private function equals(string $target, string $text): string
{
switch ($target) {
case 'text':
return sprintf("text()='%s'", $text);
return \sprintf("text()='%s'", $text);
default:
return sprintf("@%s='%s'", $target, $text);
return \sprintf("@%s='%s'", $target, $text);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Context/BackendOrderContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function iShouldSeeExactlyOneOrderInTheOrderList(string $amount): void
{
$actualAmount = $this->getModulePage()->getNumberOfOrdersInOrderList();
if ((int) $amount !== $actualAmount) {
throw new \Exception(sprintf('Expected %s order, found %s.', $amount, $actualAmount));
throw new \Exception(\sprintf('Expected %s order, found %s.', $amount, $actualAmount));
}
}

Expand All @@ -76,7 +76,7 @@ public function iShouldSeeTheOrderFromAtTheTopOfTheOrderList(string $email): voi
$topmostOrder = $this->getModulePage()->getTopmostOrderFromList();

if (!strpos($topmostOrder->getHtml(), $email)) {
throw new \Exception(sprintf('Expected order from %s would be at top of list.', $email));
throw new \Exception(\sprintf('Expected order from %s would be at top of list.', $email));
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Context/DebugContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function takeScreenshot(): void
*/
public function saveScreenshot(?string $filename = null, ?string $filepath = null): void
{
$filename = $filename ?: sprintf('%s_%s_%s.%s', $this->getMinkParameter('browser_name'), time(),
$filename = $filename ?: \sprintf('%s_%s_%s.%s', $this->getMinkParameter('browser_name'), time(),
uniqid('', true), 'png');
$filepath = $filepath ?: (\ini_get('upload_tmp_dir') ? \ini_get('upload_tmp_dir') : sys_get_temp_dir());

Expand All @@ -63,7 +63,7 @@ public function saveScreenshot(?string $filename = null, ?string $filepath = nul
private function logRequest(): void
{
$session = $this->getSession();
$log = sprintf('Current page: %d %s', $this->getStatusCode(), $session->getCurrentUrl()) . "\n";
$log = \sprintf('Current page: %d %s', $this->getStatusCode(), $session->getCurrentUrl()) . "\n";
$log .= $this->getResponseHeadersLogMessage($session);
$log .= $this->getRequestContentLogMessage($session);
$this->saveLog($log, 'log');
Expand All @@ -78,9 +78,9 @@ private function saveLog(string $content, string $type): void

$currentDateAsString = date('YmdHis');

$path = sprintf('%s/behat-%s.%s', $logDir, $currentDateAsString, $type);
$path = \sprintf('%s/behat-%s.%s', $logDir, $currentDateAsString, $type);
if (!file_put_contents($path, $content)) {
throw new \RuntimeException(sprintf('Failed while trying to write log in "%s".', $path));
throw new \RuntimeException(\sprintf('Failed while trying to write log in "%s".', $path));
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Context/Exception/PageNotDefinedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PageNotDefinedException extends \RuntimeException
*/
public function __construct(string $pageClass, int $code = 0, ?\Throwable $previous = null)
{
$message = sprintf('Page "%s" is not defined', $pageClass);
$message = \sprintf('Page "%s" is not defined', $pageClass);
parent::__construct($message, $code, $previous);
}
}
6 changes: 3 additions & 3 deletions tests/Context/GeneralContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function iWaitForSeconds($amount): void
*/
public function iScrollDown($pixels): void
{
$this->getSession()->executeScript(sprintf('window.scroll(0, %s)', $pixels));
$this->getSession()->executeScript(\sprintf('window.scroll(0, %s)', $pixels));
}

/**
Expand Down Expand Up @@ -105,13 +105,13 @@ private static function cleanDatabase(): void
$dbDumpFile = __DIR__ . '/../../clean_db.sql';

if (!is_file($dbDumpFile)) {
echo "Could not reset database - no clean state available. Missing dump file at " . $dbDumpFile . PHP_EOL;
echo 'Could not reset database - no clean state available. Missing dump file at ' . $dbDumpFile . PHP_EOL;

return;
}

echo 'Resetting database to clean state...' . PHP_EOL;
passthru(sprintf('mysql -u root -proot -h mysql shopware < %s', $dbDumpFile));
passthru(\sprintf('mysql -u root -proot -h mysql shopware < %s', $dbDumpFile));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Element/Backend/Form/Combobox.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setValue($value): void
// Click on correct dropdown entry
$option = $this->getOptionByValue($value, $dropdown);
if (!$option instanceof NodeElement) {
throw new \RuntimeException(sprintf('Could not find option with value "%s"', print_r($value, true)));
throw new \RuntimeException(\sprintf('Could not find option with value "%s"', print_r($value, true)));
}

$option->click();
Expand Down
4 changes: 2 additions & 2 deletions tests/Element/Backend/GridView/GridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getFirstRow(): GridViewRow
$xPath = $this->getGridViewFirstRowXpath();
$element = $this->find('xpath', $xPath);
if (!$element instanceof NodeElement) {
throw new \RuntimeException(sprintf('Could not find grid view row with xPath: "%s"', $xPath));
throw new \RuntimeException(\sprintf('Could not find grid view row with xPath: "%s"', $xPath));
}

return new GridViewRow($element->getXpath(), $this->getSession());
Expand Down Expand Up @@ -105,6 +105,6 @@ private function getGridViewRowsXpath(): string

private function getGridViewFirstRowXpath(): string
{
return sprintf('(%s)[1]', $this->getGridViewRowsXpath());
return \sprintf('(%s)[1]', $this->getGridViewRowsXpath());
}
}
28 changes: 14 additions & 14 deletions tests/Element/Frontend/Checkout/CartPosition.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ class CartPosition
/**
* @var string
*/
private $name;
private string $name;

/**
* @var string
*/
private $number;
private string $number;

/**
* @var int
*/
private $quantity;
private int $quantity;

/**
* @var float
*/
private $itemPrice;
private float $itemPrice;

/**
* @var float
*/
private $sum;
private float $sum;

/**
* @param string $name
Expand All @@ -38,7 +38,7 @@ class CartPosition
* @param float $itemPrice
* @param float $sum
*/
private function __construct($name, $number, $quantity, $itemPrice, $sum)
private function __construct(string $name, string $number, int $quantity, float $itemPrice, float $sum)
{
$this->name = $name;
$this->number = $number;
Expand All @@ -52,7 +52,7 @@ private function __construct($name, $number, $quantity, $itemPrice, $sum)
*
* @return CartPosition
*/
public static function fromArray(array $data)
public static function fromArray(array $data): CartPosition
{
if (!\array_key_exists('name', $data)
|| !\array_key_exists('number', $data)
Expand All @@ -78,39 +78,39 @@ public static function fromArray(array $data)
/**
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}

/**
* @return string
*/
public function getNumber()
public function getNumber(): string
{
return $this->number;
}

/**
* @return int
*/
public function getQuantity()
public function getQuantity(): int
{
return $this->quantity;
}

/**
* @return float
*/
public function getItemPrice()
public function getItemPrice(): float
{
return $this->itemPrice;
}

/**
* @return float
*/
public function getSum()
public function getSum(): float
{
return $this->sum;
}
Expand All @@ -120,7 +120,7 @@ public function getSum()
*
* @return float
*/
private static function toFloat($string)
private static function toFloat($string): float
{
if (\is_float($string)) {
return $string;
Expand All @@ -129,6 +129,6 @@ private static function toFloat($string)
$float = str_replace([' ', '.', ','], ['', '', '.'], $string);
preg_match('/([0-9]+[\\.]?[0-9]*)/', $float, $matches);

return (float) $matches[0];
return (float) ($matches[0] ?? 0.0);
}
}
2 changes: 1 addition & 1 deletion tests/Page/Backend/NewArticleModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private function setPriceData(string $value, int $position, string $inputName):
$this->waitForSelectorVisible('xpath', $priceFieldXpath);
$priceField = $row->find('xpath', $priceFieldXpath);
if (!$priceField instanceof NodeElement) {
throw new \RuntimeException(sprintf('Could not find price field with xPath "%s"', $priceFieldXpath));
throw new \RuntimeException(\sprintf('Could not find price field with xPath "%s"', $priceFieldXpath));
}
$priceField->click();

Expand Down
4 changes: 2 additions & 2 deletions tests/Page/Backend/ShippingModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function setShippingCosts(string $methodName, array $costData): void
$window = $this->getModuleWindow();

if (!$this->shippingMethodExists($methodName)) {
throw new \Exception(sprintf('Missing shipping method "%s"', $methodName));
throw new \Exception(\sprintf('Missing shipping method "%s"', $methodName));
}

$methodRow = $window->getGridView()->getRowByContent($methodName);
Expand Down Expand Up @@ -186,7 +186,7 @@ private function activateCountries(NodeElement $editor, array $countries)
*
* @return NodeElement|null
*/
private function getGridRowByContent($text, NodeElement $scope = null)
private function getGridRowByContent($text, ?NodeElement $scope = null)
{
$xpath = BackendXpathBuilder::create()
->child('div', ['@text' => $text])
Expand Down
18 changes: 8 additions & 10 deletions tests/Page/Frontend/CheckoutCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function removeCartPositionAtIndex($position)
$position = (int) $position;

if ($position > \count($rows)) {
throw new \Exception(sprintf('Can\'t delete cart position #%s - no such position', $position));
throw new \Exception(\sprintf('Can\'t delete cart position #%s - no such position', $position));
}

$row = $rows[$position - 1];
Expand Down Expand Up @@ -194,7 +194,7 @@ public function emptyCart()
public function checkPositionCountAndCartSum(string $quantity, string $amount)
{
if ($this->getCartPositionCount() !== (int) $quantity || $this->getCartSum() !== self::toFloat($amount)) {
throw new \Exception(sprintf('Expected %s positions with a sum of %s, but got %s with a sum of %s',
throw new \Exception(\sprintf('Expected %s positions with a sum of %s, but got %s with a sum of %s',
$quantity, $amount, $this->getCartPositionCount(), $this->getCartSum()));
}
}
Expand Down Expand Up @@ -268,7 +268,7 @@ private function extractActualCartPositions()
private function assertCartPositionListsAreEqual(array $expected, array $actual)
{
if (\count($expected) !== \count($actual)) {
throw new \Exception(sprintf('Expected %s cart positions, got %s.', \count($expected), \count($actual)));
throw new \Exception(\sprintf('Expected %s cart positions, got %s.', \count($expected), \count($actual)));
}

foreach ($expected as $expectedPosition) {
Expand All @@ -278,14 +278,14 @@ private function assertCartPositionListsAreEqual(array $expected, array $actual)
continue 2;
}

throw new \Exception(sprintf('Cart positions not as expected: Expected: %s Got: %s',
throw new \Exception(\sprintf('Cart positions not as expected: Expected: %s Got: %s',
print_r($expectedPosition, true),
print_r($actualPosition, true))
);
}
}

throw new \Exception(sprintf('Could not find position %s', print_r($expectedPosition, true)));
throw new \Exception(\sprintf('Could not find position %s', print_r($expectedPosition, true)));
}
}

Expand Down Expand Up @@ -327,7 +327,7 @@ private static function toFloat($string): float
$float = str_replace([' ', '.', ','], ['', '', '.'], $string);
preg_match('/([0-9]+[\\.]?[0-9]*)/', $float, $matches);

return (float) $matches[0];
return (float) ($matches[0] ?? 0.0);
}

/**
Expand Down Expand Up @@ -363,12 +363,10 @@ protected function verifyPage()
/**
* @return array
*/
private function hydratePositionData(array $positionData)
private function hydratePositionData(array $positionData): array
{
$expectedPositions = array_map(function ($position) {
return array_map(function ($position) {
return CartPosition::fromArray($position);
}, $positionData);

return $expectedPositions;
}
}
Loading

0 comments on commit 9ea06e6

Please sign in to comment.