Skip to content

Commit

Permalink
fix: Fixed unit test (swoft-cloud/swoft-component#227)
Browse files Browse the repository at this point in the history
* Fixed unit test

Since swoft-cloud/swoft-component#209, the result that get via QueryBuilder will not format the data type anymore.

* Update BugTest.php
  • Loading branch information
huangzhhui authored and swoft-bot committed Nov 21, 2018
1 parent fc9c1e1 commit 977fbfd
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/Cases/Mysql/BugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,21 +317,22 @@ public function testListType(int $uid)
/* @var User $user*/
$user = User::findById($uid)->getResult();
$userAry = $user->toArray();

$this->assertTrue(is_int($userAry['age']));
$this->assertTrue(is_int($userAry['sex']));
$this->assertTrue(is_string($userAry['desc']));

/**
* 通过 QueryBuilder 执行的查询将不再格式化结果属性的数据类型
* @see https://github.com/swoft-cloud/swoft-component/pull/209
*/
$row = Query::table(User::class)->where('id', $uid)->one()->getResult();

$this->assertTrue(is_int($row['age']));
$this->assertTrue(is_int($row['sex']));
$this->assertTrue(is_string($row['age']));
$this->assertTrue(is_string($row['sex']));
$this->assertTrue(is_string($row['description']));

$rows = Query::table(User::class)->where('id', $uid)->get()->getResult();
foreach ($rows as $userRow){
$this->assertTrue(is_int($userRow['age']));
$this->assertTrue(is_int($userRow['sex']));
$this->assertTrue(is_string($userRow['age']));
$this->assertTrue(is_string($userRow['sex']));
$this->assertTrue(is_string($userRow['description']));
}
}
Expand Down Expand Up @@ -374,4 +375,4 @@ public function testNoInc()
}


}
}

0 comments on commit 977fbfd

Please sign in to comment.