ComponentMetadata example


final class ComponentMetadataTest extends UnitTestCaseTest {

  /** * Tests that the correct data is returned for each property. * * @dataProvider dataProviderMetadata */
  public function testMetadata(array $metadata_info, array $expectations) {
    $metadata = new ComponentMetadata($metadata_info, 'foo/', FALSE);
    $this->assertSame($expectations['path']$metadata->path);
    $this->assertSame($expectations['status']$metadata->status);
    $this->assertSame($expectations['thumbnail']$metadata->getThumbnailPath());
    $this->assertEquals($expectations['props']$metadata->schema);
  }

  /** * Tests the correct checks when enforcing schemas or not. * * @dataProvider dataProviderMetadata */
  
$template = $plugin_definition['template'] ?? NULL;
    if (!$template) {
      $message = sprintf(
        'Unable to find the Twig template for the component "%s".',
        $plugin_id
      );
      throw new InvalidComponentException($message);
    }
    $this->template = $template;
    $this->machineName = $plugin_definition['machineName'];
    $this->library = $plugin_definition['library'] ?? [];
    $this->metadata = new ComponentMetadata(
      $plugin_definition,
      $configuration['app_root'],
      (bool) ($configuration['enforce_schemas'] ?? FALSE)
    );
  }

  /** * The template path. * * @return string|null * The path to the template. */
Home | Imprint | This part of the site doesn't use cookies.