Skip to content

Commit e36773a

Browse files
committed
schema space id validation
1 parent 9d29b7d commit e36773a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Schema.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public function getSpace($id)
4444
return $this->getSpace($this->getSpaceId($id));
4545
}
4646

47+
if(!$id) {
48+
throw new Exception("Space id or name not defined");
49+
}
50+
4751
if(!array_key_exists($id, $this->spaces)) {
4852
$this->spaces[$id] = new Space($this->mapper, $id, array_search($id, $this->names));
4953
}

tests/SchemaTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
<?php
22

3+
use Exception;
34
use Tarantool\Mapper\Mapper;
45
use Tarantool\Mapper\Space;
56

67
class SchemaTest extends TestCase
78
{
9+
public function testNoSpaceException()
10+
{
11+
$mapper = $this->createMapper();
12+
$this->clean($mapper);
13+
$this->expectException(Exception::class);
14+
$space = $mapper->getSchema()->getSpace(null);
15+
}
16+
817
public function testEmptySpace()
918
{
1019
$mapper = $this->createMapper();

0 commit comments

Comments
 (0)