Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update dependencies #5

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 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 @@ -75,8 +75,8 @@ 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));
if (strpos($topmostOrder->getHtml(), $email) === false) {
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
2 changes: 1 addition & 1 deletion tests/Page/Backend/ProductExportModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function blockSupplier($supplierName)
*/
public function addMinimumPriceFilter($minPrice)
{
$this->getEditorWindow()->getInput('Preis grösser:')->setValue((int) $minPrice);
$this->getEditorWindow()->getInput('Preis grösser:')->setValue($minPrice);
}

/**
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
Loading
Loading