'field_test', 'entity_type' => 'entity_test', 'type' => 'test_object_field', ])->save(); FieldConfig::create([ 'entity_type' => 'entity_test', 'field_name' => 'field_test', 'bundle' => 'entity_test', ])->save(); } /** * Tests the serialization of a field type that has an object. */ public function testTestObjectItem() { $object = new \stdClass(); $object->foo = 'bar'; $entity = EntityTest::create(); $entity->field_test->value = $object; $entity->save(); // Verify that the entity has been created properly. $id = $entity->id(); $entity = EntityTest::load($id); $this->assertTrue($entity->field_test->value instanceof \stdClass); $this->assertEquals($object, $entity->field_test->value); } }