Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent division by zero #15518

Merged
merged 5 commits into from Nov 24, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -41,6 +41,10 @@ public function getChannel(): ChannelInterface

public function getAverageOrderValue(): int
{
if (0 === $this->ordersCount) {
return 0;
}

return (int) round($this->ordersValue / $this->ordersCount);
}
}
Expand Up @@ -42,4 +42,10 @@ function it_has_an_average_value_of_an_order(): void
{
$this->getAverageOrderValue()->shouldReturn(2000);
}

function it_has_zero_average_order_value_when_order_count_is_zero(ChannelInterface $channel): void
{
$this->beConstructedWith(0, 0, $channel);
$this->getAverageOrderValue()->shouldReturn(0);
}
}