-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '5.6' of https://github.com/iceheat/framework into icehe…
…at-5.6
- Loading branch information
Showing
2 changed files
with
107 additions
and
11 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 |
---|---|---|
|
@@ -156,7 +156,6 @@ public function testAllColumnsAreRetrievedByDefault() | |
{ | ||
$this->seedData(); | ||
$post = HasManyThroughTestCountry::first()->posts()->first(); | ||
|
||
$this->assertEquals([ | ||
'id', | ||
'user_id', | ||
|
@@ -181,6 +180,43 @@ public function testOnlyProperColumnsAreSelectedIfProvided() | |
], array_keys($post->getAttributes())); | ||
} | ||
|
||
public function testChunkReturnsCorrectModels(){ | ||
$this->seedData(); | ||
$this->seedDataExtended(); | ||
$country = HasManyThroughTestCountry::find(2); | ||
|
||
$country->posts()->chunk(10,function($postsChunk){ | ||
$post = $postsChunk->first(); | ||
$this->assertEquals([ | ||
'id', | ||
'user_id', | ||
'title', | ||
'body', | ||
'email', | ||
'created_at', | ||
'updated_at', | ||
'country_id'],array_keys($post->getAttributes())); | ||
|
||
}); | ||
} | ||
public function testEachReturnsCorrectModels(){ | ||
$this->seedData(); | ||
$this->seedDataExtended(); | ||
$country = HasManyThroughTestCountry::find(2); | ||
|
||
$country->posts()->each(function($post){ | ||
$this->assertEquals([ | ||
'id', | ||
'user_id', | ||
'title', | ||
'body', | ||
'email', | ||
'created_at', | ||
'updated_at', | ||
'country_id'],array_keys($post->getAttributes())); | ||
|
||
}); | ||
} | ||
public function testIntermediateSoftDeletesAreIgnored() | ||
{ | ||
$this->seedData(); | ||
|
@@ -214,6 +250,26 @@ protected function seedData() | |
['title' => 'Another title', 'body' => 'Another body', 'email' => '[email protected]'], | ||
]); | ||
} | ||
protected function seedDataExtended(){ | ||
$country = HasManyThroughTestCountry::create(['id' => 2, 'name' => 'United Kingdom', 'shortname' => 'uk']); | ||
$country->users()->create(['id' => 2, 'email' => '[email protected]', 'country_short' => 'uk']) | ||
->posts()->createMany([ | ||
['title' => 'Example1 title1', 'body' => 'Example1 body1', 'email' => '[email protected]'], | ||
['title' => 'Example1 title2', 'body' => 'Example1 body2', 'email' => '[email protected]'] | ||
]); | ||
$country->users()->create(['id' => 3, 'email' => '[email protected]', 'country_short' => 'uk']) | ||
->posts()->createMany([ | ||
['title' => 'Example2 title1', 'body' => 'Example2 body1', 'email' => '[email protected]'], | ||
['title' => 'Example2 title2', 'body' => 'Example2 body2', 'email' => '[email protected]'] | ||
]); | ||
$country->users()->create(['id' => 4, 'email' => '[email protected]', 'country_short' => 'uk']) | ||
->posts()->createMany([ | ||
['title' => 'Example3 title1', 'body' => 'Example3 body1', 'email' => '[email protected]'], | ||
['title' => 'Example3 title2', 'body' => 'Example3 body2', 'email' => '[email protected]'] | ||
]); | ||
|
||
|
||
} | ||
|
||
/** | ||
* Seed data for a default HasManyThrough setup. | ||
|