Skip to content

Commit 720b465

Browse files
committed
Fix getAll returns an array with 'not-exist' id if get('not-exist') is called before
1 parent 77bbafd commit 720b465

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/StaticEntityManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getAll()
8383
$this->createInstance($id);
8484
}
8585

86-
return $this->instances;
86+
return array_filter($this->instances);
8787
}
8888

8989
/**

tests/StaticEntityTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ public function testGetAllTwice()
120120
$this->assertSame($all1, $all2);
121121
}
122122

123+
public function testGetAllAfterInexistent()
124+
{
125+
Civility::get('not-exists');
126+
$all = Civility::getAll();
127+
128+
$this->assertArrayNotHasKey('not-exists', $all);
129+
}
130+
123131
public function testGetAssoc()
124132
{
125133
$assoc = Civility::getAssociative();

0 commit comments

Comments
 (0)