From 3438cf764a868f07f273600876a7a140aac65bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=AF=BAEno?= <895183594@qq.com> Date: Mon, 4 Nov 2024 11:17:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=EF=BC=9A=E9=80=9A=E8=BF=87=E6=8C=87=E5=AE=9A=E8=A1=A8?= =?UTF-8?q?=E5=88=AB=E5=90=8D=E8=8E=B7=E5=8F=96=E5=AD=97=E6=AE=B5=E5=88=97?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/Component/Tests/Db/DbBaseTest.php | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/unit/Component/Tests/Db/DbBaseTest.php b/tests/unit/Component/Tests/Db/DbBaseTest.php index 52f499765..450775550 100644 --- a/tests/unit/Component/Tests/Db/DbBaseTest.php +++ b/tests/unit/Component/Tests/Db/DbBaseTest.php @@ -674,6 +674,38 @@ public function testColumn(array $args): void $this->assertEquals(array_column_ex($origin, ['title', 'content', 'time', 'id'], 'id'), $data); } + /** + * @depends testBatchInsert + */ + public function testAliasColumn(array $args): void + { + $origin = $args['origin']; + + $data = Db::query($this->poolName) + ->table('tb_article', 't') + ->column('t.content'); + + $this->assertEquals(array_column($origin, 'content'), $data); + + $data = Db::query($this->poolName) + ->table('tb_article', 't') + ->column('t.content', 't.id'); + + $this->assertEquals(array_column($origin, 'content', 'id'), $data); + + $data = Db::query($this->poolName) + ->table('tb_article', 't') + ->column(['t.id', 't.content'], 't.id'); + + $this->assertEquals(array_column_ex($origin, ['id', 'content'], 'id'), $data); + + $data = Db::query($this->poolName) + ->table('tb_article', 't') + ->column(['t.title', 't.content', 't.time'], 't.id'); + + $this->assertEquals(array_column_ex($origin, ['title', 'content', 'time', 'id'], 'id'), $data); + } + /** * @depends testInsert */