本文整理汇总了PHP中ElggObject::setCurrentTime方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggObject::setCurrentTime方法的具体用法?PHP ElggObject::setCurrentTime怎么用?PHP ElggObject::setCurrentTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggObject
的用法示例。
在下文中一共展示了ElggObject::setCurrentTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanSaveNewObject
/**
* @group current
*/
public function testCanSaveNewObject()
{
$subtype = 'test_subtype';
$subtype_id = add_subtype('object', $subtype);
$user = $this->mocks()->getUser();
_elgg_services()->session->setLoggedInUser($user);
$object = new \ElggObject();
$object->subtype = $subtype;
$object->title = 'Foo';
$object->description = 'Bar';
$object->owner_guid = $user->guid;
$object->container_guid = $user->guid;
$object->access_id = ACCESS_LOGGED_IN;
$object->time_created = time();
$object->setCurrentTime();
// We should be able to match timestamps
$now = $object->getCurrentTime()->getTimestamp();
$guid = $object->save();
$this->assertNotFalse($guid);
$object = get_entity($guid);
$this->assertEquals('object', $object->type);
$this->assertEquals($subtype_id, $object->subtype);
$this->assertEquals('Foo', $object->title);
$this->assertEquals('Foo', $object->getDisplayName());
$this->assertEquals('Bar', $object->description);
$this->assertEquals($user->guid, $object->getOwnerGUID());
$this->assertEquals($user, $object->getOwnerEntity());
$this->assertEquals($user->guid, $object->getContainerGUID());
$this->assertEquals($user, $object->getContainerEntity());
$this->assertEquals(ACCESS_LOGGED_IN, $object->access_id);
_elgg_services()->session->removeLoggedInUser();
}