isCoreAdvisory example

/** * 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. */
  protected function getProjectExistingVersion(SecurityAdvisory $sa): ?string {
    if ($sa->isCoreAdvisory()) {
      return \Drupal::VERSION;
    }
    $extension_info = $this->getMatchingExtensionInfo($sa);
    return $extension_info['version'] ?? NULL;
  }

  /** * Determines if a security advisory is applicable for the current site. * * @param \Drupal\system\SecurityAdvisories\SecurityAdvisory $sa * The security advisory. * * @return bool * TRUE if the advisory is applicable for the current site, or FALSE * otherwise. */
$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 {
    return [
      // For 'is_psa' the return value should converted to any array.       [
        ['is_psa' => 1],
        ['is_psa' => TRUE],
      ],
Home | Imprint | This part of the site doesn't use cookies.