Skip to content

Commit

Permalink
Fix checking whether an image exists
Browse files Browse the repository at this point in the history
  • Loading branch information
pamil committed Dec 7, 2020
1 parent 9670b46 commit 84ba5f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public function isImageWithTypeDisplayed(string $type): bool
}

$this->getDriver()->visit($imageUrl);
$pageText = $this->getDocument()->getText();
$statusCode = $this->getDriver()->getStatusCode();
$this->getDriver()->back();

return false === stripos($pageText, '404 Not Found');
return strpos((string) $statusCode, '2') === 0;
}

public function attachImage(string $path, string $type = null): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ public function isImageWithTypeDisplayed(string $type): bool
}

$this->getDriver()->visit($imageUrl);
$pageText = $this->getDocument()->getText();
$statusCode = $this->getDriver()->getStatusCode();
$this->getDriver()->back();

return false === stripos($pageText, '404 Not Found');
return strpos((string) $statusCode, '2') === 0;
}

public function attachImage(string $path, string $type = null): void
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public function isImageWithTypeDisplayed(string $type): bool
}

$this->getDriver()->visit($imageUrl);
$pageText = $this->getDocument()->getText();
$statusCode = $this->getDriver()->getStatusCode();
$this->getDriver()->back();

return false === stripos($pageText, '404 Not Found');
return strpos((string) $statusCode, '2') === 0;
}

public function isSlugReadonly(string $languageCode = 'en_US'): bool
Expand Down

0 comments on commit 84ba5f2

Please sign in to comment.