function BytesTest::testValidate
Tests \Drupal\Component\Utility\Bytes::validate().
@legacy-covers ::validate @legacy-covers ::validateConstraint
Attributes
#[DataProvider('providerTestValidate')]
  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.