Esempio n. 1
0
 /**
  * Tests that vocabulary machine name changes are mirrored in field definitions.
  */
 function testTaxonomyTermFieldChangeMachineName()
 {
     // Add several entries in the 'allowed_values' setting, to make sure that
     // they all get updated.
     $this->fieldStorage->setSetting('allowed_values', [array('vocabulary' => $this->vocabulary->id(), 'parent' => '0'), array('vocabulary' => $this->vocabulary->id(), 'parent' => '0'), array('vocabulary' => 'foo', 'parent' => '0')]);
     $this->fieldStorage->save();
     // Change the machine name.
     $new_name = Unicode::strtolower($this->randomMachineName());
     $this->vocabulary->set('vid', $new_name);
     $this->vocabulary->save();
     // Check that the field is still attached to the vocabulary.
     $field_storage = FieldStorageConfig::loadByName('entity_test', $this->fieldName);
     $allowed_values = $field_storage->getSetting('allowed_values');
     $this->assertEqual($allowed_values[0]['vocabulary'], $new_name, 'Index 0: Machine name was updated correctly.');
     $this->assertEqual($allowed_values[1]['vocabulary'], $new_name, 'Index 1: Machine name was updated correctly.');
     $this->assertEqual($allowed_values[2]['vocabulary'], 'foo', 'Index 2: Machine name was left untouched.');
 }