Skip to content

Commit

Permalink
Marked the purchasable as nullable in the model
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Jan 13, 2025
1 parent 64dc6d0 commit d5c2645
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Models/CustomerPurchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* @property Carbon $purchase_date
* @property float $purchase_value
* @property string $currency
* @property int $purchasable_id
* @property string $purchasable_type
* @property int|null $purchasable_id
* @property string|null $purchasable_type
*
* @property-read Model $purchasable
* @property-read Model|null $purchasable
* @property-read Customer $customer
*/
class CustomerPurchase extends Model implements CustomerPurchaseContract
Expand Down
14 changes: 14 additions & 0 deletions tests/CustomerPurchaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ class CustomerPurchaseTest extends TestCase
* @test
*/
public function customer_purchase_can_be_created_with_minimal_data(): void
{
$customer = CustomerProxy::create([])->fresh();

$customerPurchase = CustomerPurchaseProxy::create([
'customer_id' => $customer->id,
])->fresh();

$this->assertTrue($customer->is($customerPurchase->customer));
}

/**
* @test
*/
public function customer_purchase_can_be_created_with_a_customer_and_a_purchasable(): void
{
$order = Order::create([
'number' => '70H-0WJB-2OD6'
Expand Down

0 comments on commit d5c2645

Please sign in to comment.