Skip to content

Commit

Permalink
增加单元测试:通过指定表别名获取字段列数据
Browse files Browse the repository at this point in the history
  • Loading branch information
Eno-CN authored Nov 4, 2024
1 parent 3a0f96a commit 3438cf7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/unit/Component/Tests/Db/DbBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 3438cf7

Please sign in to comment.