function ComposerProjectTemplatesTest::testVerifyTemplateTestProviderIsAccurate

Same name and namespace in other branches
  1. 9 core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php \Drupal\BuildTests\Composer\Template\ComposerProjectTemplatesTest::testVerifyTemplateTestProviderIsAccurate()
  2. 8.9.x core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php \Drupal\BuildTests\Composer\Template\ComposerProjectTemplatesTest::testVerifyTemplateTestProviderIsAccurate()
  3. 10 core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php \Drupal\BuildTests\Composer\Template\ComposerProjectTemplatesTest::testVerifyTemplateTestProviderIsAccurate()

Make sure we've accounted for all the templates.

File

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

Class

ComposerProjectTemplatesTest
Demonstrate that Composer project templates can be built as patched.

Namespace

Drupal\BuildTests\Composer\Template

Code

public function testVerifyTemplateTestProviderIsAccurate() : void {
    $root = $this->getDrupalRoot();
    $data = $this->provideTemplateCreateProject();
    // Find all the templates.
    $template_files = Composer::composerSubprojectPaths($root, 'Template');
    $this->assertSameSize($template_files, $data);
    // We could have the same number of templates but different names.
    $template_data = [];
    foreach ($data as $data_name => $data_value) {
        $template_data[$data_value[0]] = $data_name;
    }
    
    /** @var \SplFileInfo $file */
    foreach ($template_files as $file) {
        $json_file = new JsonFile($file->getPathname());
        $json = $json_file->read();
        $this->assertArrayHasKey('name', $json);
        // Assert that the template name is in the project created
        // from the template.
        $this->assertArrayHasKey($json['name'], $template_data);
    }
}

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