1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
39a181a4
|
Assos Assos
|
* File for Crud Tests.
|
6 |
|
|
*
|
7 |
|
|
* Basic CRUD simpletests for the link module, based off of content.crud.test in
|
8 |
|
|
* CCK.
|
9 |
85ad3d82
|
Assos Assos
|
*/
|
10 |
|
|
|
11 |
39a181a4
|
Assos Assos
|
/**
|
12 |
|
|
* Content Crud.
|
13 |
|
|
*/
|
14 |
85ad3d82
|
Assos Assos
|
class LinkContentCrudTest extends DrupalWebTestCase {
|
15 |
|
|
|
16 |
39a181a4
|
Assos Assos
|
/**
|
17 |
|
|
* Get Info.
|
18 |
|
|
*/
|
19 |
85ad3d82
|
Assos Assos
|
public static function getInfo() {
|
20 |
|
|
return array(
|
21 |
|
|
'name' => 'Link CRUD - Basic API tests',
|
22 |
|
|
'description' => 'Tests the field CRUD (create, read, update, delete) API.',
|
23 |
|
|
'group' => 'Link',
|
24 |
|
|
);
|
25 |
|
|
}
|
26 |
|
|
|
27 |
39a181a4
|
Assos Assos
|
/**
|
28 |
8e7483ab
|
Assos Assos
|
* {@inheritdoc}
|
29 |
39a181a4
|
Assos Assos
|
*/
|
30 |
8e7483ab
|
Assos Assos
|
public function setUp(array $modules = array()) {
|
31 |
|
|
$modules[] = 'field_ui';
|
32 |
|
|
$modules[] = 'link';
|
33 |
|
|
parent::setUp($modules);
|
34 |
85ad3d82
|
Assos Assos
|
}
|
35 |
|
|
|
36 |
|
|
/**
|
37 |
39a181a4
|
Assos Assos
|
* Create Field API.
|
38 |
|
|
*
|
39 |
|
|
* All we're doing here is creating a content type, creating a simple link
|
40 |
|
|
* field on that content type.
|
41 |
85ad3d82
|
Assos Assos
|
*/
|
42 |
8e7483ab
|
Assos Assos
|
public function testLinkCreateFieldApi() {
|
43 |
85ad3d82
|
Assos Assos
|
$content_type_friendly = $this->randomName(20);
|
44 |
|
|
$content_type_machine = strtolower($this->randomName(10));
|
45 |
|
|
|
46 |
|
|
// Create and login user.
|
47 |
39a181a4
|
Assos Assos
|
$this->web_user = $this->drupalCreateUser(array(
|
48 |
|
|
'administer content types',
|
49 |
|
|
'administer fields',
|
50 |
|
|
));
|
51 |
85ad3d82
|
Assos Assos
|
$this->drupalLogin($this->web_user);
|
52 |
|
|
|
53 |
|
|
$this->drupalGet('admin/structure/types');
|
54 |
|
|
|
55 |
|
|
// Create the content type.
|
56 |
|
|
$this->clickLink(t('Add content type'));
|
57 |
|
|
|
58 |
c8740e19
|
Assos Assos
|
$edit = array(
|
59 |
85ad3d82
|
Assos Assos
|
'name' => $content_type_friendly,
|
60 |
|
|
'type' => $content_type_machine,
|
61 |
|
|
);
|
62 |
|
|
$this->drupalPost(NULL, $edit, t('Save and add fields'));
|
63 |
|
|
$this->assertText(t('The content type @name has been added.', array('@name' => $content_type_friendly)));
|
64 |
|
|
|
65 |
|
|
// Now add a singleton field.
|
66 |
|
|
$single_field_name_friendly = $this->randomName(20);
|
67 |
|
|
$single_field_name_machine = strtolower($this->randomName(10));
|
68 |
c8740e19
|
Assos Assos
|
$edit = array(
|
69 |
85ad3d82
|
Assos Assos
|
'fields[_add_new_field][label]' => $single_field_name_friendly,
|
70 |
|
|
'fields[_add_new_field][field_name]' => $single_field_name_machine,
|
71 |
|
|
'fields[_add_new_field][type]' => 'link_field',
|
72 |
|
|
'fields[_add_new_field][widget_type]' => 'link_field',
|
73 |
|
|
);
|
74 |
|
|
$this->drupalPost(NULL, $edit, t('Save'));
|
75 |
|
|
|
76 |
|
|
// We'll go with the default settings for this run-through.
|
77 |
|
|
$this->drupalPost(NULL, array(), t('Save field settings'));
|
78 |
|
|
|
79 |
|
|
// Using all the default settings, so press the button.
|
80 |
|
|
$this->drupalPost(NULL, array(), t('Save settings'));
|
81 |
|
|
$this->assertText(t('Saved @name configuration.', array('@name' => $single_field_name_friendly)));
|
82 |
|
|
|
83 |
|
|
// Somehow clicking "save" isn't enough, and we have to do a
|
84 |
|
|
// node_types_rebuild().
|
85 |
|
|
node_types_rebuild();
|
86 |
|
|
menu_rebuild();
|
87 |
|
|
$type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
|
88 |
|
|
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
|
89 |
|
|
}
|
90 |
39a181a4
|
Assos Assos
|
|
91 |
85ad3d82
|
Assos Assos
|
} |