Chris@0: installEntitySchema('entity_test'); Chris@0: $this->installEntitySchema('user'); Chris@0: Chris@0: $storage = $this->container->get('entity_type.manager')->getStorage('entity_form_display'); Chris@0: $this->entityFormDisplay = $storage->create([ Chris@0: 'targetEntityType' => 'entity_test', Chris@0: 'bundle' => 'entity_test', Chris@0: 'mode' => 'default', Chris@0: 'status' => TRUE, Chris@0: ]); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests the widget with the locked languages. Chris@0: */ Chris@0: public function testWithIncludedLockedLanguage() { Chris@0: $this->entityFormDisplay->setComponent('langcode', [ Chris@0: 'type' => 'language_select', Chris@0: ])->save(); Chris@0: $entity = EntityTest::create(['name' => $this->randomString()]); Chris@0: $form = $this->container->get('entity.form_builder')->getForm($entity); Chris@0: $options = array_keys($form['langcode']['widget'][0]['value']['#options']); Chris@0: $this->assertSame(['en', 'und', 'zxx'], $options); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Test the widget without the locked languages. Chris@0: */ Chris@0: public function testWithoutIncludedLockedLanguage() { Chris@0: $this->entityFormDisplay->setComponent('langcode', [ Chris@0: 'type' => 'language_select', Chris@0: 'settings' => ['include_locked' => FALSE], Chris@0: ])->save(); Chris@0: $entity = EntityTest::create(['name' => $this->randomString()]); Chris@0: $form = $this->container->get('entity.form_builder')->getForm($entity); Chris@0: $options = array_keys($form['langcode']['widget'][0]['value']['#options']); Chris@0: $this->assertSame(['en'], $options); Chris@0: } Chris@0: Chris@0: }