You are here

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

Test it can be created by a DateTime object.

File

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

Class

TimeTest
Tests time.

Namespace

Drupal\Tests\time_field\Unit

Code

public function testItCanBeCreatedByDateTime() {
  $time = Time::createFromDateTime(new \DateTime('2020-09-08 13:33:26'));
  $this
    ->assertEquals('13', $time
    ->getHour());
  $this
    ->assertEquals('33', $time
    ->getMinute());
  $this
    ->assertEquals('26', $time
    ->getSecond());
}