Skip to content

Commit

Permalink
Merge pull request #5391 from usu/fix/test-namespaces
Browse files Browse the repository at this point in the history
fix: test namespaces + some typos
  • Loading branch information
usu committed Jun 18, 2024
2 parents 3a7359f + 0c618d6 commit 39f93fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
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

0 comments on commit 39f93fd

Please sign in to comment.