function StageOwnershipTest::testForceDestroy

Tests a stage being destroyed by a user who doesn't own it.

File

core/modules/package_manager/tests/src/Kernel/StageOwnershipTest.php, line 228

Class

StageOwnershipTest
Tests that ownership of the stage is enforced.

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testForceDestroy() : void {
  $owned = $this->createStage();
  $owned->create();
  $not_owned = $this->createStage();
  try {
    $not_owned->destroy();
    $this->fail("Able to destroy a stage that we don't own.");
  } catch (\LogicException $exception) {
    $this->assertSame('Stage must be claimed before performing any operations on it.', $exception->getMessage());
  }
  // We should be able to destroy the stage if we ignore ownership.
  $not_owned->destroy(TRUE);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.