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 */