Skip to content

Commit 037a6c9

Browse files
committed
Code style fixes in functional tests
1 parent 4f9615f commit 037a6c9

4 files changed

Lines changed: 26 additions & 14 deletions

File tree

tests/FunctionalTests/Controller/Dashboard/DashboardPackagesControllerTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ public function testAddMirroring(): void
2424
$registry = $client->getContainer()->get(RegistryRepository::class)->findOneBy(['name' => 'Packagist']);
2525

2626
$client->request('GET', '/packages/add-mirroring');
27+
28+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
29+
2730
$client->submitForm('Add packages', [
2831
'package_add_mirroring_form[packages]' => 'psr/cache',
2932
'package_add_mirroring_form[registry]' => $registry->getId(),
3033
]);
3134

32-
$this->assertResponseStatusCodeSame(200);
35+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
3336

3437
// todo the submit request should be invoked with ajax, and this assertion should be performed on the initial request
3538
// however, the assertion is performed on the ajax response making it invalid
@@ -54,11 +57,14 @@ public function testAddVcsRepository(): void
5457
$this->loginUser('admin');
5558

5659
$client->request('GET', '/packages/add-vcs');
60+
61+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
62+
5763
$client->submitForm('Add VCS repository', [
5864
'package_add_vcs_form[repositoryUrl]' => 'https://github.com/php-fig/container',
5965
]);
6066

61-
$this->assertResponseStatusCodeSame(302);
67+
$this->assertResponseStatusCodeSame(Response::HTTP_FOUND);
6268

6369
/** @var PackageRepository $packageRepository */
6470
$packageRepository = $client->getContainer()->get(PackageRepository::class);
@@ -75,9 +81,12 @@ public function testEdit(): void
7581
$this->loginUser('admin');
7682

7783
$client->request('GET', '/packages/psr/log/edit');
84+
85+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
86+
7887
$client->submitForm('Save changes');
7988

80-
$this->assertResponseStatusCodeSame(302);
89+
$this->assertResponseStatusCodeSame(Response::HTTP_FOUND);
8190
}
8291

8392
public function testDelete(): void

tests/FunctionalTests/Controller/Dashboard/DashboardPackagesInfoControllerTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use CodedMonkey\Dirigent\Doctrine\Repository\UserRepository;
88
use CodedMonkey\Dirigent\Tests\FunctionalTests\WebTestCaseTrait;
99
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
10+
use Symfony\Component\HttpFoundation\Response;
1011

1112
class DashboardPackagesInfoControllerTest extends WebTestCase
1213
{
@@ -19,7 +20,7 @@ public function testInfo(): void
1920

2021
$client->request('GET', '/packages/psr/log');
2122

22-
$this->assertResponseStatusCodeSame(200);
23+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
2324
}
2425

2526
public function testPackageInfo(): void
@@ -29,7 +30,7 @@ public function testPackageInfo(): void
2930

3031
$client->request('GET', '/packages/psr/log/v/1.0.0');
3132

32-
$this->assertResponseStatusCodeSame(200);
33+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
3334
}
3435

3536
public function testVersions(): void
@@ -39,7 +40,7 @@ public function testVersions(): void
3940

4041
$client->request('GET', '/packages/psr/log/versions');
4142

42-
$this->assertResponseStatusCodeSame(200);
43+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
4344
}
4445

4546
public function testDependents(): void
@@ -55,7 +56,7 @@ public function testDependents(): void
5556

5657
$client->request('GET', '/packages/psr/log/dependents');
5758

58-
$this->assertResponseStatusCodeSame(200);
59+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
5960

6061
$this->assertAnySelectorTextSame('h1 small', 'Dependents');
6162
}
@@ -73,7 +74,7 @@ public function testImplementations(): void
7374

7475
$client->request('GET', '/packages/psr/log/implementations');
7576

76-
$this->assertResponseStatusCodeSame(200);
77+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
7778

7879
$this->assertAnySelectorTextSame('h1 small', 'Implementations');
7980
}
@@ -91,7 +92,7 @@ public function testProviders(): void
9192

9293
$client->request('GET', '/packages/psr/log/providers');
9394

94-
$this->assertResponseStatusCodeSame(200);
95+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
9596

9697
$this->assertAnySelectorTextSame('h1 small', 'Providers');
9798
}
@@ -109,7 +110,7 @@ public function testSuggesters(): void
109110

110111
$client->request('GET', '/packages/psr/log/suggesters');
111112

112-
$this->assertResponseStatusCodeSame(200);
113+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
113114

114115
$this->assertAnySelectorTextSame('h1 small', 'Suggesters');
115116
}
@@ -121,7 +122,7 @@ public function testStatistics(): void
121122

122123
$client->request('GET', '/packages/psr/log/statistics');
123124

124-
$this->assertResponseStatusCodeSame(200);
125+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
125126

126127
/** @var PackageRepository $packageRepository */
127128
$packageRepository = $client->getContainer()->get(PackageRepository::class);

tests/FunctionalTests/Controller/Dashboard/DashboardRootControllerPublicTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use CodedMonkey\Dirigent\Tests\FunctionalTests\PublicKernel;
66
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
7+
use Symfony\Component\HttpFoundation\Response;
78

89
class DashboardRootControllerPublicTest extends WebTestCase
910
{
@@ -18,7 +19,7 @@ public function testIndex(): void
1819

1920
$client->request('GET', '/');
2021

21-
$this->assertResponseStatusCodeSame(200);
22+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
2223

2324
$this->assertAnySelectorTextSame('#total_packages .display-6', '1');
2425
}

tests/FunctionalTests/Controller/Dashboard/DashboardRootControllerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use CodedMonkey\Dirigent\Kernel;
66
use CodedMonkey\Dirigent\Tests\FunctionalTests\WebTestCaseTrait;
77
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
8+
use Symfony\Component\HttpFoundation\Response;
89

910
class DashboardRootControllerTest extends WebTestCase
1011
{
@@ -17,7 +18,7 @@ public function testIndex(): void
1718

1819
$client->request('GET', '/');
1920

20-
$this->assertResponseStatusCodeSame(200);
21+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
2122

2223
$this->assertAnySelectorTextSame('#total_packages .display-6', '1');
2324
}
@@ -29,7 +30,7 @@ public function testCredits(): void
2930

3031
$client->request('GET', '/credits');
3132

32-
$this->assertResponseStatusCodeSame(200);
33+
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
3334

3435
$this->assertAnySelectorTextSame('.list-group-item div', 'v' . Kernel::VERSION);
3536
}

0 commit comments

Comments
 (0)