function ProjectReleaseTest::testOptionalFields

Same name in other branches
  1. 9 core/modules/update/tests/src/Unit/ProjectReleaseTest.php \Drupal\Tests\update\Unit\ProjectReleaseTest::testOptionalFields()
  2. 11.x core/modules/update/tests/src/Unit/ProjectReleaseTest.php \Drupal\Tests\update\Unit\ProjectReleaseTest::testOptionalFields()

Tests that optional fields can be omitted.

@covers ::createFromArray

File

core/modules/update/tests/src/Unit/ProjectReleaseTest.php, line 112

Class

ProjectReleaseTest
@coversDefaultClass \Drupal\update\ProjectRelease

Namespace

Drupal\Tests\update\Unit

Code

public function testOptionalFields() : void {
    $data = $this->getValidData();
    unset($data['core_compatible'], $data['core_compatibility_message'], $data['download_link'], $data['date'], $data['terms']);
    $release = ProjectRelease::createFromArray($data);
    $this->assertNull($release->isCoreCompatible());
    $this->assertNull($release->getCoreCompatibilityMessage());
    $this->assertNull($release->getDate());
    // Confirm that all getters that rely on 'terms' default to FALSE.
    $this->assertFalse($release->isSecurityRelease());
    $this->assertFalse($release->isInsecure());
    $this->assertFalse($release->isUnsupported());
}

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