Created
October 31, 2020 08:30
-
-
Save chx/66449f2aeb36aa37c7bba05253dab197 to your computer and use it in GitHub Desktop.
map item test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\Tests\field\Kernel; | |
use Drupal\entity_test\Entity\EntityTestMapField; | |
class MapItemTest extends FieldKernelTestBase { | |
protected function setUp(): void { | |
parent::setUp(); | |
$this->installEntitySchema('entity_test_map_field'); | |
} | |
public function testMapItem() { | |
$name = $this->randomString(); | |
$data = []; | |
for ($i = 0; $i <= 4; $i++) { | |
$data[$this->randomMachineName()] = $this->randomString(); | |
} | |
$entity = EntityTestMapField::create([ | |
'name' => $name, | |
'data' => $data, | |
]); | |
$entity = $this->entitySaveReload($entity); | |
$this->assertSame($name, $entity->label()); | |
foreach ($data as $k => $v) { | |
$this->assertSame($v, $entity->data->$k); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment