Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 33 additions & 35 deletions tests/Subscriber/StatusChangeByCommentSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,43 +61,41 @@ public function testOnIssueComment($comment, $expectedStatus)
}

/**
* @return array<array{string, string|null}>
* @return iterable<array{string, string|null}>
*/
public static function getCommentsForStatusChange(): array
public static function getCommentsForStatusChange(): iterable
{
return [
['Have a great day!', null],
// basic tests for status change
['Status: needs review', Status::NEEDS_REVIEW],
['Status: needs work', Status::NEEDS_WORK],
['Status: reviewed', Status::REVIEWED],
// accept quotes
['Status: "reviewed"', Status::REVIEWED],
["Status: 'reviewed'", Status::REVIEWED],
// accept trailing punctuation
['Status: works for me!', Status::WORKS_FOR_ME],
['Status: works for me.', Status::WORKS_FOR_ME],
// play with different formatting
['STATUS: REVIEWED', Status::REVIEWED],
['**Status**: reviewed', Status::REVIEWED],
['**Status:** reviewed', Status::REVIEWED],
['**Status: reviewed**', Status::REVIEWED],
['**Status: reviewed!**', Status::REVIEWED],
['**Status: reviewed**.', Status::REVIEWED],
['Status:reviewed', Status::REVIEWED],
['Status: reviewed', Status::REVIEWED],
// reject missing colon
['Status reviewed', null],
// multiple matches - use the last one
["Status: needs review \r\n that is what the issue *was* marked as.\r\n Status: reviewed", Status::REVIEWED],
// "needs review" does not come directly after status: , so there is no status change
['Here is my status: I\'m really happy! I realize this needs review, but I\'m, having too much fun Googling cats!', null],
// reject if the status is not on a line of its own
// use case: someone posts instructions about how to change a status
// in a comment
['You should include e.g. the line `Status: needs review` in your comment', null],
['Before the ticket was in state "Status: reviewed", but then the status was changed', null],
];
yield ['Have a great day!', null];
// basic tests for status change
yield ['Status: needs review', Status::NEEDS_REVIEW];
yield ['Status: needs work', Status::NEEDS_WORK];
yield ['Status: reviewed', Status::REVIEWED];
// accept quotes
yield ['Status: "reviewed"', Status::REVIEWED];
yield ["Status: 'reviewed'", Status::REVIEWED];
// accept trailing punctuation
yield ['Status: works for me!', Status::WORKS_FOR_ME];
yield ['Status: works for me.', Status::WORKS_FOR_ME];
// play with different formatting
yield ['STATUS: REVIEWED', Status::REVIEWED];
yield ['**Status**: reviewed', Status::REVIEWED];
yield ['**Status:** reviewed', Status::REVIEWED];
yield ['**Status: reviewed**', Status::REVIEWED];
yield ['**Status: reviewed!**', Status::REVIEWED];
yield ['**Status: reviewed**.', Status::REVIEWED];
yield ['Status:reviewed', Status::REVIEWED];
yield ['Status: reviewed', Status::REVIEWED];
// reject missing colon
yield ['Status reviewed', null];
// multiple matches - use the last one
yield ["Status: needs review \r\n that is what the issue *was* marked as.\r\n Status: reviewed", Status::REVIEWED];
// "needs review" does not come directly after status: , so there is no status change
yield ['Here is my status: I\'m really happy! I realize this needs review, but I\'m, having too much fun Googling cats!', null];
// reject if the status is not on a line of its own
// use case: someone posts instructions about how to change a status
// in a comment
yield ['You should include e.g. the line `Status: needs review` in your comment', null];
yield ['Before the ticket was in state "Status: reviewed", but then the status was changed', null];
}

public function testOnIssueCommentAuthorSelfReview(): void
Expand Down
68 changes: 33 additions & 35 deletions tests/Subscriber/StatusChangeByReviewSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,43 +65,41 @@ public function testOnReview($comment, $expectedStatus)
}

/**
* @return array<array{string, string|null}>
* @return iterable<array{string, string|null}>
*/
public static function getCommentsForStatusChange(): array
public static function getCommentsForStatusChange(): iterable
{
return [
['Have a great day!', null],
// basic tests for status change
['Status: needs review', Status::NEEDS_REVIEW],
['Status: needs work', Status::NEEDS_WORK],
['Status: reviewed', Status::REVIEWED],
// accept quotes
['Status: "reviewed"', Status::REVIEWED],
["Status: 'reviewed'", Status::REVIEWED],
// accept trailing punctuation
['Status: works for me!', Status::WORKS_FOR_ME],
['Status: works for me.', Status::WORKS_FOR_ME],
// play with different formatting
['STATUS: REVIEWED', Status::REVIEWED],
['**Status**: reviewed', Status::REVIEWED],
['**Status:** reviewed', Status::REVIEWED],
['**Status: reviewed**', Status::REVIEWED],
['**Status: reviewed!**', Status::REVIEWED],
['**Status: reviewed**.', Status::REVIEWED],
['Status:reviewed', Status::REVIEWED],
['Status: reviewed', Status::REVIEWED],
// reject missing colon
['Status reviewed', null],
// multiple matches - use the last one
["Status: needs review \r\n that is what the issue *was* marked as.\r\n Status: reviewed", Status::REVIEWED],
// "needs review" does not come directly after status: , so there is no status change
['Here is my status: I\'m really happy! I realize this needs review, but I\'m, having too much fun Googling cats!', null],
// reject if the status is not on a line of its own
// use case: someone posts instructions about how to change a status
// in a comment
['You should include e.g. the line `Status: needs review` in your comment', null],
['Before the ticket was in state "Status: reviewed", but then the status was changed', null],
];
yield ['Have a great day!', null];
// basic tests for status change
yield ['Status: needs review', Status::NEEDS_REVIEW];
yield ['Status: needs work', Status::NEEDS_WORK];
yield ['Status: reviewed', Status::REVIEWED];
// accept quotes
yield ['Status: "reviewed"', Status::REVIEWED];
yield ["Status: 'reviewed'", Status::REVIEWED];
// accept trailing punctuation
yield ['Status: works for me!', Status::WORKS_FOR_ME];
yield ['Status: works for me.', Status::WORKS_FOR_ME];
// play with different formatting
yield ['STATUS: REVIEWED', Status::REVIEWED];
yield ['**Status**: reviewed', Status::REVIEWED];
yield ['**Status:** reviewed', Status::REVIEWED];
yield ['**Status: reviewed**', Status::REVIEWED];
yield ['**Status: reviewed!**', Status::REVIEWED];
yield ['**Status: reviewed**.', Status::REVIEWED];
yield ['Status:reviewed', Status::REVIEWED];
yield ['Status: reviewed', Status::REVIEWED];
// reject missing colon
yield ['Status reviewed', null];
// multiple matches - use the last one
yield ["Status: needs review \r\n that is what the issue *was* marked as.\r\n Status: reviewed", Status::REVIEWED];
// "needs review" does not come directly after status: , so there is no status change
yield ['Here is my status: I\'m really happy! I realize this needs review, but I\'m, having too much fun Googling cats!', null];
// reject if the status is not on a line of its own
// use case: someone posts instructions about how to change a status
// in a comment
yield ['You should include e.g. the line `Status: needs review` in your comment', null];
yield ['Before the ticket was in state "Status: reviewed", but then the status was changed', null];
}

#[DataProviderExternal(ValidCommandProvider::class, 'get')]
Expand Down
14 changes: 6 additions & 8 deletions tests/Subscriber/StatusChangeOnPushSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@ public function testOnPushingCommits($currentStatus, $statusChange)
}

/**
* @return array<array{string, string|null}>
* @return iterable<array{string, string|null}>
*/
public static function getStatuses(): array
public static function getStatuses(): iterable
{
return [
[Status::NEEDS_WORK, Status::NEEDS_REVIEW],
[Status::REVIEWED, null],
[Status::WORKS_FOR_ME, null],
[Status::NEEDS_REVIEW, null],
];
yield [Status::NEEDS_WORK, Status::NEEDS_REVIEW];
yield [Status::REVIEWED, null];
yield [Status::WORKS_FOR_ME, null];
yield [Status::NEEDS_REVIEW, null];
}

public function testOnNonPushPullRequestEvent()
Expand Down