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
108 lines
3.3 KiB
PHP
108 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
|
use App\Entity\Project\Project;
|
|
use App\Entity\Project\ProjectDeadline;
|
|
use App\Entity\Project\ProjectStatus;
|
|
use App\Entity\User\User;
|
|
use App\Factory\Project\ProjectFactory;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Zenstruck\Foundry\Test\Factories;
|
|
use Zenstruck\Foundry\Test\ResetDatabase;
|
|
|
|
class ProjectCalendarTest extends ApiTestCase
|
|
{
|
|
use ResetDatabase;
|
|
use Factories;
|
|
|
|
private EntityManagerInterface $entityManager;
|
|
private User $owner;
|
|
|
|
public function setUp(): void
|
|
{
|
|
self::bootKernel();
|
|
$this->entityManager = static::getContainer()->get(EntityManagerInterface::class);
|
|
|
|
$this->owner = $this->createTestUser();
|
|
$this->entityManager->persist($this->owner);
|
|
$this->entityManager->flush();
|
|
}
|
|
|
|
private function createTestUser(string $handle = 'test_user', string $email = 'testuser@example.com'): User
|
|
{
|
|
$user = new User();
|
|
$user->setHandle($handle);
|
|
$user->setEmail($email);
|
|
$user->setPassword('projectapitestpassword');
|
|
|
|
return $user;
|
|
}
|
|
|
|
private function createTestProject(ProjectDeadline $deadline = ProjectDeadline::Minimum): Project
|
|
{
|
|
return ProjectFactory::createOne([
|
|
'owner' => $this->owner,
|
|
'deadline' => $deadline,
|
|
])->_real();
|
|
}
|
|
|
|
private function createProjectAndSetToInCampaign(
|
|
ProjectDeadline $deadline = ProjectDeadline::Minimum,
|
|
): Project {
|
|
$project = $this->createTestProject($deadline);
|
|
|
|
$this->entityManager->persist($project);
|
|
$this->entityManager->flush();
|
|
|
|
$project->setStatus(ProjectStatus::InCampaign);
|
|
$this->entityManager->flush();
|
|
|
|
return $project;
|
|
}
|
|
|
|
public function testReleaseDateUpdatesOnCampaignStart(): void
|
|
{
|
|
$project = $this->createProjectAndSetToInCampaign();
|
|
|
|
$this->assertNotNull($project->getCalendar()->release);
|
|
}
|
|
|
|
public function testMinimumDeadlineIsSetCorrectly(): void
|
|
{
|
|
$project = $this->createProjectAndSetToInCampaign(ProjectDeadline::Minimum);
|
|
|
|
$releaseDate = $project->getCalendar()->release;
|
|
$minimumDeadline = $project->getCalendar()->minimum;
|
|
|
|
$this->assertNotNull($minimumDeadline);
|
|
$this->assertGreaterThan($releaseDate, $minimumDeadline);
|
|
$this->assertEquals($releaseDate->modify('+40 days'), $minimumDeadline);
|
|
}
|
|
|
|
public function testOptimumDeadlineIsSetCorrectly(): void
|
|
{
|
|
$project = $this->createProjectAndSetToInCampaign(ProjectDeadline::Optimum);
|
|
|
|
$minimumDeadline = $project->getCalendar()->minimum;
|
|
$optimumDeadline = $project->getCalendar()->optimum;
|
|
|
|
$this->assertNotNull($optimumDeadline);
|
|
$this->assertGreaterThan($minimumDeadline, $optimumDeadline);
|
|
$this->assertEquals($minimumDeadline->modify('+40 days'), $optimumDeadline);
|
|
}
|
|
|
|
public function testProjectNotInCampaignHasNoCalendar(): void
|
|
{
|
|
$project = $this->createTestProject();
|
|
|
|
$this->entityManager->persist($project);
|
|
$this->entityManager->flush();
|
|
|
|
$this->assertNull($project->getCalendar()->release);
|
|
$this->assertNull($project->getCalendar()->minimum);
|
|
$this->assertNull($project->getCalendar()->optimum);
|
|
}
|
|
}
|