public function ProjectReleaseTest::testCreateFromArrayMissingField in Drupal 10
Same name and namespace in other branches
- 9 core/modules/update/tests/src/Unit/ProjectReleaseTest.php \Drupal\Tests\update\Unit\ProjectReleaseTest::testCreateFromArrayMissingField()
Tests exceptions with missing fields.
@covers ::createFromArray
@dataProvider providerCreateFromArrayMissingField
Parameters
string $missing_field: The field to test.
File
- core/
modules/ update/ tests/ src/ Unit/ ProjectReleaseTest.php, line 139
Class
- ProjectReleaseTest
- @coversDefaultClass \Drupal\update\ProjectRelease
Namespace
Drupal\Tests\update\UnitCode
public function testCreateFromArrayMissingField(string $missing_field) : void {
$data = $this
->getValidData();
unset($data[$missing_field]);
$this
->expectException(\UnexpectedValueException::class);
$expected_message = 'Malformed release data:.*' . preg_quote("[{$missing_field}]:", '/');
$expected_message .= '.*This field is missing';
$this
->expectExceptionMessageMatches("/{$expected_message}/s");
ProjectRelease::createFromArray($data);
}