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

[Bug]: Possible missing mutation. #1333

Open
cAstraea opened this issue Dec 26, 2024 · 0 comments
Open

[Bug]: Possible missing mutation. #1333

cAstraea opened this issue Dec 26, 2024 · 0 comments
Labels

Comments

@cAstraea
Copy link

cAstraea commented Dec 26, 2024

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

@cAstraea cAstraea added the bug label Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant