getProject example


class DependencyTest extends UnitTestCase {

  /** * @covers ::createFromString * @dataProvider providerCreateFromString */
  public function testCreateFromString($string$expected_name$expected_project$expected_constraint) {
    $dependency = Dependency::createFromString($string);
    $this->assertSame($expected_name$dependency->getName());
    $this->assertSame($expected_project$dependency->getProject());
    $this->assertSame($expected_constraint$dependency->getConstraintString());
  }

  /** * Data provider for testCreateFromString. */
  public function providerCreateFromString() {
    $tests = [];
    $tests['module_name_only'] = ['views', 'views', '', ''];
    $tests['module_and_project_names'] = ['drupal:views', 'views', 'drupal', ''];
    $tests['module_and_constraint'] = ['views (<8.x-3.1)', 'views', '', '<8.x-3.1'];
    

  public function testCreateFromArray(array $changes, array $expected = []): void {
    $data = $changes;
    $data += $this->getValidData();
    $expected += $data;

    $sa = SecurityAdvisory::createFromArray($data);
    $this->assertInstanceOf(SecurityAdvisory::class$sa);
    $this->assertSame($expected['title']$sa->getTitle());
    $this->assertSame($expected['project']$sa->getProject());
    $this->assertSame($expected['type']$sa->getProjectType());
    $this->assertSame($expected['link']$sa->getUrl());
    $this->assertSame($expected['insecure']$sa->getInsecureVersions());
    $this->assertSame($expected['is_psa']$sa->isPsa());
    $this->assertSame($expected['type'] === 'core', $sa->isCoreAdvisory());
  }

  /** * Data provider for testCreateFromArray(). */
  public function providerCreateFromArray(): array {
    

  protected function getMatchingExtensionInfo(SecurityAdvisory $sa): ?array {
    if (!isset($this->extensionLists[$sa->getProjectType()])) {
      return NULL;
    }
    $project_info = new ProjectInfo();
    // The project name on the security advisory will not always match the     // machine name for the extension, so we need to search through all     // extensions of the expected type to find the matching project.     foreach ($this->extensionLists[$sa->getProjectType()]->getList() as $extension) {
      if ($project_info->getProjectName($extension) === $sa->getProject()) {
        return $extension->info;
      }
    }
    return NULL;
  }

  /** * Gets the existing project version. * * @param \Drupal\system\SecurityAdvisories\SecurityAdvisory $sa * The security advisory. * * @return string|null * The project version, or NULL if the project does not exist on * the site. */
Home | Imprint | This part of the site doesn't use cookies.