-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Gman98ish/array-access
Change ArrayAccess to load from object rather than array
- Loading branch information
Showing
2 changed files
with
22 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ public function sets_attributes_from_an_array() | |
$this->assertEquals(1, $this->entity->id); | ||
$this->assertEquals('John', $this->entity->first_name); | ||
$this->assertEquals('Doe', $this->entity->last_name); | ||
$this->assertEquals('[email protected]', $this->entity->email->personal); | ||
} | ||
|
||
/** | ||
|
@@ -33,6 +34,20 @@ public function can_convert_to_an_array() | |
$this->assertEquals(1, $array['id']); | ||
$this->assertEquals('John', $array['first_name']); | ||
$this->assertEquals('Doe', $array['last_name']); | ||
$this->assertEquals('[email protected]', $array['email']['personal']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function can_access_as_array() | ||
{ | ||
$this->loadSampleEntity(); | ||
|
||
$this->assertEquals(1, $this->entity['id']); | ||
$this->assertEquals('John', $this->entity['first_name']); | ||
$this->assertEquals('Doe', $this->entity['last_name']); | ||
$this->assertEquals('[email protected]', $this->entity['email']['personal']); | ||
} | ||
|
||
protected function loadSampleEntity() | ||
|
@@ -41,6 +56,9 @@ protected function loadSampleEntity() | |
'id' => 1, | ||
'first_name' => 'John', | ||
'last_name' => 'Doe', | ||
'email' => (object) [ | ||
'personal' => '[email protected]' | ||
] | ||
]); | ||
} | ||
} |