File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ You can create a Record object from Storage object:
56
56
57
57
``` php
58
58
$storage = new Storage();
59
- $record = $storage->record();
59
+ $record = $storage->record(); // You also can provide default data, like an array or stdClass
60
60
$record->name = 'Henrique Moody';
61
61
62
62
$storage->users->insert($record);
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ public function getName()
25
25
return $ this ->name ;
26
26
}
27
27
28
- public function record ($ record )
28
+ public function record ($ record = array () )
29
29
{
30
30
if (! $ record instanceof Record) {
31
31
$ data = (array ) $ record ;
Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ public function testShouldDefineNameOnConstructor()
15
15
$ this ->assertEquals ($ name , $ collection ->getName ());
16
16
}
17
17
18
+ public function testShouldCreateNewRecord ()
19
+ {
20
+ $ collection = new Collection ('whatever ' );
21
+ $ record = $ collection ->record ();
22
+
23
+ $ this ->assertInstanceOf (__NAMESPACE__ . '\\Record ' , $ record );
24
+ }
25
+
18
26
public function testShouldCreateNewRecordFromArray ()
19
27
{
20
28
$ collection = new Collection ('whatever ' );
You can’t perform that action at this time.
0 commit comments