Skip to content

Commit

Permalink
Apply fixes from Rector
Browse files Browse the repository at this point in the history
  • Loading branch information
Coderberg committed Jun 20, 2024
1 parent 4edec3b commit bc9186b
Show file tree
Hide file tree
Showing 30 changed files with 166 additions and 141 deletions.
7 changes: 4 additions & 3 deletions tests/Functional/Controller/Admin/CategoryControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions tests/Functional/Controller/Admin/CityControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions tests/Functional/Controller/Admin/CurrencyControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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'));
}
}
7 changes: 4 additions & 3 deletions tests/Functional/Controller/Admin/DealTypeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions tests/Functional/Controller/Admin/DistrictControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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([
Expand Down
7 changes: 4 additions & 3 deletions tests/Functional/Controller/Admin/FeatureControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 8 additions & 7 deletions tests/Functional/Controller/Admin/MenuControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -90,26 +91,26 @@ 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();

$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,
]);
Expand All @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions tests/Functional/Controller/Admin/MetroControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions tests/Functional/Controller/Admin/PageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
Loading

0 comments on commit bc9186b

Please sign in to comment.