Skip to content

Commit 5db7974

Browse files
committed
force mapper schema initialize
1 parent 261b07f commit 5db7974

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Mapper.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,19 @@ public function getSpace(object|int|string $id): Space
166166

167167
public function getSpaces(): array
168168
{
169+
if (!count($this->spaces)) {
170+
$this->setSchemaId(0);
171+
}
172+
169173
return array_values($this->spaces);
170174
}
171175

172176
public function hasSpace(string $space): bool
173177
{
178+
if (!count($this->spaces)) {
179+
$this->setSchemaId(0);
180+
}
181+
174182
return array_key_exists($this->getClassSpace($space), $this->spaceId);
175183
}
176184

tests/MapperTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public function createMapper(
3535
return $mapper;
3636
}
3737

38+
public function testUninitializedSpacePresent()
39+
{
40+
$this->assertTrue($this->createMapper(dropUserSpaces:false)->hasSpace('_space'));
41+
}
42+
43+
public function testUninitializedSpaceList()
44+
{
45+
$this->assertNotCount(0, $this->createMapper(dropUserSpaces:false)->getSpaces());
46+
}
47+
3848
public function testClassBased()
3949
{
4050
$mapper = $this->createMapper();

0 commit comments

Comments
 (0)