From bc9186b2550daeb611c7de4efb60727818ec93f8 Mon Sep 17 00:00:00 2001 From: Valery Maslov Date: Thu, 20 Jun 2024 14:01:20 +0300 Subject: [PATCH] Apply fixes from Rector --- .../Admin/CategoryControllerTest.php | 7 +++-- .../Controller/Admin/CityControllerTest.php | 7 +++-- .../Admin/CurrencyControllerTest.php | 7 +++-- .../Admin/DashboardControllerTest.php | 3 +- .../Admin/DealTypeControllerTest.php | 7 +++-- .../Admin/DistrictControllerTest.php | 7 +++-- .../Admin/FeatureControllerTest.php | 7 +++-- .../Controller/Admin/MenuControllerTest.php | 15 +++++----- .../Controller/Admin/MetroControllerTest.php | 7 +++-- .../Admin/NeighborhoodControllerTest.php | 7 +++-- .../Controller/Admin/PageControllerTest.php | 7 +++-- .../Admin/PropertyControllerTest.php | 13 +++++---- .../Settings/HeaderSettingsControllerTest.php | 8 ++--- .../Settings/MainSettingsControllerTest.php | 10 +++---- .../Settings/MapSettingsControllerTest.php | 2 +- .../Controller/Admin/UserControllerTest.php | 15 +++++----- .../Controller/Ajax/CityControllerTest.php | 9 +++--- .../Auth/RegisterControllerTest.php | 11 +++---- .../Auth/ResendVerificationControllerTest.php | 20 ++++++------- .../Auth/ResettingControllerTest.php | 7 +++-- .../Auth/VerificationControllerTest.php | 6 ++-- .../Controller/DefaultControllerTest.php | 9 +++--- .../Controller/PageControllerTest.php | 5 ++-- .../Controller/PropertyControllerTest.php | 29 ++++++++++--------- .../Controller/SitemapControllerTest.php | 7 +++-- .../Controller/User/PhotoControllerTest.php | 15 +++++----- .../Controller/User/ProfileControllerTest.php | 3 +- .../User/PropertyControllerTest.php | 27 ++++++++--------- .../GoogleAuthenticatorControllerTest.php | 19 ++++++------ .../User/Security/PasswordControllerTest.php | 11 +++---- 30 files changed, 166 insertions(+), 141 deletions(-) diff --git a/tests/Functional/Controller/Admin/CategoryControllerTest.php b/tests/Functional/Controller/Admin/CategoryControllerTest.php index c7dca6a3..9edd9e4f 100644 --- a/tests/Functional/Controller/Admin/CategoryControllerTest.php +++ b/tests/Functional/Controller/Admin/CategoryControllerTest.php @@ -7,6 +7,7 @@ use App\Entity\Category; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class CategoryControllerTest extends WebTestCase @@ -23,7 +24,7 @@ final class CategoryControllerTest extends WebTestCase public function testAdminNewCategory(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', '/en/admin/category/new'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/category/new'); $form = $crawler->selectButton('Create category')->form([ 'category[name]' => self::NAME, @@ -58,7 +59,7 @@ public function testAdminEditCategory(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $client->request('GET', '/en/admin/category/'.$category.'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/category/'.$category.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'category[name]' => self::EDITED_NAME, @@ -91,7 +92,7 @@ public function testAdminDeleteCategory(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $client->request('GET', '/en/admin/category'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/category'); $client->submit($crawler->filter('#delete-form-'.$category)->form()); $this->assertSame( Response::HTTP_FOUND, diff --git a/tests/Functional/Controller/Admin/CityControllerTest.php b/tests/Functional/Controller/Admin/CityControllerTest.php index e903ee06..0094ab7c 100644 --- a/tests/Functional/Controller/Admin/CityControllerTest.php +++ b/tests/Functional/Controller/Admin/CityControllerTest.php @@ -5,6 +5,7 @@ namespace App\Tests\Functional\Controller\Admin; use App\Entity\City; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class CityControllerTest extends AbstractLocationControllerTest @@ -14,7 +15,7 @@ final class CityControllerTest extends AbstractLocationControllerTest */ public function testAdminNewCity(): void { - $crawler = $this->client->request('GET', '/en/admin/locations/city/new'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/city/new'); $form = $crawler->selectButton('Create city')->form([ 'city[name]' => self::NAME, @@ -52,7 +53,7 @@ public function testAdminEditCity(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $this->client->request('GET', '/en/admin/locations/city/'.$city.'/edit'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/city/'.$city.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'city[name]' => self::EDITED_NAME, @@ -88,7 +89,7 @@ public function testAdminDeleteCity(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $this->client->request('GET', '/en/admin/locations/city'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/city'); $this->client->submit($crawler->filter('#delete-form-'.$city)->form()); $this->assertSame( Response::HTTP_FOUND, diff --git a/tests/Functional/Controller/Admin/CurrencyControllerTest.php b/tests/Functional/Controller/Admin/CurrencyControllerTest.php index b5d99731..516b61db 100644 --- a/tests/Functional/Controller/Admin/CurrencyControllerTest.php +++ b/tests/Functional/Controller/Admin/CurrencyControllerTest.php @@ -7,6 +7,7 @@ use App\Entity\Currency; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class CurrencyControllerTest extends WebTestCase @@ -23,7 +24,7 @@ public function testAdminNewCurrency(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', '/en/admin/currency/new'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/currency/new'); $form = $crawler->selectButton('Create currency')->form([ 'currency[currency_title]' => self::CURRENCY, @@ -57,7 +58,7 @@ public function testAdminEditCurrency(): void 'code' => self::CURRENCY, ])->getId(); - $crawler = $client->request('GET', '/en/admin/currency/'.$currency.'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/currency/'.$currency.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'currency[currency_title]' => self::EDITED, @@ -91,7 +92,7 @@ public function testAdminDeleteCurrency(): void 'code' => self::EDITED, ])->getId(); - $crawler = $client->request('GET', '/en/admin/currency'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/currency'); $client->submit($crawler->filter('#delete-form-'.$currency)->form()); $this->assertSame( Response::HTTP_FOUND, diff --git a/tests/Functional/Controller/Admin/DashboardControllerTest.php b/tests/Functional/Controller/Admin/DashboardControllerTest.php index b337c012..1cb11468 100644 --- a/tests/Functional/Controller/Admin/DashboardControllerTest.php +++ b/tests/Functional/Controller/Admin/DashboardControllerTest.php @@ -6,6 +6,7 @@ use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; final class DashboardControllerTest extends WebTestCase { @@ -14,7 +15,7 @@ final class DashboardControllerTest extends WebTestCase public function testAdminDashboard(): void { $client = $this->authAsAdmin($this); - $client->request('GET', '/en/admin'); + $client->request(Request::METHOD_GET, '/en/admin'); $this->assertResponseIsSuccessful(sprintf('The %s public URL loads correctly.', '/admin')); } } diff --git a/tests/Functional/Controller/Admin/DealTypeControllerTest.php b/tests/Functional/Controller/Admin/DealTypeControllerTest.php index c0b5c534..f80f3153 100644 --- a/tests/Functional/Controller/Admin/DealTypeControllerTest.php +++ b/tests/Functional/Controller/Admin/DealTypeControllerTest.php @@ -7,6 +7,7 @@ use App\Entity\DealType; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class DealTypeControllerTest extends WebTestCase @@ -24,7 +25,7 @@ public function testAdminNewDealType(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', '/en/admin/deal_type/new'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/deal_type/new'); $form = $crawler->selectButton('Create deal type')->form([ 'deal_type[name]' => self::NAME, @@ -59,7 +60,7 @@ public function testAdminEditDealType(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $client->request('GET', '/en/admin/deal_type/'.$dealType.'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/deal_type/'.$dealType.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'deal_type[name]' => self::EDITED_NAME, @@ -92,7 +93,7 @@ public function testAdminDeleteDealType(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $client->request('GET', '/en/admin/deal_type'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/deal_type'); $client->submit($crawler->filter('#delete-form-'.$dealType)->form()); $this->assertSame( Response::HTTP_FOUND, diff --git a/tests/Functional/Controller/Admin/DistrictControllerTest.php b/tests/Functional/Controller/Admin/DistrictControllerTest.php index 0d809c85..34d90047 100644 --- a/tests/Functional/Controller/Admin/DistrictControllerTest.php +++ b/tests/Functional/Controller/Admin/DistrictControllerTest.php @@ -5,6 +5,7 @@ namespace App\Tests\Functional\Controller\Admin; use App\Entity\District; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class DistrictControllerTest extends AbstractLocationControllerTest @@ -14,7 +15,7 @@ final class DistrictControllerTest extends AbstractLocationControllerTest */ public function testAdminNewDistrict(): void { - $crawler = $this->client->request('GET', '/en/admin/locations/district/new'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/district/new'); $form = $crawler->selectButton('Create district')->form([ 'district[name]' => self::NAME, @@ -46,7 +47,7 @@ public function testAdminEditDistrict(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $this->client->request('GET', '/en/admin/locations/district/'.$district.'/edit'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/district/'.$district.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'district[name]' => self::EDITED_NAME, @@ -72,7 +73,7 @@ public function testAdminEditDistrict(): void */ public function testAdminDeleteDistrict(): void { - $crawler = $this->client->request('GET', '/en/admin/locations/district'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/district'); $district = $this->getRepository($this->client, District::class) ->findOneBy([ diff --git a/tests/Functional/Controller/Admin/FeatureControllerTest.php b/tests/Functional/Controller/Admin/FeatureControllerTest.php index 1eb53ff6..6f12c01c 100644 --- a/tests/Functional/Controller/Admin/FeatureControllerTest.php +++ b/tests/Functional/Controller/Admin/FeatureControllerTest.php @@ -7,6 +7,7 @@ use App\Entity\Feature; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class FeatureControllerTest extends WebTestCase @@ -23,7 +24,7 @@ public function testAdminNewFeature(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', '/en/admin/feature/new'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/feature/new'); $form = $crawler->selectButton('Create feature')->form([ 'feature[name]' => self::FEATURE, @@ -55,7 +56,7 @@ public function testAdminEditFeature(): void 'name' => self::FEATURE, ])->getId(); - $crawler = $client->request('GET', '/en/admin/feature/'.$feature.'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/feature/'.$feature.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'feature[name]' => self::EDITED, @@ -86,7 +87,7 @@ public function testAdminDeleteFeature(): void 'name' => self::EDITED, ])->getId(); - $crawler = $client->request('GET', '/en/admin/feature'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/feature'); $client->submit($crawler->filter('#delete-form-'.$feature)->form()); $this->assertSame( Response::HTTP_FOUND, diff --git a/tests/Functional/Controller/Admin/MenuControllerTest.php b/tests/Functional/Controller/Admin/MenuControllerTest.php index 7ee20138..df950fa8 100644 --- a/tests/Functional/Controller/Admin/MenuControllerTest.php +++ b/tests/Functional/Controller/Admin/MenuControllerTest.php @@ -7,6 +7,7 @@ use App\Entity\Menu; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class MenuControllerTest extends WebTestCase @@ -25,7 +26,7 @@ public function testAdminNewItem(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', '/en/admin/menu/new'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/menu/new'); $form = $crawler->selectButton('Save changes')->form([ 'menu[title]' => self::TITLE, @@ -63,7 +64,7 @@ public function testAdminEditItem(): void 'locale' => self::LOCALE, ])->getId(); - $crawler = $client->request('GET', '/en/admin/menu/'.$item.'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/menu/'.$item.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'menu[title]' => self::EDITED_TITLE, @@ -90,7 +91,7 @@ public function testAdminEditItem(): void public function testAdminSortItems(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', '/en/admin/menu'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/menu'); $token = $this->getCsrfToken($crawler); $items = $this->getRepository($client, Menu::class) ->findItems(); @@ -98,18 +99,18 @@ public function testAdminSortItems(): void $itemsArray = array_map(fn ($item) => $item->getId(), $items); $uri = '/en/admin/menu/sort'; - $client->request('POST', $uri, [ + $client->request(Request::METHOD_POST, $uri, [ 'csrf-token' => $token, 'items' => array_reverse($itemsArray), ]); $this->assertResponseStatusCodeSame(419); - $client->request('POST', $uri, [ + $client->request(Request::METHOD_POST, $uri, [ 'csrf_token' => $token, 'items' => array_reverse($itemsArray), ]); - $client->request('POST', $uri, [ + $client->request(Request::METHOD_POST, $uri, [ 'csrf_token' => $token, 'items' => $itemsArray, ]); @@ -136,7 +137,7 @@ public function testAdminDeleteItem(): void 'url' => self::URL, ])->getId(); - $crawler = $client->request('GET', '/en/admin/menu'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/menu'); $client->submit($crawler->filter('#delete-form-'.$item)->form()); $this->assertSame( Response::HTTP_FOUND, diff --git a/tests/Functional/Controller/Admin/MetroControllerTest.php b/tests/Functional/Controller/Admin/MetroControllerTest.php index e45d2ede..99b3e1f0 100644 --- a/tests/Functional/Controller/Admin/MetroControllerTest.php +++ b/tests/Functional/Controller/Admin/MetroControllerTest.php @@ -5,6 +5,7 @@ namespace App\Tests\Functional\Controller\Admin; use App\Entity\Metro; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class MetroControllerTest extends AbstractLocationControllerTest @@ -14,7 +15,7 @@ final class MetroControllerTest extends AbstractLocationControllerTest */ public function testAdminNewStation(): void { - $crawler = $this->client->request('GET', '/en/admin/locations/metro/new'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/metro/new'); $form = $crawler->selectButton('Create metro station')->form([ 'metro[name]' => self::NAME, @@ -46,7 +47,7 @@ public function testAdminEditStation(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $this->client->request('GET', '/en/admin/locations/metro/'.$station.'/edit'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/metro/'.$station.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'metro[name]' => self::EDITED_NAME, @@ -73,7 +74,7 @@ public function testAdminDeleteStation(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $this->client->request('GET', '/en/admin/locations/metro'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/metro'); $this->client->submit($crawler->filter('#delete-metro-'.$station)->form()); $this->assertSame(Response::HTTP_FOUND, $this->client->getResponse()->getStatusCode(), $this->client->getResponse()->getContent()); diff --git a/tests/Functional/Controller/Admin/NeighborhoodControllerTest.php b/tests/Functional/Controller/Admin/NeighborhoodControllerTest.php index 874d5b44..2fe75d28 100644 --- a/tests/Functional/Controller/Admin/NeighborhoodControllerTest.php +++ b/tests/Functional/Controller/Admin/NeighborhoodControllerTest.php @@ -5,6 +5,7 @@ namespace App\Tests\Functional\Controller\Admin; use App\Entity\Neighborhood; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class NeighborhoodControllerTest extends AbstractLocationControllerTest @@ -14,7 +15,7 @@ final class NeighborhoodControllerTest extends AbstractLocationControllerTest */ public function testAdminNewNeighborhood(): void { - $crawler = $this->client->request('GET', '/en/admin/locations/neighborhood/new'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/neighborhood/new'); $form = $crawler->selectButton('Create neighborhood')->form([ 'neighborhood[name]' => self::NAME, @@ -47,7 +48,7 @@ public function testAdminEditNeighborhood(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $this->client->request('GET', '/en/admin/locations/neighborhood/'.$neighborhood.'/edit'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/neighborhood/'.$neighborhood.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'neighborhood[name]' => self::EDITED_NAME, @@ -78,7 +79,7 @@ public function testAdminDeleteNeighborhood(): void 'slug' => self::SLUG, ])->getId(); - $crawler = $this->client->request('GET', '/en/admin/locations/neighborhood'); + $crawler = $this->client->request(Request::METHOD_GET, '/en/admin/locations/neighborhood'); $this->client->submit($crawler->filter('#delete-neighborhood-'.$neighborhood)->form()); $this->assertSame( Response::HTTP_FOUND, diff --git a/tests/Functional/Controller/Admin/PageControllerTest.php b/tests/Functional/Controller/Admin/PageControllerTest.php index 6a67b180..abf0df34 100644 --- a/tests/Functional/Controller/Admin/PageControllerTest.php +++ b/tests/Functional/Controller/Admin/PageControllerTest.php @@ -8,6 +8,7 @@ use App\Entity\Page; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class PageControllerTest extends WebTestCase @@ -25,7 +26,7 @@ final class PageControllerTest extends WebTestCase public function testAdminNewPage(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', '/en/admin/page/new'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/page/new'); $form = $crawler->selectButton('Create page')->form([ 'page[title]' => self::TITLE, @@ -73,7 +74,7 @@ public function testAdminEditPage(): void 'locale' => self::LOCALE, ])->getId(); - $crawler = $client->request('GET', '/en/admin/page/'.$page.'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/page/'.$page.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'page[title]' => self::EDITED_TITLE, @@ -106,7 +107,7 @@ public function testAdminDeletePage(): void 'locale' => self::LOCALE, ])->getId(); - $crawler = $client->request('GET', '/en/admin/page'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/page'); $client->submit($crawler->filter('#delete-form-'.$page)->form()); $this->assertSame( diff --git a/tests/Functional/Controller/Admin/PropertyControllerTest.php b/tests/Functional/Controller/Admin/PropertyControllerTest.php index 1d2fec2f..ef584d3b 100644 --- a/tests/Functional/Controller/Admin/PropertyControllerTest.php +++ b/tests/Functional/Controller/Admin/PropertyControllerTest.php @@ -13,6 +13,7 @@ use App\Entity\Property; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class PropertyControllerTest extends WebTestCase @@ -26,7 +27,7 @@ public function testAdminNewProperty(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', '/en/admin/property/new'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/property/new'); $city = $this->getRepository($client, City::class) ->findOneBy(['slug' => 'miami'])->getId(); @@ -64,7 +65,7 @@ public function testAdminEditPhoto(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['slug' => 'test'])->getId(); - $crawler = $client->request('GET', '/en/admin/photo/'.$property.'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/photo/'.$property.'/edit'); $this->assertSelectorTextContains('html', 'Upload photos'); $photo = __DIR__.'/../../../../public/images/bg.jpg'; @@ -91,7 +92,7 @@ public function testAdminEditProperty(): void $feature = $this->getRepository($client, Feature::class) ->findOneBy(['name' => 'Secure parking']); - $crawler = $client->request('GET', '/en/admin/property/'.$property->getId().'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/property/'.$property->getId().'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'property[property_description][meta_title]' => 'Custom Meta Title', @@ -107,7 +108,7 @@ public function testAdminEditProperty(): void $client->getResponse()->getContent() ); - $crawler = $client->request('GET', sprintf( + $crawler = $client->request(Request::METHOD_GET, sprintf( '/en/%s/%s/%d', $property->getCity()->getSlug(), $property->getSlug(), @@ -128,7 +129,7 @@ public function testAdminDeletePhoto(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['slug' => 'test'])->getId(); - $crawler = $client->request('GET', '/en/admin/photo/'.$property.'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/photo/'.$property.'/edit'); $form = $crawler->selectButton('Delete')->form(); $client->submit($form); @@ -149,7 +150,7 @@ public function testAdminDeleteProperty(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['slug' => 'test'])->getId(); - $crawler = $client->request('GET', '/en/admin/property?sort_by=id'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/property?sort_by=id'); $client->submit($crawler->filter('#delete-form-'.$property)->form()); $this->assertSame( diff --git a/tests/Functional/Controller/Admin/Settings/HeaderSettingsControllerTest.php b/tests/Functional/Controller/Admin/Settings/HeaderSettingsControllerTest.php index 947ca11b..1c4bed56 100644 --- a/tests/Functional/Controller/Admin/Settings/HeaderSettingsControllerTest.php +++ b/tests/Functional/Controller/Admin/Settings/HeaderSettingsControllerTest.php @@ -19,7 +19,7 @@ public function testUploadHeaderImage(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', self::SETTINGS_PAGE_PATH); + $crawler = $client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, self::SETTINGS_PAGE_PATH); $this->assertSelectorTextContains('html', 'Header settings'); $image = __DIR__.'/../../../../../public/uploads/images/full/demo/1.jpeg'; @@ -34,7 +34,7 @@ public function testUploadLogoImage(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', self::SETTINGS_PAGE_PATH); + $crawler = $client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, self::SETTINGS_PAGE_PATH); $this->assertSelectorTextContains('html', 'Header settings'); $image = __DIR__.'/../../../../../public/images/logo-square.png'; @@ -49,7 +49,7 @@ public function testDeleteHeaderImage(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', self::SETTINGS_PAGE_PATH); + $crawler = $client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, self::SETTINGS_PAGE_PATH); $this->assertSelectorExists('.remove-header_image'); $client->submit($crawler->filter('#delete-form-header_image')->form()); @@ -64,7 +64,7 @@ public function testDeleteLogoImage(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', self::SETTINGS_PAGE_PATH); + $crawler = $client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, self::SETTINGS_PAGE_PATH); $this->assertSelectorExists('.remove-logo_image'); $client->submit($crawler->filter('#delete-form-logo_image')->form()); diff --git a/tests/Functional/Controller/Admin/Settings/MainSettingsControllerTest.php b/tests/Functional/Controller/Admin/Settings/MainSettingsControllerTest.php index e0e45267..52b45bf1 100644 --- a/tests/Functional/Controller/Admin/Settings/MainSettingsControllerTest.php +++ b/tests/Functional/Controller/Admin/Settings/MainSettingsControllerTest.php @@ -21,7 +21,7 @@ public function testAdminEditSettings(): void $title = $this->getRepository($client, Settings::class) ->findOneBy(['setting_name' => 'title'])->getSettingValue(); - $crawler = $client->request('GET', '/en/admin/settings'); + $crawler = $client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/en/admin/settings'); $form = $crawler->selectButton('Save changes')->form([ 'main_settings[title]' => $title.' - Test title', @@ -43,7 +43,7 @@ public function testPublicSettings(): void { $client = self::createClient(); - $crawler = $client->request('GET', '/en/'); + $crawler = $client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/en/'); $this->assertStringContainsString('Test title', $crawler->html()); $this->assertStringContainsString('Edited text', $crawler->html()); @@ -56,7 +56,7 @@ public function testPublicSettings(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['slug' => 'bright-and-cheerful-alcove-studio']); - $crawler = $client->request('GET', + $crawler = $client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, sprintf('/en/%s/%s/%d', $property->getCity()->getSlug(), $property->getSlug(), $property->getId()) ); // Check if similar properties are enabled @@ -69,7 +69,7 @@ public function testChangedBackSettings(): void $client = self::createClient(); $this->resetSettings($client); - $crawler = $client->request('GET', '/en/'); + $crawler = $client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/en/'); $this->assertStringNotContainsString('Test title', $crawler->html()); $this->assertCount(6, $crawler->filter('.property-box-img')); @@ -81,7 +81,7 @@ public function testChangedBackSettings(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['slug' => 'bright-and-cheerful-alcove-studio']); - $crawler = $client->request('GET', + $crawler = $client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, sprintf('/en/%s/%s/%d', $property->getCity()->getSlug(), $property->getSlug(), $property->getId()) ); // Check if similar properties are disabled diff --git a/tests/Functional/Controller/Admin/Settings/MapSettingsControllerTest.php b/tests/Functional/Controller/Admin/Settings/MapSettingsControllerTest.php index 1f43f18a..b54d7d2f 100644 --- a/tests/Functional/Controller/Admin/Settings/MapSettingsControllerTest.php +++ b/tests/Functional/Controller/Admin/Settings/MapSettingsControllerTest.php @@ -24,7 +24,7 @@ public function testAdminEditSettings(): void $this->assertEmpty($initialKey); - $crawler = $client->request('GET', self::MAP_SETTINGS_PAGE); + $crawler = $client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, self::MAP_SETTINGS_PAGE); $form = $crawler->selectButton('Save changes')->form([ 'map_settings[ymaps_key]' => self::TEST_KEY, diff --git a/tests/Functional/Controller/Admin/UserControllerTest.php b/tests/Functional/Controller/Admin/UserControllerTest.php index ff248548..299b5f81 100644 --- a/tests/Functional/Controller/Admin/UserControllerTest.php +++ b/tests/Functional/Controller/Admin/UserControllerTest.php @@ -7,6 +7,7 @@ use App\Entity\User; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class UserControllerTest extends WebTestCase @@ -19,7 +20,7 @@ final class UserControllerTest extends WebTestCase public function testAdminNewUser(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', '/en/admin/user/new'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/user/new'); $form = $crawler->selectButton('Create user')->form([ 'user[profile][full_name]' => 'test', @@ -51,10 +52,10 @@ public function testUserPermissions(): void 'PHP_AUTH_PW' => 'test', ]); - $client->request('GET', '/en/user/property'); + $client->request(Request::METHOD_GET, '/en/user/property'); $this->assertResponseIsSuccessful(); - $client->request('GET', '/en/admin'); + $client->request(Request::METHOD_GET, '/en/admin'); $this->assertResponseStatusCodeSame(403); } @@ -66,7 +67,7 @@ public function testAdminEditUser(): void $client = $this->authAsAdmin($this); $user = $this->getUser($client, 'test')->getId(); - $crawler = $client->request('GET', '/en/admin/user/'.$user.'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/user/'.$user.'/edit'); $form = $crawler->selectButton('Save changes')->form([ 'user[roles]' => ['ROLE_ADMIN'], @@ -94,10 +95,10 @@ public function testAdminPermissions(): void { $client = $this->authAsAdmin($this); - $client->request('GET', '/en/user/property'); + $client->request(Request::METHOD_GET, '/en/user/property'); $this->assertResponseIsSuccessful(); - $client->request('GET', '/en/admin'); + $client->request(Request::METHOD_GET, '/en/admin'); $this->assertResponseIsSuccessful(); } @@ -109,7 +110,7 @@ public function testAdminDeleteUser(): void $client = $this->authAsAdmin($this); $user = $this->getUser($client, 'edited')->getId(); - $crawler = $client->request('GET', '/en/admin/user'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/user'); $client->submit($crawler->filter('#delete-form-'.$user)->form()); $this->assertSame( Response::HTTP_FOUND, diff --git a/tests/Functional/Controller/Ajax/CityControllerTest.php b/tests/Functional/Controller/Ajax/CityControllerTest.php index 73125839..9abf526b 100644 --- a/tests/Functional/Controller/Ajax/CityControllerTest.php +++ b/tests/Functional/Controller/Ajax/CityControllerTest.php @@ -7,6 +7,7 @@ use App\Entity\City; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; final class CityControllerTest extends WebTestCase { @@ -15,7 +16,7 @@ final class CityControllerTest extends WebTestCase public function testSomething(): void { $client = $this->authAsUser($this); - $crawler = $client->request('GET', '/en/user/property/new'); + $crawler = $client->request(Request::METHOD_GET, '/en/user/property/new'); // Find CSRF token $token = $this->getCsrfToken($crawler); @@ -25,15 +26,15 @@ public function testSomething(): void ->findOneBy(['slug' => 'miami'])->getId(); // Request without CSRF token - $client->request('GET', sprintf('/en/city/%s.json', $city)); + $client->request(Request::METHOD_GET, sprintf('/en/city/%s.json', $city)); $this->assertResponseStatusCodeSame(419); // Request with wrong city ID - $client->request('GET', sprintf('/en/city/%s.json?csrf_token=%s', 999, $token)); + $client->request(Request::METHOD_GET, sprintf('/en/city/%s.json?csrf_token=%s', 999, $token)); $this->assertResponseStatusCodeSame(404); // Request with CSRF token - $client->request('GET', sprintf('/en/city/%s.json?csrf_token=%s', $city, $token)); + $client->request(Request::METHOD_GET, sprintf('/en/city/%s.json?csrf_token=%s', $city, $token)); $this->assertResponseIsSuccessful(); $response = $client->getResponse(); diff --git a/tests/Functional/Controller/Auth/RegisterControllerTest.php b/tests/Functional/Controller/Auth/RegisterControllerTest.php index 31777c39..b3f7c1bb 100644 --- a/tests/Functional/Controller/Auth/RegisterControllerTest.php +++ b/tests/Functional/Controller/Auth/RegisterControllerTest.php @@ -6,6 +6,7 @@ use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; final class RegisterControllerTest extends WebTestCase { @@ -20,7 +21,7 @@ final class RegisterControllerTest extends WebTestCase public function testRegistrationSuspended(): void { $client = self::createClient(); - $client->request('GET', '/en/register'); + $client->request(Request::METHOD_GET, '/en/register'); $this->assertResponseRedirects('/en/'); $client->followRedirect(); $this->assertSelectorTextContains('.alert-danger', 'temporarily suspended'); @@ -29,7 +30,7 @@ public function testRegistrationSuspended(): void public function testAdminUpdateSettings(): void { $client = $this->authAsAdmin($this); - $crawler = $client->request('GET', '/en/admin/settings'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/settings'); $form = $crawler->selectButton('Save changes')->form([ 'main_settings[anyone_can_register]' => '1', ]); @@ -40,7 +41,7 @@ public function testAdminUpdateSettings(): void public function testRegister(): void { $client = self::createClient(); - $crawler = $client->request('GET', '/en/register'); + $crawler = $client->request(Request::METHOD_GET, '/en/register'); $this->assertResponseIsSuccessful(); $this->assertSelectorTextContains('.card-header', 'Register'); $form = $crawler->selectButton('Create account')->form([ @@ -61,7 +62,7 @@ public function testRegister(): void public function testLogin(): void { $client = $this->authAsUser($this); - $client->request('GET', '/en/user/profile'); + $client->request(Request::METHOD_GET, '/en/user/profile'); $this->assertSelectorTextContains('h3', 'My profile'); } @@ -70,7 +71,7 @@ public function testDeleteUser(): void { $client = $this->authAsAdmin($this); $user = $this->getUser($client, self::USER['PHP_AUTH_USER'])->getId(); - $crawler = $client->request('GET', '/en/admin/user'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/user'); $client->submit($crawler->filter('#delete-form-'.$user)->form()); $this->assertResponseRedirects('/en/admin/user'); $this->resetSettings($client); diff --git a/tests/Functional/Controller/Auth/ResendVerificationControllerTest.php b/tests/Functional/Controller/Auth/ResendVerificationControllerTest.php index 76013cfc..aa1f2189 100644 --- a/tests/Functional/Controller/Auth/ResendVerificationControllerTest.php +++ b/tests/Functional/Controller/Auth/ResendVerificationControllerTest.php @@ -44,30 +44,30 @@ public function testResetUserVerification(): void $this->entityManager->flush(); // Make sure the user is not verified - $this->client->request('GET', '/en/user/property'); + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/en/user/property'); $this->assertSelectorTextContains('.alert-warning', 'you need to confirm your email address'); $this->assertFalse($this->user->isVerified()); } public function testCsrfProtection(): void { - $this->client->request('GET', '/en/auth/should_link_be_visible', []); + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/en/auth/should_link_be_visible', []); $this->assertResponseStatusCodeSame(419); - $this->client->request('POST', '/en/auth/resend', []); + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_POST, '/en/auth/resend', []); $this->assertResponseStatusCodeSame(419); } public function testShouldLinkBeVisible(): void { - $crawler = $this->client->request('GET', '/en/user/property'); + $crawler = $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/en/user/property'); $token = $this->getCsrfToken($crawler); - $this->client->request('POST', '/en/auth/should_link_be_visible', [ + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_POST, '/en/auth/should_link_be_visible', [ 'csrf_token' => $token, ]); $this->assertResponseStatusCodeSame(405); - $this->client->request('GET', '/en/auth/should_link_be_visible', [ + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/en/auth/should_link_be_visible', [ 'csrf_token' => $token, ]); $this->assertResponseIsSuccessful(); @@ -75,17 +75,17 @@ public function testShouldLinkBeVisible(): void public function testResendEmail(): void { - $crawler = $this->client->request('GET', '/en/user/property'); + $crawler = $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/en/user/property'); $token = $this->getCsrfToken($crawler); $url = $crawler->filter('#resend')->attr('data-path'); - $this->client->request('POST', $url, [ + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_POST, $url, [ 'csrf_token' => $token, ]); $this->assertResponseIsSuccessful(); $this->assertEmailCount(1); - $this->client->request('POST', $url, [ + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_POST, $url, [ 'csrf_token' => $token, ]); $this->assertResponseIsUnprocessable(); @@ -96,7 +96,7 @@ public function testVerifyUser(): void { // Generate link $url = $this->generateEmailConfirmationLink($this->user); - $this->client->request('GET', $url); + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, $url); $this->client->followRedirect(); // Make sure the user is verified diff --git a/tests/Functional/Controller/Auth/ResettingControllerTest.php b/tests/Functional/Controller/Auth/ResettingControllerTest.php index 78019286..53710140 100644 --- a/tests/Functional/Controller/Auth/ResettingControllerTest.php +++ b/tests/Functional/Controller/Auth/ResettingControllerTest.php @@ -6,6 +6,7 @@ use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; final class ResettingControllerTest extends WebTestCase { @@ -14,7 +15,7 @@ final class ResettingControllerTest extends WebTestCase public function testPasswordReset(): void { $client = self::createClient(); - $crawler = $client->request('GET', '/en/password/reset'); + $crawler = $client->request(Request::METHOD_GET, '/en/password/reset'); $this->assertResponseIsSuccessful(); $this->assertSelectorTextContains('.card-header', 'Reset Password'); @@ -44,7 +45,7 @@ public function testChangePassword(): void $user = $this->getUser($client, 'admin'); - $crawler = $client->request('GET', sprintf('/en/password/reset/%s', $user->getConfirmationToken())); + $crawler = $client->request(Request::METHOD_GET, sprintf('/en/password/reset/%s', $user->getConfirmationToken())); $this->assertResponseIsSuccessful(); $this->assertSelectorTextContains('.card-header', 'Set a new password'); @@ -61,7 +62,7 @@ public function testLogin(): void { $client = $this->authAsAdmin($this); - $client->request('GET', '/en/admin'); + $client->request(Request::METHOD_GET, '/en/admin'); $this->assertSelectorTextContains('.navbar-brand', 'Dashboard'); $user = $this->getUser($client, 'admin'); diff --git a/tests/Functional/Controller/Auth/VerificationControllerTest.php b/tests/Functional/Controller/Auth/VerificationControllerTest.php index 0b8801f8..7956532f 100644 --- a/tests/Functional/Controller/Auth/VerificationControllerTest.php +++ b/tests/Functional/Controller/Auth/VerificationControllerTest.php @@ -40,7 +40,7 @@ public function testVerifyUserEmail(): void $this->entityManager->flush(); // Use incorrect link - $this->client->request('GET', '/en/email/verify'); + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/en/email/verify'); $this->assertResponseRedirects('/en/user/property'); $this->client->followRedirect(); @@ -50,12 +50,12 @@ public function testVerifyUserEmail(): void $this->assertFalse($user->isVerified()); // Make sure an unverified user cannot add new properties - $this->client->request('GET', '/en/user/property/new'); + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, '/en/user/property/new'); $this->assertResponseRedirects('/en/user/property'); // Generate link $url = $this->generateEmailConfirmationLink($user); - $this->client->request('GET', $url); + $this->client->request(\Symfony\Component\HttpFoundation\Request::METHOD_GET, $url); $this->client->followRedirect(); // Make sure the user is verified diff --git a/tests/Functional/Controller/DefaultControllerTest.php b/tests/Functional/Controller/DefaultControllerTest.php index 0b6e4a8a..fc0d9a6c 100644 --- a/tests/Functional/Controller/DefaultControllerTest.php +++ b/tests/Functional/Controller/DefaultControllerTest.php @@ -5,6 +5,7 @@ namespace App\Tests\Functional\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class DefaultControllerTest extends WebTestCase @@ -15,7 +16,7 @@ final class DefaultControllerTest extends WebTestCase public function testPublicUrls(string $url): void { $client = self::createClient(); - $client->request('GET', $url); + $client->request(Request::METHOD_GET, $url); $this->assertResponseIsSuccessful(sprintf('The %s public URL loads correctly.', $url)); } @@ -25,7 +26,7 @@ public function testPublicUrls(string $url): void public function testSecureUrls(string $url): void { $client = self::createClient(); - $client->request('GET', $url); + $client->request(Request::METHOD_GET, $url); $response = $client->getResponse(); $this->assertSame(Response::HTTP_FOUND, $response->getStatusCode(), $response->getContent()); $this->assertSame( @@ -41,7 +42,7 @@ public function testSecureUrls(string $url): void public function testMenuItems(string $url): void { $client = self::createClient(); - $crawler = $client->request('GET', '/'); + $crawler = $client->request(Request::METHOD_GET, '/'); $link = $crawler->filter(sprintf('a[href="%s"]', $url))->link(); $urlFound = $link->getUri(); if (false === mb_strpos($url, 'https://')) { @@ -54,7 +55,7 @@ public function testMenuItems(string $url): void public function test404(): void { $client = self::createClient(); - $client->request('GET', '/en/wrong-url'); + $client->request(Request::METHOD_GET, '/en/wrong-url'); $this->assertTrue($client->getResponse()->isNotFound()); } diff --git a/tests/Functional/Controller/PageControllerTest.php b/tests/Functional/Controller/PageControllerTest.php index e72ce154..feaa4259 100644 --- a/tests/Functional/Controller/PageControllerTest.php +++ b/tests/Functional/Controller/PageControllerTest.php @@ -7,6 +7,7 @@ use App\Entity\Page; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class PageControllerTest extends WebTestCase @@ -21,7 +22,7 @@ public function testPage(): void 'add_contact_form' => 0, ]); - $client->request('GET', sprintf('/en/info/%s', $page->getSlug())); + $client->request(Request::METHOD_GET, sprintf('/en/info/%s', $page->getSlug())); $this->assertResponseIsSuccessful(); } @@ -33,7 +34,7 @@ public function testContactPage(): void 'add_contact_form' => 1, ]); - $crawler = $client->request('GET', sprintf('/en/info/%s', $page->getSlug())); + $crawler = $client->request(Request::METHOD_GET, sprintf('/en/info/%s', $page->getSlug())); $this->assertResponseIsSuccessful(); $form = $crawler->selectButton('Submit')->form([ diff --git a/tests/Functional/Controller/PropertyControllerTest.php b/tests/Functional/Controller/PropertyControllerTest.php index 98ef4544..82aecbf3 100644 --- a/tests/Functional/Controller/PropertyControllerTest.php +++ b/tests/Functional/Controller/PropertyControllerTest.php @@ -9,6 +9,7 @@ use App\Entity\Settings; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; final class PropertyControllerTest extends WebTestCase { @@ -18,7 +19,7 @@ public function testIndex(): void { $client = $this->createClient(); $client->followRedirects(true); - $crawler = $client->request('GET', '/en/'); + $crawler = $client->request(Request::METHOD_GET, '/en/'); $this->assertTrue($client->getResponse()->isOk()); $this->assertStringContainsString('Popular Listing', $crawler->filter('h1') @@ -33,7 +34,7 @@ public function testProperty(): void 'state' => 'published', ]); - $crawler = $client->request('GET', sprintf( + $crawler = $client->request(Request::METHOD_GET, sprintf( '/en/%s/%s/%d', $property->getCity()->getSlug(), $property->getSlug(), @@ -44,7 +45,7 @@ public function testProperty(): void // Find link to City's page $link = $crawler->filter('.overview a')->link(); $uri = $link->getUri(); - $client->request('GET', $uri); + $client->request(Request::METHOD_GET, $uri); $this->assertResponseIsSuccessful(); } @@ -55,19 +56,19 @@ public function testSearch(): void $city = $repository->findOneBy(['slug' => 'miami'])->getId(); - $crawler = $client->request('GET', sprintf('/en/?city=%d&bedrooms=0', $city)); + $crawler = $client->request(Request::METHOD_GET, sprintf('/en/?city=%d&bedrooms=0', $city)); $this->assertCount(3, $crawler->filter('.property-box-img')); - $crawler = $client->request('GET', sprintf('/en/?city=%d&bedrooms=1', $city)); + $crawler = $client->request(Request::METHOD_GET, sprintf('/en/?city=%d&bedrooms=1', $city)); $this->assertCount(1, $crawler->filter('.property-box-img')); - $crawler = $client->request('GET', sprintf('/en/?city=%d&bedrooms=3', $city)); + $crawler = $client->request(Request::METHOD_GET, sprintf('/en/?city=%d&bedrooms=3', $city)); $this->assertCount(0, $crawler->filter('.property-box-img')); - $crawler = $client->request('GET', '/en/?guests=6'); + $crawler = $client->request(Request::METHOD_GET, '/en/?guests=6'); $this->assertCount(1, $crawler->filter('.property-box-img')); - $crawler = $client->request('GET', '/en/?guests=3'); + $crawler = $client->request(Request::METHOD_GET, '/en/?guests=3'); $this->assertCount(4, $crawler->filter('.property-box-img')); } @@ -77,7 +78,7 @@ public function testSearchFilter(): void $repository = $this->getRepository($client, Settings::class); // Expects 3 fields in the filter on Homepage - $crawler = $client->request('GET', '/en/'); + $crawler = $client->request(Request::METHOD_GET, '/en/'); $this->assertCount(3, $crawler->filter('.form-control')); $this->assertSelectorTextNotContains('.search_form', 'Feature'); @@ -85,7 +86,7 @@ public function testSearchFilter(): void $repository->updateSetting('show_filter_by_city', '0'); // Expects 2 fields in the filter on Homepage - $crawler = $client->request('GET', '/en/'); + $crawler = $client->request(Request::METHOD_GET, '/en/'); $this->assertCount(2, $crawler->filter('.form-control')); $this->assertSelectorTextNotContains('.search_form', 'City'); @@ -94,7 +95,7 @@ public function testSearchFilter(): void $repository->updateSetting('show_filter_by_bedrooms', '1'); // Expects 4 fields in the filter on Homepage - $crawler = $client->request('GET', '/en/'); + $crawler = $client->request(Request::METHOD_GET, '/en/'); $this->assertCount(4, $crawler->filter('.form-control')); $this->assertSelectorTextContains('.search_form', 'City'); $this->assertSelectorTextContains('.search_form', 'Bedrooms'); @@ -103,7 +104,7 @@ public function testSearchFilter(): void $repository->updateSetting('show_filter_by_bedrooms', '0'); // Expects 3 fields in the filter on Homepage - $crawler = $client->request('GET', '/en/'); + $crawler = $client->request(Request::METHOD_GET, '/en/'); $this->assertCount(3, $crawler->filter('.form-control')); $this->assertSelectorTextNotContains('.search_form', 'Bedrooms'); @@ -111,7 +112,7 @@ public function testSearchFilter(): void $repository->updateSetting('show_filter_by_features', '1'); // Expects 4 fields in the filter on Homepage - $crawler = $client->request('GET', '/'); + $crawler = $client->request(Request::METHOD_GET, '/'); $this->assertCount(4, $crawler->filter('.form-control')); $this->assertSelectorTextContains('.search_form', 'Feature'); @@ -119,7 +120,7 @@ public function testSearchFilter(): void $repository->updateSetting('show_filter_by_features', '0'); // Expects 3 fields in the filter on Homepage - $crawler = $client->request('GET', '/'); + $crawler = $client->request(Request::METHOD_GET, '/'); $this->assertCount(3, $crawler->filter('.form-control')); } } diff --git a/tests/Functional/Controller/SitemapControllerTest.php b/tests/Functional/Controller/SitemapControllerTest.php index 34ed538f..7965015f 100644 --- a/tests/Functional/Controller/SitemapControllerTest.php +++ b/tests/Functional/Controller/SitemapControllerTest.php @@ -5,6 +5,7 @@ namespace App\Tests\Functional\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; final class SitemapControllerTest extends WebTestCase { @@ -13,21 +14,21 @@ final class SitemapControllerTest extends WebTestCase public function testSitemap(): void { $client = self::createClient(); - $client->request('GET', '/en/sitemap.xml'); + $client->request(Request::METHOD_GET, '/en/sitemap.xml'); $this->assertResponseHeaderSame('Content-Type', self::CONTENT_TYPE); } public function testCitiesSitemap(): void { $client = self::createClient(); - $client->request('GET', '/en/sitemap/cities.xml'); + $client->request(Request::METHOD_GET, '/en/sitemap/cities.xml'); $this->assertResponseHeaderSame('Content-Type', self::CONTENT_TYPE); } public function testPropertiesSitemap(): void { $client = self::createClient(); - $client->request('GET', '/en/sitemap/properties.xml'); + $client->request(Request::METHOD_GET, '/en/sitemap/properties.xml'); $this->assertResponseHeaderSame('Content-Type', self::CONTENT_TYPE); } } diff --git a/tests/Functional/Controller/User/PhotoControllerTest.php b/tests/Functional/Controller/User/PhotoControllerTest.php index 88c5afd9..1c40e7f1 100644 --- a/tests/Functional/Controller/User/PhotoControllerTest.php +++ b/tests/Functional/Controller/User/PhotoControllerTest.php @@ -7,6 +7,7 @@ use App\Entity\Property; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class PhotoControllerTest extends WebTestCase @@ -22,7 +23,7 @@ public function testEditingForbidden(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['author' => $user]); - $client->request('GET', sprintf('/en/user/photo/%d/edit', $property->getId())); + $client->request(Request::METHOD_GET, sprintf('/en/user/photo/%d/edit', $property->getId())); $this->assertResponseStatusCodeSame(403); } @@ -33,7 +34,7 @@ public function testUploadPhoto(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['slug' => 'furnished-renovated-2-bedroom-2-bathroom-flat']); - $crawler = $client->request('GET', sprintf('/en/user/photo/%d/edit', $property->getId())); + $crawler = $client->request(Request::METHOD_GET, sprintf('/en/user/photo/%d/edit', $property->getId())); $this->assertResponseIsSuccessful(); $this->assertStringContainsString('Upload photos', $crawler->filter('h3')->text()); @@ -52,23 +53,23 @@ public function testSorting(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['slug' => 'interesting-two-bedroom-apartment-for-sale']); - $crawler = $client->request('GET', '/en/user/photo/'.$property->getId().'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/user/photo/'.$property->getId().'/edit'); $token = $this->getCsrfToken($crawler); $itemsArray = $property->getPhotos()->map(fn ($item) => $item->getId())->getValues(); $uri = '/en/user/photo/'.$property->getId().'/sort'; - $client->request('POST', $uri, [ + $client->request(Request::METHOD_POST, $uri, [ 'ids' => array_reverse($itemsArray), ]); $this->assertResponseStatusCodeSame(419); - $client->request('POST', $uri, [ + $client->request(Request::METHOD_POST, $uri, [ 'csrf_token' => $token, 'ids' => array_reverse($itemsArray), ]); - $client->request('POST', $uri, [ + $client->request(Request::METHOD_POST, $uri, [ 'csrf_token' => $token, 'ids' => $itemsArray, ]); @@ -90,7 +91,7 @@ public function testDeletePhoto(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['slug' => 'furnished-renovated-2-bedroom-2-bathroom-flat']); - $crawler = $client->request('GET', sprintf('/en/user/photo/%d/edit', $property->getId())); + $crawler = $client->request(Request::METHOD_GET, sprintf('/en/user/photo/%d/edit', $property->getId())); $form = $crawler->selectButton('Delete')->first()->form(); $client->submit($form); diff --git a/tests/Functional/Controller/User/ProfileControllerTest.php b/tests/Functional/Controller/User/ProfileControllerTest.php index ee1bc13c..bb6e9af2 100644 --- a/tests/Functional/Controller/User/ProfileControllerTest.php +++ b/tests/Functional/Controller/User/ProfileControllerTest.php @@ -7,6 +7,7 @@ use App\Entity\Profile; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; final class ProfileControllerTest extends WebTestCase { @@ -21,7 +22,7 @@ public function testEditProfile(): void { $client = $this->authAsUser($this); - $crawler = $client->request('GET', '/en/user/profile'); + $crawler = $client->request(Request::METHOD_GET, '/en/user/profile'); $this->assertResponseIsSuccessful(); $this->assertSelectorTextContains('h3', 'My profile'); diff --git a/tests/Functional/Controller/User/PropertyControllerTest.php b/tests/Functional/Controller/User/PropertyControllerTest.php index bafb00be..8a67da67 100644 --- a/tests/Functional/Controller/User/PropertyControllerTest.php +++ b/tests/Functional/Controller/User/PropertyControllerTest.php @@ -11,6 +11,7 @@ use App\Entity\PropertyDescription; use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; final class PropertyControllerTest extends WebTestCase @@ -20,21 +21,21 @@ final class PropertyControllerTest extends WebTestCase public function testIndex(): void { $client = $this->authAsUser($this); - $crawler = $client->request('GET', '/en/user/property'); + $crawler = $client->request(Request::METHOD_GET, '/en/user/property'); $this->assertResponseIsSuccessful(sprintf('The %s public URL loads correctly.', '/user/account')); $this->assertCount(2, $crawler->filter('.property-box-img')); $this->assertSelectorTextContains('html', 'My properties (2)'); - $client->request('GET', '/en/admin'); + $client->request(Request::METHOD_GET, '/en/admin'); $this->assertResponseStatusCodeSame(403); } public function testUnpublish(): void { $client = $this->authAsUser($this); - $crawler = $client->request('GET', '/en/user/property'); + $crawler = $client->request(Request::METHOD_GET, '/en/user/property'); $link = $crawler->filter('.btn-outline-secondary')->first()->link(); - $client->request('GET', $link->getUri()); + $client->request(Request::METHOD_GET, $link->getUri()); $this->assertResponseIsSuccessful(); // asserts that the "Content-Type" header is "application/json" @@ -55,19 +56,19 @@ public function testEditingForbidden(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['author' => $user]); - $client->request('GET', sprintf('/en/user/property/%d/update?state=private', $property->getId())); + $client->request(Request::METHOD_GET, sprintf('/en/user/property/%d/update?state=private', $property->getId())); $this->assertResponseStatusCodeSame(419); - $client->request('GET', sprintf('/en/user/property/%d/edit', $property->getId())); + $client->request(Request::METHOD_GET, sprintf('/en/user/property/%d/edit', $property->getId())); $this->assertResponseStatusCodeSame(403); } public function testPublish(): void { $client = $this->authAsUser($this); - $crawler = $client->request('GET', '/en/user/property?state=unpublished'); + $crawler = $client->request(Request::METHOD_GET, '/en/user/property?state=unpublished'); $link = $crawler->filter('.btn-outline-secondary')->first()->link(); - $client->request('GET', $link->getUri()); + $client->request(Request::METHOD_GET, $link->getUri()); $this->assertResponseIsSuccessful(); // asserts that the "Content-Type" header is "application/json" @@ -85,7 +86,7 @@ public function testNewProperty(): void $client = $this->authAsUser($this); $this->updateSettings($client, ['allow_html' => '0']); - $crawler = $client->request('GET', '/en/user/property/new'); + $crawler = $client->request(Request::METHOD_GET, '/en/user/property/new'); $city = $this->getRepository($client, City::class) ->findOneBy(['slug' => 'miami'])->getId(); @@ -118,7 +119,7 @@ public function testEditPhoto(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['slug' => 'added-by-user'])->getId(); - $crawler = $client->request('GET', '/en/user/photo/'.$property.'/edit'); + $crawler = $client->request(Request::METHOD_GET, '/en/user/photo/'.$property.'/edit'); $this->assertSelectorTextContains('html', 'Upload photos'); $photo = __DIR__.'/../../../../public/images/bg.jpg'; @@ -141,7 +142,7 @@ public function testEditProperty(): void $this->assertSame('Lorem ipsum dolor sit amet', $property->getPropertyDescription()->getContent()); - $crawler = $client->request('GET', sprintf('/en/user/property/%d/edit', $property->getId())); + $crawler = $client->request(Request::METHOD_GET, sprintf('/en/user/property/%d/edit', $property->getId())); $this->assertResponseIsSuccessful(); $form = $crawler->selectButton('Save changes')->form([ @@ -154,7 +155,7 @@ public function testEditProperty(): void $editedProperty = $this->getRepository($client, PropertyDescription::class) ->findOneBy(['meta_title' => 'Custom Meta Title'])->getProperty(); - $client->request('GET', sprintf('/en/user/property/%d/edit', $editedProperty->getId())); + $client->request(Request::METHOD_GET, sprintf('/en/user/property/%d/edit', $editedProperty->getId())); $this->assertResponseIsSuccessful(); } @@ -165,7 +166,7 @@ public function testDeleteProperty(): void $property = $this->getRepository($client, Property::class) ->findOneBy(['slug' => 'added-by-user'])->getId(); - $crawler = $client->request('GET', '/en/admin/property?sort_by=id'); + $crawler = $client->request(Request::METHOD_GET, '/en/admin/property?sort_by=id'); $client->submit($crawler->filter('#delete-form-'.$property)->form()); $this->assertSame( diff --git a/tests/Functional/Controller/User/Security/GoogleAuthenticatorControllerTest.php b/tests/Functional/Controller/User/Security/GoogleAuthenticatorControllerTest.php index 2458b12a..d85b1e4e 100644 --- a/tests/Functional/Controller/User/Security/GoogleAuthenticatorControllerTest.php +++ b/tests/Functional/Controller/User/Security/GoogleAuthenticatorControllerTest.php @@ -9,6 +9,7 @@ use Coderberg\GoogleAuthenticator; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; final class GoogleAuthenticatorControllerTest extends WebTestCase { @@ -22,15 +23,15 @@ public function testAuthCodeWithoutCsrfToken(): void { $client = $this->authAsUser($this); - $client->request('GET', self::ENDPOINT, []); + $client->request(Request::METHOD_GET, self::ENDPOINT, []); $this->assertResponseStatusCodeSame(419); $this->assertJson($client->getResponse()->getContent()); - $client->request('PUT', self::ENDPOINT, []); + $client->request(Request::METHOD_PUT, self::ENDPOINT, []); $this->assertResponseStatusCodeSame(419); $this->assertJson($client->getResponse()->getContent()); - $client->request('DELETE', self::ENDPOINT, []); + $client->request(Request::METHOD_DELETE, self::ENDPOINT, []); $this->assertResponseStatusCodeSame(419); $this->assertJson($client->getResponse()->getContent()); } @@ -40,7 +41,7 @@ public function testGetAuthCode(): void $client = $this->authAsUser($this); $token = $this->getToken($client); $this->assertNotEmpty($token); - $client->request('GET', self::ENDPOINT, [ + $client->request(Request::METHOD_GET, self::ENDPOINT, [ 'csrf_token' => $token, ]); $this->assertResponseIsSuccessful(); @@ -58,7 +59,7 @@ public function testSetInvalidAuthCode(): void // Send empty data $client = $this->authAsUser($this); $token = $this->getToken($client); - $client->request('PUT', self::ENDPOINT, [ + $client->request(Request::METHOD_PUT, self::ENDPOINT, [ 'csrf_token' => $token, ]); $this->assertResponseIsUnprocessable(); @@ -67,7 +68,7 @@ public function testSetInvalidAuthCode(): void $this->assertContainsWords($response, ['Cannot enable Google Authenticator']); // Set wrong data - $client->request('PUT', self::ENDPOINT, [ + $client->request(Request::METHOD_PUT, self::ENDPOINT, [ 'secret' => self::SECRET, 'authentication_code' => random_int(100000, 999999), 'csrf_token' => $token, @@ -90,7 +91,7 @@ public function testSetAuthCode(): void $ga = new GoogleAuthenticator(); $oneTimePassword = $ga->getCode(self::SECRET); - $client->request('PUT', self::ENDPOINT, [ + $client->request(Request::METHOD_PUT, self::ENDPOINT, [ 'secret' => self::SECRET, 'authentication_code' => $oneTimePassword, 'csrf_token' => $token, @@ -110,7 +111,7 @@ public function testDeleteAuthCode(): void $client = $this->authAsUser($this); $token = $this->getToken($client); - $client->request('DELETE', self::ENDPOINT, [ + $client->request(Request::METHOD_DELETE, self::ENDPOINT, [ 'csrf_token' => $token, ]); @@ -125,7 +126,7 @@ public function testDeleteAuthCode(): void private function getToken(KernelBrowser $client): string { - $crawler = $client->request('GET', '/en/user/security'); + $crawler = $client->request(Request::METHOD_GET, '/en/user/security'); return $crawler->filter('[name="auth_token"]')->attr('value'); } diff --git a/tests/Functional/Controller/User/Security/PasswordControllerTest.php b/tests/Functional/Controller/User/Security/PasswordControllerTest.php index c6f9f4dd..23585331 100644 --- a/tests/Functional/Controller/User/Security/PasswordControllerTest.php +++ b/tests/Functional/Controller/User/Security/PasswordControllerTest.php @@ -7,6 +7,7 @@ use App\Tests\Helper\WebTestHelper; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; final class PasswordControllerTest extends WebTestCase { @@ -18,7 +19,7 @@ final class PasswordControllerTest extends WebTestCase public function testPasswordChangeWithoutToken(): void { $client = $this->authAsUser($this); - $client->request('POST', self::ENDPOINT, []); + $client->request(Request::METHOD_POST, self::ENDPOINT, []); $this->assertResponseStatusCodeSame(419); $this->isJson(); } @@ -29,7 +30,7 @@ public function testInvalidPassword(): void $token = $this->getToken($client); // Try too short password - $client->request('POST', self::ENDPOINT, [ + $client->request(Request::METHOD_POST, self::ENDPOINT, [ 'password1' => mb_substr(self::TEMP_PASSWORD, 0, -6), 'password2' => self::TEMP_PASSWORD, 'csrf_token' => $token, @@ -38,7 +39,7 @@ public function testInvalidPassword(): void $this->assertResponseIsUnprocessable(); // Try mismatched passwords - $client->request('POST', self::ENDPOINT, [ + $client->request(Request::METHOD_POST, self::ENDPOINT, [ 'password1' => self::TEMP_PASSWORD, 'password2' => mb_substr(self::TEMP_PASSWORD, 0, -6), 'csrf_token' => $token, @@ -52,7 +53,7 @@ public function testPasswordChange(): void $client = $this->authAsUser($this); $token = $this->getToken($client); $this->assertNotEmpty($token); - $client->request('POST', self::ENDPOINT, [ + $client->request(Request::METHOD_POST, self::ENDPOINT, [ 'password1' => self::TEMP_PASSWORD, 'password2' => self::TEMP_PASSWORD, 'csrf_token' => $token, @@ -63,7 +64,7 @@ public function testPasswordChange(): void private function getToken(KernelBrowser $client): string { - $crawler = $client->request('GET', '/en/user/security'); + $crawler = $client->request(Request::METHOD_GET, '/en/user/security'); return $crawler->filter('[name="password_token"]')->attr('value'); }