sendDeleteRequestForUser example

/** * Tests if JSON:API respects user.settings.cancel_method: user_cancel_block. */
  public function testDeleteRespectsUserCancelBlock() {
    $cancel_method = 'user_cancel_block';
    $this->config('jsonapi.settings')->set('read_only', FALSE)->save(TRUE);
    $this->config('user.settings')->set('cancel_method', $cancel_method)->save(TRUE);

    $account = $this->createAnotherEntity($cancel_method);
    $node = $this->drupalCreateNode(['uid' => $account->id()]);

    $this->sendDeleteRequestForUser($account$cancel_method);

    $user_storage = $this->container->get('entity_type.manager')
      ->getStorage('user');
    $user_storage->resetCache([$account->id()]);
    $account = $user_storage->load($account->id());

    $this->assertNotNull($account, 'User is not deleted after JSON:API DELETE operation with user.settings.cancel_method: ' . $cancel_method);
    $this->assertTrue($account->isBlocked(), 'User is blocked after JSON:API DELETE operation with user.settings.cancel_method: ' . $cancel_method);

    $node_storage = $this->container->get('entity_type.manager')->getStorage('node');
    $node_storage->resetCache([$node->id()]);
    
Home | Imprint | This part of the site doesn't use cookies.