Increase code coverage for Git namespace

This commit is contained in:
Claudio Zizza
2023-09-06 00:49:24 +02:00
parent 0f6f8e57c9
commit d5a6e00376
2 changed files with 60 additions and 24 deletions

View File

@@ -100,6 +100,13 @@ class TagBranchGuesserTest extends TestCase
self::assertSame('2.0', $this->tagBranchGuesser->generateTagBranchSlug($tag));
}
public function testGenerateTagBranchSlugWithNonNumericTag(): void
{
$tag = new Tag('my.dev', new DateTimeImmutable());
self::assertSame(null, $this->tagBranchGuesser->generateTagBranchSlug($tag));
}
protected function setUp(): void
{
$this->processFactory = $this->createMock(ProcessFactory::class);

View File

@@ -10,37 +10,52 @@ use Doctrine\Website\Tests\TestCase;
class TagTest extends TestCase
{
private DateTimeImmutable $date;
private string $name;
private Tag $tag;
public function testGetName(): void
{
self::assertSame('v1.0.0', $this->tag->getName());
$tag = new Tag(
'v1.0.0',
$this->createDateTimeImmtable(),
);
self::assertSame('v1.0.0', $tag->getName());
}
public function testGetDate(): void
{
self::assertSame($this->date, $this->tag->getDate());
$date = $this->createDateTimeImmtable();
$tag = new Tag(
'v1.0.0',
$date,
);
self::assertSame($date, $tag->getDate());
}
public function testGetComposerRequireVersionString(): void
{
self::assertSame('1.0.0', $this->tag->getComposerRequireVersionString());
$tag = new Tag(
'v1.0.0',
$this->createDateTimeImmtable(),
);
self::assertSame('1.0.0', $tag->getComposerRequireVersionString());
}
public function testIsPreComposer(): void
{
self::assertTrue($this->tag->isPreComposer());
$tag = new Tag(
'v1.0.0',
$this->createDateTimeImmtable(),
);
self::assertTrue($tag->isPreComposer());
}
public function testStableStability(): void
{
$tag = new Tag(
'v1.0.0',
new DateTimeImmutable('1985-09-01'),
$this->createDateTimeImmtable(),
);
self::assertSame('stable', $tag->getStability());
@@ -50,7 +65,7 @@ class TagTest extends TestCase
{
$tag = new Tag(
'v1.0.0-alpha1',
new DateTimeImmutable('1985-09-01'),
$this->createDateTimeImmtable(),
);
self::assertSame('alpha', $tag->getStability());
@@ -60,7 +75,7 @@ class TagTest extends TestCase
{
$tag = new Tag(
'v1.0.0-beta1',
new DateTimeImmutable('1985-09-01'),
$this->createDateTimeImmtable(),
);
self::assertSame('beta', $tag->getStability());
@@ -70,7 +85,7 @@ class TagTest extends TestCase
{
$tag = new Tag(
'v1.0.0-rc1',
new DateTimeImmutable('1985-09-01'),
$this->createDateTimeImmtable(),
);
self::assertSame('rc', $tag->getStability());
@@ -80,7 +95,7 @@ class TagTest extends TestCase
{
$tag = new Tag(
'v0.0.1',
new DateTimeImmutable('1985-09-01'),
$this->createDateTimeImmtable(),
);
self::assertSame('dev', $tag->getStability());
@@ -90,7 +105,7 @@ class TagTest extends TestCase
{
$tag = new Tag(
'v0.0.1',
new DateTimeImmutable('1985-09-01'),
$this->createDateTimeImmtable(),
);
self::assertTrue($tag->isMajorReleaseZero());
@@ -100,20 +115,34 @@ class TagTest extends TestCase
{
$tag = new Tag(
'v1.0.1',
new DateTimeImmutable('1985-09-01'),
$this->createDateTimeImmtable(),
);
self::assertFalse($tag->isMajorReleaseZero());
}
protected function setUp(): void
public function testGetSlug(): void
{
$this->date = new DateTimeImmutable('1985-09-01');
$this->name = 'v1.0.0';
$this->tag = new Tag(
$this->name,
$this->date,
$tag = new Tag(
'v1.0.0',
$this->createDateTimeImmtable(),
);
self::assertSame('1.0.0', $tag->getSlug());
}
public function testGetDisplayName(): void
{
$tag = new Tag(
'v1.0.0',
$this->createDateTimeImmtable(),
);
self::assertSame('1.0.0', $tag->getDisplayName());
}
private function createDateTimeImmtable(): DateTimeImmutable
{
return new DateTimeImmutable('1985-09-01');
}
}