function SecurityAdvisoryTest::testCreateFromArray

Same name in other branches
  1. 10 core/modules/system/tests/src/Unit/SecurityAdvisories/SecurityAdvisoryTest.php \Drupal\Tests\system\Unit\SecurityAdvisories\SecurityAdvisoryTest::testCreateFromArray()
  2. 11.x core/modules/system/tests/src/Unit/SecurityAdvisories/SecurityAdvisoryTest.php \Drupal\Tests\system\Unit\SecurityAdvisories\SecurityAdvisoryTest::testCreateFromArray()

Tests creating with valid data.

@covers ::createFromArray @covers ::isCoreAdvisory @covers ::isPsa

@dataProvider providerCreateFromArray

Parameters

mixed[] $changes: The changes to the valid data set to test.

mixed[] $expected: The expected changes for the object methods.

File

core/modules/system/tests/src/Unit/SecurityAdvisories/SecurityAdvisoryTest.php, line 29

Class

SecurityAdvisoryTest
@coversDefaultClass \Drupal\system\SecurityAdvisories\SecurityAdvisory

Namespace

Drupal\Tests\system\Unit\SecurityAdvisories

Code

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());
}

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