diff --git a/src/Fields/Field.php b/src/Fields/Field.php index 8def3e086..0b370c720 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -38,7 +38,7 @@ class Field extends OrganicField implements JsonSerializable public $value; /** - * In case of the update, this will keep the previous value + * In case of the update, this will keep the previous value. * @var */ public $valueBeforeUpdate; diff --git a/tests/Unit/FieldTest.php b/tests/Unit/FieldTest.php index 61a374a5b..3d3715e8c 100644 --- a/tests/Unit/FieldTest.php +++ b/tests/Unit/FieldTest.php @@ -5,7 +5,6 @@ use Binaryk\LaravelRestify\Fields\Field; use Binaryk\LaravelRestify\Http\Requests\RepositoryStoreRequest; use Binaryk\LaravelRestify\Http\Requests\RepositoryUpdateRequest; -use Binaryk\LaravelRestify\Http\Requests\RestifyRequest; use Binaryk\LaravelRestify\Tests\Fixtures\PostRepository; use Binaryk\LaravelRestify\Tests\IntegrationTest; use Illuminate\Database\Eloquent\Model; @@ -19,10 +18,10 @@ public function test_fields_can_have_custom_index_callback() return strtoupper($value); }); - $field->resolveForIndex((object)['name' => 'Binaryk'], 'name'); + $field->resolveForIndex((object) ['name' => 'Binaryk'], 'name'); $this->assertEquals('BINARYK', $field->value); - $field->resolveForShow((object)['name' => 'Binaryk'], 'name'); + $field->resolveForShow((object) ['name' => 'Binaryk'], 'name'); $this->assertEquals('Binaryk', $field->value); } @@ -32,10 +31,10 @@ public function test_fields_can_have_custom_show_callback() return strtoupper($value); }); - $field->resolveForShow((object)['name' => 'Binaryk'], 'name'); + $field->resolveForShow((object) ['name' => 'Binaryk'], 'name'); $this->assertEquals('BINARYK', $field->value); - $field->resolveForIndex((object)['name' => 'Binaryk'], 'name'); + $field->resolveForIndex((object) ['name' => 'Binaryk'], 'name'); $this->assertEquals('Binaryk', $field->value); } @@ -45,7 +44,7 @@ public function test_fields_can_have_custom_resolver_callback_even_if_field_is_m return strtoupper('default'); }); - $field->resolveForShow((object)['name' => 'Binaryk'], 'email'); + $field->resolveForShow((object) ['name' => 'Binaryk'], 'email'); $this->assertEquals('DEFAULT', $field->value); } @@ -56,7 +55,7 @@ public function test_computed_fields_resolve() return 'Computed'; }); - $field->resolveForIndex((object)[]); + $field->resolveForIndex((object) []); $this->assertEquals('Computed', $field->value); } @@ -67,7 +66,7 @@ public function test_fields_may_have_callback_resolver() return 'Resolved Title'; }); - $field->resolveForIndex((object)[]); + $field->resolveForIndex((object) []); $this->assertEquals('Resolved Title', $field->value); } @@ -76,7 +75,7 @@ public function test_fields_has_default_value() { $field = Field::make('title')->default('Title'); - $field->resolveForIndex((object)[]); + $field->resolveForIndex((object) []); $this->assertEquals('Title', data_get($field->jsonSerialize(), 'value')); } @@ -94,7 +93,6 @@ public function test_field_can_have_custom_store_callback() $model->title = 'from store callback'; }); - $field->fillAttribute($request, $model); $this->assertEquals('from store callback', $model->title); @@ -113,7 +111,6 @@ public function test_field_can_have_custom_udpate_callback() $model->title = 'from update callback'; }); - $field->fillAttribute($request, $model); $this->assertEquals('from update callback', $model->title); @@ -136,9 +133,8 @@ public function test_field_fill_callback_has_high_priority() $model->title = 'from store callback'; }) ->updateCallback(function ($request, $model) { - $model->title = 'from update callback'; - }); - + $model->title = 'from update callback'; + }); $field->fillAttribute($request, $model); @@ -157,7 +153,6 @@ public function test_field_fill_from_request() }); }); - $request->merge([ 'title' => 'title from request', ]); @@ -169,7 +164,6 @@ public function test_field_fill_from_request() /** * @var Field $field */ $field = Field::new('title'); - $field->fillAttribute($request, $model); $this->assertEquals('title from request', $model->title);