Skip to content

Commit

Permalink
Update tests for deactivation
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat committed Jul 31, 2021
1 parent e2c4d57 commit e874010
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions tests/integration/api/users/UpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,26 @@ public function users_cant_activate_themselves()
$this->assertEquals(403, $response->getStatusCode());
}

/**
* @test
*/
public function users_cant_deactivate_themselves()
{
$response = $this->send(
$this->request('PATCH', '/api/users/2', [
'authenticatedAs' => 2,
'json' => [
'data' => [
'attributes' => [
'isEmailConfirmed' => false
],
]
],
])
);
$this->assertEquals(403, $response->getStatusCode());
}

/**
* @test
*
Expand Down Expand Up @@ -354,6 +374,26 @@ public function users_cant_activate_others_without_permission()
$this->assertEquals(403, $response->getStatusCode());
}

/**
* @test
*/
public function users_cant_deactivate_others_without_permission()
{
$response = $this->send(
$this->request('PATCH', '/api/users/2', [
'authenticatedAs' => 2,
'json' => [
'data' => [
'attributes' => [
'isEmailConfirmed' => false
],
]
],
])
);
$this->assertEquals(403, $response->getStatusCode());
}

/**
* @test
*
Expand Down Expand Up @@ -574,6 +614,27 @@ public function users_cant_activate_others_even_with_permissions()
$this->assertEquals(403, $response->getStatusCode());
}

/**
* @test
*/
public function users_cant_deactivate_others_even_with_permissions()
{
$this->giveNormalUsersEditPerms();
$response = $this->send(
$this->request('PATCH', '/api/users/2', [
'authenticatedAs' => 2,
'json' => [
'data' => [
'attributes' => [
'isEmailConfirmed' => false
],
]
],
])
);
$this->assertEquals(403, $response->getStatusCode());
}

/**
* @test
*/
Expand Down Expand Up @@ -636,6 +697,26 @@ public function admins_can_activate_others()
$this->assertEquals(200, $response->getStatusCode());
}

/**
* @test
*/
public function admins_can_deactivate_others()
{
$response = $this->send(
$this->request('PATCH', '/api/users/2', [
'authenticatedAs' => 1,
'json' => [
'data' => [
'attributes' => [
'isEmailConfirmed' => false
],
]
],
])
);
$this->assertEquals(200, $response->getStatusCode());
}

/**
* @test
*/
Expand Down

0 comments on commit e874010

Please sign in to comment.