From 273feae9923c7c5eb055258ac9835ea8dc5c9161 Mon Sep 17 00:00:00 2001 From: dmitry krokhin Date: Tue, 15 Oct 2024 15:16:14 +0300 Subject: [PATCH] space class for uppercased strings --- src/Mapper.php | 2 +- tests/MapperTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Mapper.php b/src/Mapper.php index a5531f0..11b0f12 100644 --- a/src/Mapper.php +++ b/src/Mapper.php @@ -133,7 +133,7 @@ public function getChanges(): array public function getClassSpace(int|string $class): int|string { - if (!is_integer($class) && class_exists($class)) { + if (!is_integer($class) && !ctype_lower($class) && class_exists($class)) { if (!array_key_exists($class, $this->classNames)) { $this->registerClass($class); } diff --git a/tests/MapperTest.php b/tests/MapperTest.php index 96a11f5..00e3649 100644 --- a/tests/MapperTest.php +++ b/tests/MapperTest.php @@ -48,6 +48,18 @@ public function testClassBased() $this->assertEquals($row, $mapper->findOne('constructor')); } + public function testAttribute() + { + $mapper = $this->createMapper(); + $attribute = $mapper->createSpace('attribute'); + $attribute->addProperty('key', 'string'); + $attribute->addProperty('value', 'string'); + $attribute->addIndex(['key']); + + $attribute = $mapper->findOrCreate('attribute', ['key' => 'tester']); + $this->assertNotNull($attribute); + } + public function testIdleField() { $mapper = $this->createMapper();