PHPUnit / phpunit (push) Canceled after 0s
* fix: upgrade goteo/benzina to 0.6 * feat: increase Nominatim cache TTL * fix: allow long addresses for territory data * fix: build project addresses from goteo 3 territory fields * fix: handle empty strings for video sources * fix: update project drafts deadline to 2026 * feat: split project description into 4 fields * feat: bump doctrine related dependencies * feat: bump symfony related dependencies * feat: make categories work on idOrSlug * fix: allow filtering on project descBrief property * fix: update constraints on project update to allow optional updates of properties * fix: update Projects test suite to new project shape * fix: order of DROP operations in migration Version20260813171902 * fix: move accounting balance and checkout to supports listeners to onFlush events * fix: bad order of filter safeguards * chore: code style by php-cs-fixer * fix: prevent uninitialized fields on api resource from breaking AccountingVoter * fix: small bug preventing code improvements on Accounting api resource * feat: add cover property on ProjectReward resource * feat: add cover property to Project resources * feat: use video cover for project cover * feat: add migration for property cover on project and rewards * fix: small improvements on UserOwned helpers * feat: add territory to project creation * feat: mark creation fields as required * feat: add CollaborationCandidacy resource * fix: update old validations access of new types * feat: add validation for charges targetting projects not in campaign * feat: validate new collaboration candicacies are to open collaborations * feat: prevent future object access issues in SameProjectRewardChargeValidator * fix: return void on succesfull delete operations * fix: force set of isFinite property * feat: allow to filter ProjectBudgetItem by type and deadline * feat: remove example values from .env * feat: add testing encryption keys * feat: make project in BudgetItem body required * feat: add testing encryption keys to actions * feat: add collaborations property to ProjectApiResource
90 lines
2.3 KiB
PHP
90 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Entity\ProjectApi;
|
|
|
|
use App\Entity\Project\Project;
|
|
use App\Entity\Project\ProjectStatus;
|
|
|
|
class GetOneTest extends ProjectTestCase
|
|
{
|
|
// Auxiliary functions
|
|
|
|
protected function getMethod(): string
|
|
{
|
|
return 'GET';
|
|
}
|
|
|
|
private function getSerializedProject(Project $project)
|
|
{
|
|
return [
|
|
'id' => $project->getId(),
|
|
'title' => $project->getTitle(),
|
|
'subtitle' => $project->getSubtitle(),
|
|
'territory' => ['country' => $project->getTerritory()->country],
|
|
'deadline' => $project->getDeadline()->value,
|
|
'status' => $project->getStatus()->value,
|
|
];
|
|
}
|
|
|
|
private function assertProjectData(array $responseData, Project $project): void
|
|
{
|
|
$expectedData = $this->getSerializedProject($project);
|
|
|
|
$this->assertArrayHasKey('id', $responseData);
|
|
$this->assertArraySubset($expectedData, $responseData);
|
|
}
|
|
|
|
// TESTS
|
|
|
|
// Auxiliary Tests
|
|
|
|
private function testSuccessfulGetOneBase(Project $project): void
|
|
{
|
|
$response = $this->request('GET', $this->getUri(1));
|
|
|
|
$this->assertResponseIsSuccessful();
|
|
$responseData = json_decode($response->getContent(), true);
|
|
$this->assertProjectData($responseData, $project);
|
|
}
|
|
|
|
private function testGetOneFilteredByStatus(ProjectStatus $status): void
|
|
{
|
|
$project = $this->createTestProjectOptimized(1, ['status' => $status])[0];
|
|
|
|
$this->testSuccessfulGetOneBase($project);
|
|
}
|
|
|
|
// Runable Tests
|
|
|
|
public function testGetOneWithValidToken(): void
|
|
{
|
|
$project = $this->createTestProjectOptimized(1)[0];
|
|
|
|
$this->testSuccessfulGetOneBase($project);
|
|
}
|
|
|
|
public function testGetOneFilteredByStatusInFunding(): void
|
|
{
|
|
$this->testGetOneFilteredByStatus(ProjectStatus::InFunding);
|
|
}
|
|
|
|
public function testGetOneFilteredByStatusFunded(): void
|
|
{
|
|
$this->testGetOneFilteredByStatus(ProjectStatus::FundingPaid);
|
|
}
|
|
|
|
public function testGetOneUnauthorized(): void
|
|
{
|
|
$this->createTestProjectOptimized(1);
|
|
|
|
$this->request('GET', $this->getUri(1));
|
|
|
|
$this->assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testGetOneNotFound(): void
|
|
{
|
|
$this->testOneNotFound();
|
|
}
|
|
}
|