public function ProjectReleaseTest::testCreateFromArrayInvalidField in Drupal 10
Same name and namespace in other branches
- 9 core/modules/update/tests/src/Unit/ProjectReleaseTest.php \Drupal\Tests\update\Unit\ProjectReleaseTest::testCreateFromArrayInvalidField()
Tests exceptions for invalid field types.
@covers ::createFromArray
@dataProvider providerCreateFromArrayInvalidField
Parameters
string $invalid_field: The field to test for an invalid value.
mixed $invalid_value: The invalid value to use in the field.
string $expected_message: The expected message for the field.
File
- core/
modules/ update/ tests/ src/ Unit/ ProjectReleaseTest.php, line 174
Class
- ProjectReleaseTest
- @coversDefaultClass \Drupal\update\ProjectRelease
Namespace
Drupal\Tests\update\UnitCode
public function testCreateFromArrayInvalidField(string $invalid_field, $invalid_value, string $expected_message) : void {
$data = $this
->getValidData();
// Set the field a value that is not valid for any of the fields in the
// feed.
$data[$invalid_field] = $invalid_value;
$this
->expectException(\UnexpectedValueException::class);
$expected_exception_message = 'Malformed release data:.*' . preg_quote("[{$invalid_field}]:", '/');
$expected_exception_message .= ".*{$expected_message}";
$this
->expectExceptionMessageMatches("/{$expected_exception_message}/s");
ProjectRelease::createFromArray($data);
}