Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
giggsey committed Apr 1, 2021
1 parent cdf7c35 commit 8fa3e95
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 45 deletions.
45 changes: 0 additions & 45 deletions src/Entity/Organization/Package/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ class Link
private string $constraint;

private ?string $packageId;
private ?string $packageName;

private ?string $targetPackageId;

public function __construct(
Expand All @@ -75,69 +73,26 @@ public function __construct(
$this->targetPackageId = $targetPackageId;
}

public function id(): UuidInterface
{
return $this->id;
}

public function type(): string
{
return $this->type;
}

public function setType(string $type): self
{
$this->type = $type;

return $this;
}

public function target(): string
{
return $this->target;
}

public function setTarget(string $target): self
{
$this->target = $target;

return $this;
}

public function constraint(): string
{
return $this->constraint;
}

public function setConstraint(string $constraint): self
{
$this->constraint = $constraint;

return $this;
}

public function packageId(): ?string
{
return $this->packageId;
}

public function targetPackageId(): ?string
{
return $this->targetPackageId;
}

public function packageName(): ?string
{
return $this->packageName;
}

public function setPackageName(?string $packageName): self
{
$this->packageName = $packageName;

return $this;
}

public function setOrganization(Organization $organization): void
{
if (isset($this->organization)) {
Expand Down
22 changes: 22 additions & 0 deletions tests/Unit/Entity/PackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Buddy\Repman\Tests\Unit\Entity;

use Buddy\Repman\Entity\Organization\Package;
use Buddy\Repman\Entity\Organization\Package\Link;
use Buddy\Repman\Entity\Organization\Package\Version;
use Buddy\Repman\Tests\MotherObject\PackageMother;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -40,6 +41,27 @@ public function testSyncSuccessRemovesUnencounteredVersions(): void
self::assertContains($version3, $this->package->versions());
}

public function testSyncSuccessRemovesUnencounteredLinks(): void
{
$this->package->addLink($link1 = new Link(Uuid::uuid4(), 'replaces', 'buddy-works/testone', '^1.0'));
$this->package->addLink($link2 = new Link(Uuid::uuid4(), 'replaces', 'buddy-works/testtwo', '^1.0'));
$this->package->addLink($link3 = new Link(Uuid::uuid4(), 'replaces', 'buddy-works/testthree', '^1.0'));

$this->package->syncSuccess(
'some/package',
'desc',
'1.1.0',
[],
['replaces-buddy-works/testone', 'replaces-buddy-works/testthree'],
new \DateTimeImmutable()
);

self::assertCount(2, $this->package->links());
self::assertContains($link1, $this->package->links());
self::assertNotContains($link2, $this->package->links());
self::assertContains($link3, $this->package->links());
}

public function testOuathTokenNotFound(): void
{
$this->expectException(\RuntimeException::class);
Expand Down

0 comments on commit 8fa3e95

Please sign in to comment.