You are here

protected function ComposerProjectTemplatesTest::makeTestPackage in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php \Drupal\BuildTests\Composer\Template\ComposerProjectTemplatesTest::makeTestPackage()

Creates a test package that points to the templates.

Parameters

string $repository_path: The path where to create the test package.

string $version: The version under test.

1 call to ComposerProjectTemplatesTest::makeTestPackage()
ComposerProjectTemplatesTest::testTemplateCreateProject in core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php
@dataProvider provideTemplateCreateProject

File

core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php, line 214

Class

ComposerProjectTemplatesTest
Demonstrate that Composer project templates are buildable as patched.

Namespace

Drupal\BuildTests\Composer\Template

Code

protected function makeTestPackage($repository_path, $version) {
  $json = <<<JSON
{
  "packages": {
    "drupal/recommended-project": {
      "{<span class="php-variable">$version</span>}": {
        "name": "drupal/recommended-project",
        "dist": {
          "type": "path",
          "url": "composer/Template/RecommendedProject"
        },
        "type": "project",
        "version": "{<span class="php-variable">$version</span>}"
      }
    },
    "drupal/legacy-project": {
      "{<span class="php-variable">$version</span>}": {
        "name": "drupal/legacy-project",
        "dist": {
          "type": "path",
          "url": "composer/Template/LegacyProject"
        },
        "type": "project",
        "version": "{<span class="php-variable">$version</span>}"
      }
    }
  }
}
JSON;
  mkdir(dirname($repository_path));
  file_put_contents($repository_path, $json);
}