From 84ba5f26c2ef5fca12c3f5a20a7c0ea367e3a8d4 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Mon, 7 Dec 2020 14:15:01 +0100 Subject: [PATCH] Fix checking whether an image exists --- .../Page/Admin/Product/UpdateConfigurableProductPage.php | 4 ++-- .../Behat/Page/Admin/Product/UpdateSimpleProductPage.php | 4 ++-- src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php b/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php index 008d8ff0162a..72bfc0e2d671 100644 --- a/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php +++ b/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php @@ -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 diff --git a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php index 0b7bfbe44ba2..2edd281fb2f2 100644 --- a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php +++ b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php @@ -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 diff --git a/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php index c82f0a30826e..104d93a7d9d6 100644 --- a/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php @@ -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