function ProjectReleaseTest::testCreateFromArray
Same name in other branches
- 9 core/modules/update/tests/src/Unit/ProjectReleaseTest.php \Drupal\Tests\update\Unit\ProjectReleaseTest::testCreateFromArray()
- 10 core/modules/update/tests/src/Unit/ProjectReleaseTest.php \Drupal\Tests\update\Unit\ProjectReleaseTest::testCreateFromArray()
Tests creating with valid data.
@covers ::createFromArray @covers ::isInsecure @covers ::isSecurityRelease @covers ::isPublished @covers ::isUnsupported @covers ::isUnsupported
@dataProvider providerCreateFromArray
Parameters
mixed[] $data: The data to test. It will be combined with ::getValidData() results.
mixed[] $expected: The values expected to be returned from the object methods.
File
-
core/
modules/ update/ tests/ src/ Unit/ ProjectReleaseTest.php, line 34
Class
- ProjectReleaseTest
- @coversDefaultClass \Drupal\update\ProjectRelease
Namespace
Drupal\Tests\update\UnitCode
public function testCreateFromArray(array $data, array $expected = []) : void {
$data += $this->getValidData();
$expected += $data;
// If not set provide default values that match ::getValidData().
$expected += [
'is_published' => TRUE,
'is_unsupported' => TRUE,
'is_security_release' => TRUE,
'is_insecure' => TRUE,
];
$release = ProjectRelease::createFromArray($data);
$this->assertInstanceOf(ProjectRelease::class, $release);
$this->assertSame($expected['version'], $release->getVersion());
$this->assertSame($expected['date'], $release->getDate());
$this->assertSame($expected['download_link'], $release->getDownloadUrl());
$this->assertSame($expected['release_link'], $release->getReleaseUrl());
$this->assertSame($expected['core_compatibility_message'], $release->getCoreCompatibilityMessage());
$this->assertSame($expected['core_compatible'], $release->isCoreCompatible());
$this->assertSame($expected['is_published'], $release->isPublished());
$this->assertSame($expected['is_unsupported'], $release->isUnsupported());
$this->assertSame($expected['is_security_release'], $release->isSecurityRelease());
$this->assertSame($expected['is_insecure'], $release->isInsecure());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.