name = 'Test Range ' . uniqid(); $range->status = true; $range->order = random_int(1, 9999); $range->picture_alt = 'alt'; $range->picture_title = 'title'; $range->save(); $product = new Product([ 'range_id' => $range->id, 'name' => 'Test Product ' . uniqid(), 'brand' => ProductBrand::loue, 'invoicing_unit' => InvoicingUnit::PCE, 'sell_unit' => SellUnit::PCE, 'order_unit' => OrderUnit::PCE, 'tax_rate' => TaxRate::TVA_20, 'description' => 'Test description', 'status' => true, ]); $product->price = Money::EUR(1000); $product->short_description = 'Short test description'; $product->picture_alt = 'test alt'; $product->picture_title = 'test title'; $product->picture_large_alt = 'test alt'; $product->picture_large_title = 'test title'; $product->star = false; $product->save(); $action = new ToggleModelStar(); $input = new ToggleModelStarInput($product); // WHEN $result = $action($input); // THEN expect($result->getAttribute('star'))->toBeTrue(); $fresh = Product::query()->find($product->id); assert($fresh instanceof Product); expect($fresh->getAttribute('star'))->toBeTrue(); }); it('throws when an invalid input is passed', function (): void { // GIVEN $action = new ToggleModelStar(); $invalidInput = new class () implements ActionInput { }; // WHEN expect( /** @phpstan-ignore argument.type */ fn () => $action($invalidInput) ) // THEN ->toThrow(\InvalidArgumentException::class); }); });