function ComposerPatchesValidatorTest::testErrorDuringPreCreate

Same name and namespace in other branches
  1. 11.x core/modules/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php \Drupal\Tests\package_manager\Kernel\ComposerPatchesValidatorTest::testErrorDuringPreCreate()

Tests that the patcher configuration is validated during pre-create.

Attributes

#[DataProvider('providerErrorDuringPreCreate')]

Parameters

int $options: What aspects of the patcher are installed how.

\Drupal\package_manager\ValidationResult[] $expected_results: The expected validation results.

File

core/modules/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php, line 96

Class

ComposerPatchesValidatorTest
Tests Composer Patches Validator.

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testErrorDuringPreCreate(int $options, array $expected_results) : void {
  $active_manipulator = new ActiveFixtureManipulator();
  if ($options & static::CONFIG_ALLOWED_PLUGIN) {
    $active_manipulator->addConfig([
      'allow-plugins.cweagans/composer-patches' => TRUE,
    ]);
  }
  if ($options & static::EXTRA_EXIT_ON_PATCH_FAILURE) {
    $active_manipulator->addConfig([
      'extra.composer-exit-on-patch-failure' => TRUE,
    ]);
  }
  if ($options & static::REQUIRE_PACKAGE_FROM_ROOT) {
    $active_manipulator->requirePackage('cweagans/composer-patches', '@dev');
  }
  elseif ($options & static::REQUIRE_PACKAGE_INDIRECTLY) {
    $active_manipulator->addPackage([
      'type' => 'package',
      'name' => 'dummy/depends-on-composer-patches',
      'description' => 'A dummy package depending on cweagans/composer-patches',
      'version' => '1.0.0',
      'require' => [
        'cweagans/composer-patches' => '*',
      ],
    ]);
  }
  if ($options !== static::ABSENT) {
    $active_manipulator->commitChanges();
  }
  $this->assertStatusCheckResults($expected_results);
  $this->assertResults($expected_results, PreCreateEvent::class);
}

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