/** * @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(); }