Skip to content

Commit bca9ab9

Browse files
committed
Added sort by key after load many references for model
1 parent f84444d commit bca9ab9

4 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/DataMapper/Redis/ModelManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function find(string $class, string $id, int $depthLevel = 1, IdentityMap
153153

154154
if (count($referenceModels) > 0) {
155155
$referenceModels = yield all($referenceModels);
156+
ksort($referenceModels);
156157
}
157158

158159
$propertyMetadata->setValue($modelInstance, $referenceModels);

tests/DataMapper/Redis/RedisImplementationIntegrationTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ public function testBooks()
156156
$this->assertEquals($bio1->getContent(), $loadedAuthor1->getBio()->getContent());
157157
$this->assertCount(3, $loadedAuthor1->getBooks());
158158

159+
foreach (['book-id1', 'book-id2', 'book-id3'] as $index => $item) {
160+
$this->assertEquals($item, $loadedAuthor1->getBooks()[$index]->getId());
161+
}
162+
159163
/** @var Book $loadedBook1 */
160164
$loadedBook1 = wait($modelManager->find(Book::class, 'book-id1', 1, $identityMap));
161165

tests/DataMapper/Redis/RedisImplementationTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use AsyncInterop\Loop;
77
use PHPUnit\Framework\TestCase;
88

9-
class RedisImplementationTestCase extends TestCase
9+
abstract class RedisImplementationTestCase extends TestCase
1010
{
1111
public static function setUpBeforeClass()
1212
{

tests/DataMapper/Stubs/Integration/Author.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,17 @@ public function getBio(): ?AuthorBio
6868
return $this->bio;
6969
}
7070

71+
/**
72+
* @return Book[]
73+
*/
7174
public function getBooks(): array
7275
{
7376
return $this->books;
7477
}
7578

79+
/**
80+
* @return Genre[]
81+
*/
7682
public function getGenres(): array
7783
{
7884
return $this->genres;

0 commit comments

Comments
 (0)