diff --git a/tests/ORM/Functional/Driver/Common/Integration/Case6/CaseTest.php b/tests/ORM/Functional/Driver/Common/Integration/Case6/CaseTest.php new file mode 100644 index 00000000..d2bcf8e0 --- /dev/null +++ b/tests/ORM/Functional/Driver/Common/Integration/Case6/CaseTest.php @@ -0,0 +1,50 @@ +makeTable('users', [ + 'id' => 'int,primary', + 'login' => 'string', + ]); + + $this->loadSchema(__DIR__ . '/schema.php'); + + $this->getDatabase()->table('users')->insertMultiple( + ['id', 'login'], + [ + [1, 'foo'], + ], + ); + } + + public function testSelect(): void + { + /** @var User $model */ + $model = (new Select($this->orm,User::class)) + ->wherePK(1) + ->fetchOne(); + + $this->assertSame('foo', $model->getLogin()); + $this->expectException(\Exception::class); + $model->login = 'new login'; + } +} diff --git a/tests/ORM/Functional/Driver/Common/Integration/Case6/Entity/User.php b/tests/ORM/Functional/Driver/Common/Integration/Case6/Entity/User.php new file mode 100644 index 00000000..44095601 --- /dev/null +++ b/tests/ORM/Functional/Driver/Common/Integration/Case6/Entity/User.php @@ -0,0 +1,26 @@ +login = $login; + } + + public function getId(): ?string + { + return $this->id === null ? null : (string)$this->id; + } + + public function getLogin(): string + { + return $this->login; + } +} diff --git a/tests/ORM/Functional/Driver/Common/Integration/Case6/schema.php b/tests/ORM/Functional/Driver/Common/Integration/Case6/schema.php new file mode 100644 index 00000000..cc0dd8c8 --- /dev/null +++ b/tests/ORM/Functional/Driver/Common/Integration/Case6/schema.php @@ -0,0 +1,31 @@ + [ + Schema::ENTITY => User::class, + Schema::MAPPER => Mapper::class, + Schema::SOURCE => Source::class, + Schema::REPOSITORY => Repository::class, + Schema::DATABASE => 'default', + Schema::TABLE => 'users', + Schema::PRIMARY_KEY => ['id'], + Schema::FIND_BY_KEYS => ['id'], + Schema::COLUMNS => [ + 'id' => 'id', + 'login' => 'login', + ], + Schema::RELATIONS => [], + Schema::TYPECAST => [ + 'id' => 'int', + 'login' => 'string', + ], + ], +]; diff --git a/tests/ORM/Functional/Driver/MySQL/Integration/Case6/CaseTest.php b/tests/ORM/Functional/Driver/MySQL/Integration/Case6/CaseTest.php new file mode 100644 index 00000000..f96d12bc --- /dev/null +++ b/tests/ORM/Functional/Driver/MySQL/Integration/Case6/CaseTest.php @@ -0,0 +1,17 @@ +