Skip to content

Commit 482dfe7

Browse files
committed
Field authorization tests
1 parent 61fc999 commit 482dfe7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/FieldTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,33 @@ public function it_can_create_time_field()
226226
$this->assertEquals('Name', $field->label);
227227
$this->assertEquals('hh:mm a', $field->format);
228228
}
229+
230+
/** @test */
231+
public function it_has_authorizations()
232+
{
233+
$field = Fields\Text::makeIf(true, 'name');
234+
$this->assertEquals([
235+
'name' => 'name',
236+
'label' => 'Name',
237+
'type' => 'text',
238+
], $field->toArray());
239+
240+
$field = Fields\Text::makeIf(false, 'name');
241+
$this->assertEquals([], $field->toArray());
242+
}
243+
244+
/** @test */
245+
public function it_can_be_serialized()
246+
{
247+
$field = Fields\Text::make('name')->data('user.name');
248+
249+
$this->assertEquals([
250+
'name' => 'name',
251+
'data' => 'user.name',
252+
'label' => 'Name',
253+
'type' => 'text',
254+
], $field->toArray());
255+
256+
$this->assertEquals('{"name":"name","label":"Name","type":"text","data":"user.name"}', $field->toJson());
257+
}
229258
}

0 commit comments

Comments
 (0)