Skip to content

Commit

Permalink
Reverted the reversion after CI composer issues have been fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Nov 4, 2020
1 parent 6fd2394 commit bc10ce4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/CastsEnums.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ protected function addEnumAttributesToArray(array $attributes): array
{
foreach ($this->enums as $key => $value) {
// Don't set if the field is not present (pluck or not selecting them in the SQL can cause it)
//if (isset($this->attributes[$key])) {
if (isset($this->attributes[$key])) {
$attributes[$key] = $this->getAttributeValue($key)->value();
//}
}
}

return $attributes;
Expand Down
24 changes: 12 additions & 12 deletions tests/EnumToArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function returns_enum_default_string_value_when_attribute_is_null()

$order = new Order([
'number' => 'abc123',
//'status' => null
'status' => null
]);

$array = $order->attributesToArray();
Expand All @@ -93,16 +93,16 @@ public function returns_enum_default_string_value_when_attribute_is_null()
$this->assertEquals($array['status'], OrderStatus::__DEFAULT);
}

// /** @test */
// public function it_does_not_set_the_attribute_key_if_the_attribute_is_absent_in_the_model()
// {
// $order = new Order([
// 'number' => 'abc123'
// ]);
//
// $array = $order->attributesToArray();
// $this->assertArrayNotHasKey('status', $array);
// }
/** @test */
public function it_does_not_set_the_attribute_key_if_the_attribute_is_absent_in_the_model()
{
$order = new Order([
'number' => 'abc123'
]);

$array = $order->attributesToArray();
$this->assertArrayNotHasKey('status', $array);
}

/**
* @test
Expand All @@ -118,7 +118,7 @@ public function returns_enum_v2_default_string_value_when_attribute_is_null()

$order = new OrderV2([
'number' => 'abc123',
//'status' => null
'status' => null
]);

$array = $order->attributesToArray();
Expand Down

0 comments on commit bc10ce4

Please sign in to comment.