You are here

public function TimeTest::testItCanBeCreatedByHtml5String in Time Field For Drupal 8.x / 9.x 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/TimeTest.php \Drupal\Tests\time_field\Unit\TimeTest::testItCanBeCreatedByHtml5String()

Test it can be created by html5 string.

File

tests/src/Unit/TimeTest.php, line 26

Class

TimeTest
Tests time.

Namespace

Drupal\Tests\time_field\Unit

Code

public function testItCanBeCreatedByHtml5String() {
  $time = Time::createFromHtml5Format('13:40:30');
  $this
    ->assertEquals('13', $time
    ->getHour());
  $this
    ->assertEquals('40', $time
    ->getMinute());
  $this
    ->assertEquals('30', $time
    ->getSecond());
  $time = Time::createFromHtml5Format('14:50');
  $this
    ->assertEquals('14', $time
    ->getHour());
  $this
    ->assertEquals('50', $time
    ->getMinute());
  $this
    ->assertEquals('0', $time
    ->getSecond());
}