fields.test 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. class CerFieldTestCase extends DrupalWebTestCase {
  3. public static function getInfo() {
  4. return array(
  5. 'name' => 'Fields',
  6. 'group' => 'Corresponding Entity Reference',
  7. 'description' => 'Tests integration with the Field API.',
  8. );
  9. }
  10. public function setUp() {
  11. parent::setUp('field', 'field_sql_storage', 'ctools', 'entityreference', 'cer');
  12. field_create_field(array(
  13. 'field_name' => 'field_user',
  14. 'type' => 'entityreference',
  15. 'cardinality' => -1,
  16. 'settings' => array(
  17. 'target_type' => 'user',
  18. ),
  19. ));
  20. field_create_field(array(
  21. 'field_name' => 'field_node',
  22. 'type' => 'entityreference',
  23. 'cardinality' => -1,
  24. 'settings' => array(
  25. 'target_type' => 'node',
  26. ),
  27. ));
  28. field_create_instance(array(
  29. 'field_name' => 'field_user',
  30. 'entity_type' => 'node',
  31. 'bundle' => 'page',
  32. ));
  33. field_create_instance(array(
  34. 'field_name' => 'field_node',
  35. 'entity_type' => 'user',
  36. 'bundle' => 'user',
  37. ));
  38. ctools_include('export');
  39. $preset = ctools_export_crud_new('cer');
  40. $preset->entity_types_content_fields = 'node*page*field_user*user*user*field_node';
  41. $preset->enabled = TRUE;
  42. ctools_export_crud_save('cer', $preset);
  43. }
  44. public function testFieldInstanceDelete() {
  45. field_delete_instance(field_info_instance('user', 'field_node', 'user'));
  46. $preset = cer_preset_load('node*page*field_user*user*user*field_node');
  47. $this->assertNull($preset, 'Deleting a field instance clears CER presets for that instance.');
  48. }
  49. public function testFieldDelete() {
  50. field_delete_field('field_user');
  51. $preset = cer_preset_load('node*page*field_user*user*user*field_node');
  52. $this->assertNull($preset, 'Deleting a field clears CER presets for that field.');
  53. }
  54. }