public function OgMembershipTest::testGetSetCreatedTime in Organic groups 8
Tests getting and setting the creation time.
@covers ::getCreatedTime @covers ::setCreatedTime
File
- tests/
src/ Kernel/ Entity/ OgMembershipTest.php, line 739
Class
- OgMembershipTest
- Tests the OgMembership entity.
Namespace
Drupal\Tests\og\Kernel\EntityCode
public function testGetSetCreatedTime() {
// When creating a brand new membership the request time should be set as
// the creation time.
// @todo Replace this with \Drupal::time()->getRequestTime() in Drupal 9.
$expected_time = (int) $_SERVER['REQUEST_TIME'];
$membership = OgMembership::create();
$this
->assertEquals($expected_time, $membership
->getCreatedTime());
// Try setting a custom creation time and retrieving it.
$custom_time = strtotime('January 1, 2019');
$created_time = $membership
->setCreatedTime($custom_time)
->getCreatedTime();
$this
->assertEquals($custom_time, $created_time);
}