You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tests for task #4 and task #5 needs improvement, because they are marked as passed with the definition of the wrong relations.
Let's take a look at the tables that are created when running a test for task #4:
users table:
roles table:
users_roles table:
The problem with this test data is that the user id and role id are the same and it follows the the error when wrong relation definition return the same result as correct relation definition
//INCORRECT RELATION
public function users()
{
// TASK: fix this by adding a parameter
return $this->belongsToMany(
User::class,
'users_roles',
'user_id',
'role_id',
);
}
select roles., (select count() from users inner join users_roles on users.id = users_roles.role_id where roles.id = users_roles.user_id) as users_count from roles
It's forbidden to make join like "users.id = users_roles.role_id", but the test case doesn't check it
//CORRECT RELATION
public function users()
{
// TASK: fix this by adding a parameter
return $this->belongsToMany(
User::class,
'users_roles',
'role_id',
'user_id',
);
}
select roles., (select count() from users inner join users_roles on users.id = users_roles.user_id where roles.id = users_roles.role_id) as users_count from roles
The text was updated successfully, but these errors were encountered:
Tests for task #4 and task #5 needs improvement, because they are marked as passed with the definition of the wrong relations.
Let's take a look at the tables that are created when running a test for task #4:
users table:
roles table:
users_roles table:
The problem with this test data is that the user id and role id are the same and it follows the the error when wrong relation definition return the same result as correct relation definition
select
roles
., (select count() fromusers
inner joinusers_roles
onusers
.id
=users_roles
.role_id
whereroles
.id
=users_roles
.user_id
) asusers_count
fromroles
It's forbidden to make join like "
users
.id
=users_roles
.role_id
", but the test case doesn't check itselect
roles
., (select count() fromusers
inner joinusers_roles
onusers
.id
=users_roles
.user_id
whereroles
.id
=users_roles
.role_id
) asusers_count
fromroles
The text was updated successfully, but these errors were encountered: