public function TestObjectItemTest::testTestObjectItem in Drupal 8
Same name and namespace in other branches
- 9 core/modules/field/tests/src/Kernel/TestObjectItemTest.php \Drupal\Tests\field\Kernel\TestObjectItemTest::testTestObjectItem()
- 10 core/modules/field/tests/src/Kernel/TestObjectItemTest.php \Drupal\Tests\field\Kernel\TestObjectItemTest::testTestObjectItem()
Tests the serialization of a field type that has an object.
File
- core/
modules/ field/ tests/ src/ Kernel/ TestObjectItemTest.php, line 45
Class
- TestObjectItemTest
- Tests the serialization of an object.
Namespace
Drupal\Tests\field\KernelCode
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
->assertInstanceOf(\stdClass::class, $entity->field_test->value);
$this
->assertEquals($object, $entity->field_test->value);
}