/**
* Login and submit a POST request to a $url that is expected to delete a given record,
* and then verify its removal.
*
* @param int $user_id The user to login as.
* @param String $url The url to send the request to. Be sure to include a trailing /.
* @param int $delete_id The id of the record to delete.
* @param String $redirect_url The url to redirect to, after the deletion.
* @param \Cake\ORM\Table $table The table to delete from.
*/
protected function deletePOST($user_id, $url, $delete_id, $redirect_url, $table)
{
$this->fakeLogin($user_id);
$this->post($url . $delete_id);
$this->assertResponseSuccess();
// 2xx, 3xx
$this->assertRedirect($redirect_url);
// Now verify that the record no longer exists
$query = new Query(ConnectionManager::get('test'), $table);
$query->find('all')->where(['id' => $delete_id]);
$this->assertEquals(0, $query->count());
}