Skip to content

Commit

Permalink
ConfigurableModel::hasConfiguration() returns false on empty arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Jul 24, 2024
1 parent 714ff66 commit 4ddbfd8
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 11 deletions.
14 changes: 14 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## 4.x Series

## Unreleased
##### 2024-XX-YY

- Changed the `ConfigurableModel::hasConfiguration()` trait to return false on empty arrays as well
(until now, only `null` was considered as no config). It affects the following models:
- `Carrier`
- `CartItem`
- `Channel`
- `OrderItem`
- `PaymentMethod`
- `Shipment`
- `ShippingMethod`
- `TaxRate`

## 4.1.0
##### 2024-07-11

Expand Down
5 changes: 5 additions & 0 deletions src/Cart/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 4.x Series

## Unreleased
##### 2024-XX-YY

- Changed `CartItem::hasConfiguration()` to return false on empty arrays as well

## 4.1.0
##### 2024-07-11

Expand Down
2 changes: 1 addition & 1 deletion src/Cart/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"konekt/enum": "^4.2",
"laravel/framework": "^10.43|^11.0",
"vanilo/contracts": "^4.0",
"vanilo/support": "^4.0"
"vanilo/support": "^4.2"
},
"require-dev": {
"ext-sqlite3": "*",
Expand Down
5 changes: 5 additions & 0 deletions src/Channel/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 4.x Series

## Unreleased
##### 2024-XX-YY

- Changed `Channel::hasConfiguration()` to return false on empty arrays as well

## 4.1.0
##### 2024-07-11

Expand Down
2 changes: 1 addition & 1 deletion src/Channel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"konekt/concord": "^1.13",
"cviebrock/eloquent-sluggable": "^10.0|^11.0",
"laravel/framework": "^10.43|^11.0",
"vanilo/support": "^4.0"
"vanilo/support": "^4.2"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Checkout/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"konekt/concord": "^1.13",
"konekt/enum": "^4.2",
"laravel/framework": "^10.43|^11.0",
"vanilo/support": "^4.0",
"vanilo/support": "^4.2",
"vanilo/contracts": "^4.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/MasterProduct/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"laravel/framework": "^10.43|^11.0",
"vanilo/contracts": "^4.0",
"vanilo/product": "^4.0",
"vanilo/support": "^4.0"
"vanilo/support": "^4.2"
},
"suggest": {
"vanilo/properties": "Allows establishing variants based on properties like color, size, etc"
Expand Down
5 changes: 5 additions & 0 deletions src/Order/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 4.x Series

## Unreleased
##### 2024-XX-YY

- Changed `OrderItem::hasConfiguration()` to return false on empty arrays as well

## 4.1.0
##### 2024-07-11

Expand Down
22 changes: 21 additions & 1 deletion src/Order/Tests/OrderItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function product_can_be_added_to_order_item()
}

/** @test */
public function order_items_can_be_configured()
public function it_can_be_configured()
{
$order = Order::create([
'number' => 'WYHP7'
Expand All @@ -91,6 +91,26 @@ public function order_items_can_be_configured()
$this->assertEquals('dolly buster', $item->configuration['hello']);
}

/** @test */
public function it_has_no_configuration_by_default()
{
$order = Order::create([
'number' => 'W0DRN'
]);

$order->items()->create([
'product_type' => 'product',
'product_id' => $this->theMoonRing->getId(),
'quantity' => 1,
'name' => $this->theMoonRing->getName(),
'price' => $this->theMoonRing->getPrice()
]);

$item = $order->items->first();

$this->assertFalse($item->hasConfiguration());
}

/** @test */
public function an_order_item_has_a_default_fullfillment_state()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Order/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"konekt/user": "^3.0",
"laravel/framework": "^10.43|^11.0",
"vanilo/contracts": "^4.0",
"vanilo/support": "^4.0"
"vanilo/support": "^4.2"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
Expand Down
5 changes: 5 additions & 0 deletions src/Payment/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 4.x Series

## Unreleased
##### 2024-XX-YY

- Changed `PaymentMethod::hasConfiguration()` to return false on empty arrays as well

## 4.1.0
##### 2024-07-11

Expand Down
2 changes: 1 addition & 1 deletion src/Payment/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"konekt/enum": "^4.2",
"laravel/framework": "^10.43|^11.0",
"vanilo/contracts": "^4.0",
"vanilo/support": "^4.0"
"vanilo/support": "^4.2"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Product/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"konekt/enum-eloquent": "^1.9",
"laravel/framework": "^10.43|^11.0",
"vanilo/contracts": "^4.0",
"vanilo/support": "^4.0",
"vanilo/support": "^4.2",
"cviebrock/eloquent-sluggable": "^10.0|^11.0"
},
"require-dev": {
Expand Down
7 changes: 7 additions & 0 deletions src/Shipment/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## 4.x Series

## Unreleased
##### 2024-XX-YY

- Changed `ShippingMethod::hasConfiguration()` to return false on empty arrays as well
- Changed `Shipment::hasConfiguration()` to return false on empty arrays as well
- Changed `Carrier::hasConfiguration()` to return false on empty arrays as well

## 4.1.0
##### 2024-07-11

Expand Down
2 changes: 1 addition & 1 deletion src/Shipment/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"konekt/laravel-migration-compatibility": "^1.6",
"laravel/framework": "^10.43|^11.0",
"vanilo/contracts": "^4.0",
"vanilo/support": "^4.0"
"vanilo/support": "^4.2"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
Expand Down
5 changes: 5 additions & 0 deletions src/Support/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 4.x Series

## Unreleased
##### 2024-XX-YY

- Changed the `ConfigurableModel::hasConfiguration()` trait to return false on empty arrays as well (until now, only `null` was considered as no config)

## 4.1.0
##### 2024-07-11

Expand Down
2 changes: 1 addition & 1 deletion src/Support/Traits/ConfigurableModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function configuration(): ?array

public function hasConfiguration(): bool
{
return null !== $this->{static::$configurationFieldName};
return !empty($this->{static::$configurationFieldName});
}

public function doesntHaveConfiguration(): bool
Expand Down
5 changes: 5 additions & 0 deletions src/Taxes/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 4.x Series

## Unreleased
##### 2024-XX-YY

- Changed `TaxRate::hasConfiguration()` to return false on empty arrays as well

## 4.1.0
##### 2024-07-11

Expand Down
2 changes: 1 addition & 1 deletion src/Taxes/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"laravel/framework": "^10.43|^11.0",
"nette/schema": "^1.2.5",
"vanilo/contracts": "^4.0",
"vanilo/support": "^4.0"
"vanilo/support": "^4.2"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
Expand Down

0 comments on commit 4ddbfd8

Please sign in to comment.