Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: test namespaces + some typos #5391

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions api/tests/Api/FirewallTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Api;
namespace App\Tests\Api;

use App\Tests\Api\ECampApiTestCase;
use App\Util\ParametrizedTestHelper;
use Doctrine\Bundle\DoctrineBundle\DataCollector\DoctrineDataCollector;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
Expand All @@ -26,12 +26,15 @@ class FirewallTest extends ECampApiTestCase {
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
#[DataProvider('getProtectedEnpoints')]
#[DataProvider('getProtectedEndpoints')]
public function testProtectedEndpointsDontResultInQuery(string $endpoint) {
$client = self::createBasicClient();
$client->enableProfiler();
$client->request('GET', $endpoint);

/**
* @var DoctrineDataCollector
*/
$collector = $client->getProfile()->getCollector('db');
/*
* 3 is:
Expand All @@ -42,12 +45,12 @@ public function testProtectedEndpointsDontResultInQuery(string $endpoint) {
assertThat($collector->getQueryCount(), equalTo(3));
}

public static function getProtectedEnpoints(): array {
$protectedEnpoints = array_filter(self::getEndPoints(), function (string $endpoint) {
public static function getProtectedEndpoints(): array {
$protectedEndpoints = array_filter(self::getEndPoints(), function (string $endpoint) {
return self::isProtectedByFirewall($endpoint);
});

return ParametrizedTestHelper::asParameterTestSets($protectedEnpoints);
return ParametrizedTestHelper::asParameterTestSets($protectedEndpoints);
}

/**
Expand All @@ -57,12 +60,15 @@ public static function getProtectedEnpoints(): array {
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
#[DataProvider('getUnprotectedEnpoints')]
#[DataProvider('getUnprotectedEndpoints')]
public function testUnprotectedEndpointsMayResultInQuery(string $endpoint) {
$client = self::createBasicClient();
$client->enableProfiler();
$client->request('GET', $endpoint);

/**
* @var DoctrineDataCollector
*/
$collector = $client->getProfile()->getCollector('db');
/*
* 3 is:
Expand All @@ -73,12 +79,12 @@ public function testUnprotectedEndpointsMayResultInQuery(string $endpoint) {
assertThat($collector->getQueryCount(), greaterThanOrEqual(3));
}

public static function getUnprotectedEnpoints() {
$protectedEnpoints = array_filter(self::getEndPoints(), function (string $endpoint) {
public static function getUnprotectedEndpoints() {
$protectedEndpoints = array_filter(self::getEndPoints(), function (string $endpoint) {
return !self::isProtectedByFirewall($endpoint);
});

return ParametrizedTestHelper::asParameterTestSets($protectedEnpoints);
return ParametrizedTestHelper::asParameterTestSets($protectedEndpoints);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions api/tests/HttpCache/TagCollectorTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace App\Tests\HttpCache;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Serializer\TagCollectorInterface;
use App\HttpCache\ResponseTagger;
Expand Down
Loading