c5ace377492b6713d38687d2d34d28de0cf93797
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Entity / EntityBundleListenerTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Entity;
4
5 /**
6  * @coversDefaultClass \Drupal\Core\Entity\EntityBundleListener
7  *
8  * @group Entity
9  */
10 class EntityBundleListenerTest extends EntityKernelTestBase {
11
12   /**
13    * @covers ::onBundleCreate
14    *
15    * Note: Installing the entity_schema_test module will mask the bug this test
16    * was written to cover, as the field map cache is cleared manually by
17    * \Drupal\Core\Field\FieldDefinitionListener::onFieldDefinitionCreate().
18    */
19   public function testOnBundleCreate() {
20     $field_map = $this->container->get('entity_field.manager')->getFieldMap();
21     $expected = [
22       'entity_test' => 'entity_test',
23     ];
24     $this->assertEquals($expected, $field_map['entity_test']['id']['bundles']);
25
26     entity_test_create_bundle('custom');
27     $field_map = $this->container->get('entity_field.manager')->getFieldMap();
28     $expected = [
29       'entity_test' => 'entity_test',
30       'custom' => 'custom',
31     ];
32     $this->assertSame($expected, $field_map['entity_test']['id']['bundles']);
33   }
34
35 }