52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Services\ReleasePlanner;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ReleasePlannerTest extends TestCase
|
|
{
|
|
private ReleasePlanner $planner;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->planner = new ReleasePlanner;
|
|
}
|
|
|
|
public function test_stable_version_offers_patch_minor_major_without_continue_beta(): void
|
|
{
|
|
$t = $this->planner->proposedTargets('0.9.58');
|
|
|
|
$this->assertSame('0.9.59', $t['patch']);
|
|
$this->assertSame('0.10.0', $t['minor']);
|
|
$this->assertSame('1.0.0', $t['major']);
|
|
$this->assertArrayNotHasKey('continueBeta', $t);
|
|
}
|
|
|
|
public function test_beta_version_also_offers_continue_beta_of_its_base(): void
|
|
{
|
|
$t = $this->planner->proposedTargets('0.10.0-beta3');
|
|
|
|
$this->assertSame('0.10.0', $t['continueBeta']);
|
|
$this->assertSame('0.10.1', $t['patch']);
|
|
$this->assertSame('0.11.0', $t['minor']);
|
|
$this->assertSame('1.0.0', $t['major']);
|
|
}
|
|
|
|
public function test_strips_a_leading_v(): void
|
|
{
|
|
$this->assertSame('0.9.59', $this->planner->proposedTargets('v0.9.58')['patch']);
|
|
}
|
|
|
|
public function test_allowed_targets_are_the_proposed_values(): void
|
|
{
|
|
$allowed = $this->planner->allowedTargets('0.10.0-beta1');
|
|
|
|
$this->assertContains('0.10.0', $allowed); // continueBeta
|
|
$this->assertContains('0.11.0', $allowed); // minor
|
|
$this->assertNotContains('0.9.0', $allowed);
|
|
}
|
|
}
|