function BytesTest::testValidate
Same name in other branches
- 9 core/tests/Drupal/Tests/Component/Utility/BytesTest.php \Drupal\Tests\Component\Utility\BytesTest::testValidate()
- 11.x core/tests/Drupal/Tests/Component/Utility/BytesTest.php \Drupal\Tests\Component\Utility\BytesTest::testValidate()
Tests \Drupal\Component\Utility\Bytes::validate().
@dataProvider providerTestValidate @covers ::validate @covers ::validateConstraint
Parameters
string $string: The value for the string argument for \Drupal\Component\Utility\Bytes::validate().
bool $expected_result: The expected return value from \Drupal\Component\Utility\Bytes::validate().
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ BytesTest.php, line 94
Class
- BytesTest
- Tests bytes size parsing helper methods.
Namespace
Drupal\Tests\Component\UtilityCode
public function testValidate($string, bool $expected_result) : void {
$this->assertSame($expected_result, Bytes::validate($string));
$execution_context = $this->prophesize(ExecutionContextInterface::class);
if ($expected_result) {
$execution_context->addViolation(Argument::cetera())
->shouldNotBeCalled();
}
else {
$execution_context->addViolation(Argument::cetera())
->shouldBeCalledTimes(1);
}
Bytes::validateConstraint($string, $execution_context->reveal());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.