Skip to content

Commit d502287

Browse files
committed
test: fix failed tests on PostgreSQL
1 parent a22634d commit d502287

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/Unit/UserModelTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,25 @@ public function testInsertUserObject(): void
6060
]);
6161
}
6262

63+
/**
64+
* This test is not correct.
65+
*
66+
* Entity's `toArray()` method returns array with properties and values.
67+
* The array may have different keys with the DB column names.
68+
* And the values may be different types with the DB column types.
69+
* So $userArray is not data to be inserted into the database.
70+
*/
6371
public function testInsertUserArray(): void
6472
{
6573
$users = $this->createUserModel();
6674

6775
$user = $this->createNewUser();
6876

6977
$userArray = $user->toArray();
70-
$id = $users->insert($userArray);
78+
// Fix value type
79+
$userArray['active'] = (int) $userArray['active'];
80+
81+
$id = $users->insert($userArray);
7182

7283
$this->dontSeeInDatabase('auth_identities', [
7384
'user_id' => $id,
@@ -138,6 +149,14 @@ public function testUpdateUserObjectWithUserDataToUpdate(): void
138149
]);
139150
}
140151

152+
/**
153+
* This test is not correct.
154+
*
155+
* Entity's `toArray()` method returns array with properties and values.
156+
* The array may have different keys with the DB column names.
157+
* And the values may be different types with the DB column types.
158+
* So $userArray is not data to be inserted into the database.
159+
*/
141160
public function testUpdateUserArrayWithUserDataToUpdate(): void
142161
{
143162
$users = $this->createUserModel();
@@ -151,6 +170,9 @@ public function testUpdateUserArrayWithUserDataToUpdate(): void
151170
$user->active = 1;
152171

153172
$userArray = $user->toArray();
173+
// Fix value type
174+
$userArray['active'] = (int) $userArray['active'];
175+
154176
$users->update(null, $userArray);
155177

156178
$this->dontSeeInDatabase('auth_identities', [

0 commit comments

Comments
 (0)