Skip to content

Commit

Permalink
Fixed skipping updated type in changelog formatter (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech authored Oct 14, 2021
1 parent ea91d99 commit 6b97a40
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Aeon/Automation/Release.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ public function changed() : array
return $this->sortChanges(Type::changed());
}

/**
* @return Change[]
*/
public function updated() : array
{
return $this->sortChanges(Type::updated());
}

/**
* @return Change[]
*/
Expand Down
27 changes: 27 additions & 0 deletions tests/Aeon/Automation/Tests/Mother/Changes/ChangeMother.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,31 @@ public static function commitFixed(string $sha, string $description, string $use
$description
);
}

public static function commitRemoved(string $sha, string $description, string $user) : Change
{
return new Change(
ChangesSourceMother::commit($sha, $user),
Type::removed(),
$description
);
}

public static function commitUpdated(string $sha, string $description, string $user) : Change
{
return new Change(
ChangesSourceMother::commit($sha, $user),
Type::updated(),
$description
);
}

public static function commitSecurity(string $sha, string $description, string $user) : Change
{
return new Change(
ChangesSourceMother::commit($sha, $user),
Type::security(),
$description
);
}
}
20 changes: 20 additions & 0 deletions tests/Aeon/Automation/Tests/Unit/ReleaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,24 @@ public function test_that_two_releases_with_different_changes_are_not_equal() :
$this->assertFalse($release1->isEqual($release2));
$this->assertFalse($release2->isEqual($release1));
}

public function test_detecting_all_changes() : void
{
$release = new Release('Unreleased', Day::fromString('2021-01-09'));

$release->add(new Changes(ChangeMother::commitChanged(SHAMother::random(), 'changed 1', 'user')));
$release->add(new Changes(ChangeMother::commitAdded(SHAMother::random(), 'added 1', 'user')));
$release->add(new Changes(ChangeMother::commitFixed(SHAMother::random(), 'fixed 1', 'user')));
$release->add(new Changes(ChangeMother::commitRemoved(SHAMother::random(), 'removed 1', 'user')));
$release->add(new Changes(ChangeMother::commitSecurity(SHAMother::random(), 'security 1', 'user')));
$release->add(new Changes(ChangeMother::commitUpdated(SHAMother::random(), 'updated 1', 'user')));

$this->assertCount(6, $release->changes());
$this->assertCount(1, $release->added());
$this->assertCount(1, $release->fixed());
$this->assertCount(1, $release->changed());
$this->assertCount(1, $release->security());
$this->assertCount(1, $release->removed());
$this->assertCount(1, $release->updated());
}
}

0 comments on commit 6b97a40

Please sign in to comment.