function ProjectReleaseTest::testOptionalFields

Same name and namespace in other branches
  1. 9 core/modules/update/tests/src/Unit/ProjectReleaseTest.php \Drupal\Tests\update\Unit\ProjectReleaseTest::testOptionalFields()
  2. 10 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 <a href="/api/drupal/core%21modules%21update%21src%21ProjectRelease.php/class/ProjectRelease/11.x" title="Provides a project release value object." class="local">\Drupal\update\ProjectRelease</a>

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.