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:
5656
5757``` php
5858$storage = new Storage();
59- $record = $storage->record();
59+ $record = $storage->record(); // You also can provide default data, like an array or stdClass
6060$record->name = 'Henrique Moody';
6161
6262$storage->users->insert($record);
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ public function getName()
2525 return $ this ->name ;
2626 }
2727
28- public function record ($ record )
28+ public function record ($ record = array () )
2929 {
3030 if (! $ record instanceof Record) {
3131 $ data = (array ) $ record ;
Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ public function testShouldDefineNameOnConstructor()
1515 $ this ->assertEquals ($ name , $ collection ->getName ());
1616 }
1717
18+ public function testShouldCreateNewRecord ()
19+ {
20+ $ collection = new Collection ('whatever ' );
21+ $ record = $ collection ->record ();
22+
23+ $ this ->assertInstanceOf (__NAMESPACE__ . '\\Record ' , $ record );
24+ }
25+
1826 public function testShouldCreateNewRecordFromArray ()
1927 {
2028 $ collection = new Collection ('whatever ' );
You can’t perform that action at this time.
0 commit comments