danielebarchiesi@4: 'Link CRUD - Basic API tests', danielebarchiesi@4: 'description' => 'Tests the field CRUD (create, read, update, delete) API.', danielebarchiesi@4: 'group' => 'Link', danielebarchiesi@4: ); danielebarchiesi@4: } danielebarchiesi@4: danielebarchiesi@4: function setUp() { danielebarchiesi@4: parent::setUp('field_ui', 'link'); danielebarchiesi@4: } danielebarchiesi@4: danielebarchiesi@4: /** danielebarchiesi@4: * All we're doing here is creating a content type, creating a simple link field danielebarchiesi@4: * on that content type. danielebarchiesi@4: */ danielebarchiesi@4: function testLinkCreateFieldAPI() { danielebarchiesi@4: $content_type_friendly = $this->randomName(20); danielebarchiesi@4: $content_type_machine = strtolower($this->randomName(10)); danielebarchiesi@4: $title = $this->randomName(20); danielebarchiesi@4: danielebarchiesi@4: // Create and login user. danielebarchiesi@4: $this->web_user = $this->drupalCreateUser(array('administer content types')); danielebarchiesi@4: $this->drupalLogin($this->web_user); danielebarchiesi@4: danielebarchiesi@4: $this->drupalGet('admin/structure/types'); danielebarchiesi@4: danielebarchiesi@4: // Create the content type. danielebarchiesi@4: $this->clickLink(t('Add content type')); danielebarchiesi@4: danielebarchiesi@4: $edit = array ( danielebarchiesi@4: 'name' => $content_type_friendly, danielebarchiesi@4: 'type' => $content_type_machine, danielebarchiesi@4: ); danielebarchiesi@4: $this->drupalPost(NULL, $edit, t('Save and add fields')); danielebarchiesi@4: $this->assertText(t('The content type @name has been added.', array('@name' => $content_type_friendly))); danielebarchiesi@4: danielebarchiesi@4: //$field = $this->createField(array('type' => 'link', 'widget_type' => 'link'), 0); danielebarchiesi@4: // Now add a singleton field. danielebarchiesi@4: $single_field_name_friendly = $this->randomName(20); danielebarchiesi@4: $single_field_name_machine = strtolower($this->randomName(10)); danielebarchiesi@4: $edit = array ( danielebarchiesi@4: 'fields[_add_new_field][label]' => $single_field_name_friendly, danielebarchiesi@4: 'fields[_add_new_field][field_name]' => $single_field_name_machine, danielebarchiesi@4: 'fields[_add_new_field][type]' => 'link_field', danielebarchiesi@4: 'fields[_add_new_field][widget_type]' => 'link_field', danielebarchiesi@4: ); danielebarchiesi@4: $this->drupalPost(NULL, $edit, t('Save')); danielebarchiesi@4: danielebarchiesi@4: // We'll go with the default settings for this run-through. danielebarchiesi@4: $this->drupalPost(NULL, array(), t('Save field settings')); danielebarchiesi@4: danielebarchiesi@4: // Using all the default settings, so press the button. danielebarchiesi@4: $this->drupalPost(NULL, array(), t('Save settings')); danielebarchiesi@4: $this->assertText(t('Saved @name configuration.', array('@name' => $single_field_name_friendly))); danielebarchiesi@4: danielebarchiesi@4: // Somehow clicking "save" isn't enough, and we have to do a danielebarchiesi@4: // node_types_rebuild(). danielebarchiesi@4: node_types_rebuild(); danielebarchiesi@4: menu_rebuild(); danielebarchiesi@4: $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField(); danielebarchiesi@4: $this->assertTrue($type_exists, 'The new content type has been created in the database.'); danielebarchiesi@4: danielebarchiesi@4: /*$table_schema = drupal_get_schema(); danielebarchiesi@4: $this->assertEqual(1, 1, print_r(array_keys($table_schema), TRUE)); danielebarchiesi@4: // Check the schema - the values should be in the per-type table. danielebarchiesi@4: $this->assertSchemaMatchesTables(array( danielebarchiesi@4: 'per_type' => array( danielebarchiesi@4: $this->content_types[0]->type => array($field['field_name'] => array('url', 'title', 'attributes')), danielebarchiesi@4: ), danielebarchiesi@4: ));*/ danielebarchiesi@4: } danielebarchiesi@4: }