You are here

public function ProjectReleaseTest::testOptionalFields in Drupal 9

Tests that optional fields can be omitted.

@covers ::createFromArray

File

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

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