[Bug]: Possible missing mutation.
Open
Nobody has claimed this yet.
bug
- Dominant language
- PHP
- Stars
- 11.7k
- Forks
- 538
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 8
Description
What Happened
I think I don't fully understand this but given
<?php
// Product.php
namespace App;
class Product
{
public function __construct(
public string $name,
public float $price,
public int $stock
) {}
public function isInStock(): bool
{
return $this->stock > 0;
}
}
// tests/ProductTest.php
namespace Tests;
use App\Product;
test('product shows correct stock status', function () {
$inStock = new Product('In Stock', 100, 5);
// $outOfStock = new Product('Out of Stock', 100, 0);
expect($inStock->isInStock())->toBeTrue();
// This assertion is commented out but mutation testing still shows 100% coverage
// expect($outOfStock->isInStock())->toBeFalse();
});
How to Reproduce
Running ./vendor/bin/pest --mutate doesn't return the case of a product with no stock and reaches 100% mutation score without the
expect($outOfStock->isInStock())->toBeFalse(); expectation
Sample Repository
No response
Pest Version
3.7.1
PHP Version
8.3
Operation System
macOS
Notes
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running ./vendor/bin/pest --mutate against the Product.php and tests/ProductTest.php example, then inspect the mutation report for the isInStock() case with stock set to zero. Compare the result with the commented assertion and document or test the expected mutation-testing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100