Révision c8740e19
Ajouté par Assos Assos il y a plus de 9 ans
drupal7/sites/all/modules/link/tests/link.token.test | ||
---|---|---|
75 | 75 |
$name = $this->randomName(); |
76 | 76 |
$settings = array( |
77 | 77 |
'instance[settings][title]' => 'value', |
78 |
'instance[settings][title_value]' => $name .' [node:content-type:machine-name]'); |
|
78 |
'instance[settings][title_value]' => $name . ' [node:content-type:machine-name]');
|
|
79 | 79 |
$field_name = $this->createLinkField('page', $settings); |
80 | 80 |
|
81 | 81 |
// create page form |
... | ... | |
118 | 118 |
$name = $this->randomName(); |
119 | 119 |
$settings = array( |
120 | 120 |
'instance[settings][title]' => 'value', |
121 |
'instance[settings][title_value]' => $name .' [node:title]'); |
|
121 |
'instance[settings][title_value]' => $name . ' [node:title]');
|
|
122 | 122 |
$field_name = $this->createLinkField('page', $settings); |
123 | 123 |
|
124 | 124 |
// create page form |
... | ... | |
144 | 144 |
$this->drupalLogout(); |
145 | 145 |
$this->drupalGet($url); |
146 | 146 |
|
147 |
$this->assertRaw(l($name .' '. $name, $input['href']));
|
|
147 |
$this->assertRaw(l($name . ' ' . $name, $input['href']));
|
|
148 | 148 |
} |
149 | 149 |
|
150 | 150 |
// This test doesn't seem to actually work, due to lack of 'title' in url. |
... | ... | |
191 | 191 |
|
192 | 192 |
$edit = array(); |
193 | 193 |
$test_link_url = 'http://www.example.com/test'; |
194 |
$edit[$field_name .'[und][0][url]'] = $test_link_url; |
|
195 |
$title = 'title_'. $this->randomName(20); |
|
196 |
$edit[$field_name .'[und][0][title]'] = $title; |
|
194 |
$edit[$field_name . '[und][0][url]'] = $test_link_url;
|
|
195 |
$title = 'title_' . $this->randomName(20);
|
|
196 |
$edit[$field_name . '[und][0][title]'] = $title;
|
|
197 | 197 |
$edit['title'] = $name; |
198 | 198 |
|
199 | 199 |
$this->drupalGet('node/add/page'); |
... | ... | |
206 | 206 |
|
207 | 207 |
//$this->drupalGet('node/'. $node->nid); |
208 | 208 |
$this->assertText($title, 'Make sure the link title/text shows'); |
209 |
$this->assertRaw(' title="'. $test_link_url .'"', "Do we show the link url as the title attribute?");
|
|
210 |
$this->assertNoRaw(' title="['. $field_name .'-url]"');
|
|
209 |
$this->assertRaw(' title="' . $test_link_url . '"', "Do we show the link url as the title attribute?");
|
|
210 |
$this->assertNoRaw(' title="[' . $field_name . '-url]"');
|
|
211 | 211 |
$this->assertTrue(module_exists('token'), t('Assure that Token Module is enabled.')); |
212 | 212 |
//$this->fail($this->content); |
213 | 213 |
} |
... | ... | |
236 | 236 |
$field_db_info = content_database_info($field); |
237 | 237 |
$url_type = str_replace('_', '-', $this->content_types[0]->type); |
238 | 238 |
|
239 |
$edit = array('attributes[title]' => '['. $field_name .'-title]',
|
|
239 |
$edit = array('attributes[title]' => '[' . $field_name . '-title]',
|
|
240 | 240 |
'enable_tokens' => TRUE); |
241 | 241 |
|
242 |
$this->drupalPost('admin/content/node-type/'. $url_type .'/fields/'. $field['field_name'],
|
|
242 |
$this->drupalPost('admin/content/node-type/' . $url_type . '/fields/' . $field['field_name'],
|
|
243 | 243 |
$edit, t('Save field settings')); |
244 | 244 |
$this->assertText(t('Saved field @field_name', array('@field_name' => $field['field_name']))); |
245 | 245 |
|
... | ... | |
248 | 248 |
|
249 | 249 |
$node = node_load($this->nodes[0]->nid); |
250 | 250 |
|
251 |
$this->drupalGet('node/'. $this->nodes[0]->nid); |
|
251 |
$this->drupalGet('node/' . $this->nodes[0]->nid);
|
|
252 | 252 |
|
253 | 253 |
$edit = array(); |
254 |
$edit[$field['field_name'] .'[0][url]'] = 'http://www.example.com/test'; |
|
255 |
$title = 'title_'. $this->randomName(20); |
|
256 |
$edit[$field['field_name'] .'[0][title]'] = $title; |
|
254 |
$edit[$field['field_name'] . '[0][url]'] = 'http://www.example.com/test';
|
|
255 |
$title = 'title_' . $this->randomName(20);
|
|
256 |
$edit[$field['field_name'] . '[0][title]'] = $title;
|
|
257 | 257 |
|
258 |
$this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
|
|
258 |
$this->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
|
|
259 | 259 |
|
260 | 260 |
// Make sure we get a new version! |
261 | 261 |
$node = node_load($this->nodes[0]->nid, NULL, TRUE); |
... | ... | |
263 | 263 |
array('@title' => $node->title, |
264 | 264 |
'@type' => $this->content_types[0]->name))); |
265 | 265 |
|
266 |
$this->drupalGet('node/'. $node->nid); |
|
266 |
$this->drupalGet('node/' . $node->nid);
|
|
267 | 267 |
$this->assertText($title, 'Make sure the link title/text shows'); |
268 |
$this->assertNoRaw(' title="'. $title .'"', "We should not show the link title as the title attribute?");
|
|
269 |
$this->assertNoRaw(' title="['. $field_name .'-title]"');
|
|
268 |
$this->assertNoRaw(' title="' . $title . '"', "We should not show the link title as the title attribute?");
|
|
269 |
$this->assertNoRaw(' title="[' . $field_name . '-title]"');
|
|
270 | 270 |
//$this->fail($this->content); |
271 | 271 |
} |
272 | 272 |
|
... | ... | |
319 | 319 |
$this->drupalLogout(); |
320 | 320 |
$this->drupalGet($url); |
321 | 321 |
|
322 |
$this->assertRaw(l($input['label'], $input['href'] .'/page')); |
|
322 |
$this->assertRaw(l($input['label'], $input['href'] . '/page'));
|
|
323 | 323 |
//$this->fail($this->content); |
324 | 324 |
} |
325 | 325 |
|
... | ... | |
372 | 372 |
$this->drupalLogout(); |
373 | 373 |
$this->drupalGet($url); |
374 | 374 |
|
375 |
$this->assertRaw(l($input['label'], $input['href'] .'/'. $this->web_user->uid)); |
|
375 |
$this->assertRaw(l($input['label'], $input['href'] . '/' . $this->web_user->uid)); |
|
376 |
} |
|
377 |
|
|
378 |
/** |
|
379 |
* Test that if you have a title and no url on a field which does not have tokens enabled, |
|
380 |
* that the title is sanitized once. |
|
381 |
*/ |
|
382 |
function testCRUDTitleOnlyTitleNoLink2() { |
|
383 |
$this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content')); |
|
384 |
$this->drupalLogin($this->web_user); |
|
385 |
|
|
386 |
// create field |
|
387 |
$name = strtolower($this->randomName()); |
|
388 |
$field_name = 'field_' . $name; |
|
389 |
$edit = array( |
|
390 |
'fields[_add_new_field][label]' => $name, |
|
391 |
'fields[_add_new_field][field_name]' => $name, |
|
392 |
'fields[_add_new_field][type]' => 'link_field', |
|
393 |
'fields[_add_new_field][widget_type]' => 'link_field', |
|
394 |
); |
|
395 |
$this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save')); |
|
396 |
$this->drupalPost(NULL, array(), t('Save field settings')); |
|
397 |
$this->drupalPost(NULL, array( |
|
398 |
'instance[settings][url]' => 1, |
|
399 |
'instance[settings][enable_tokens]' => 0, |
|
400 |
), t('Save settings')); |
|
401 |
|
|
402 |
// Is field created? |
|
403 |
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added'); |
|
404 |
|
|
405 |
// create page form |
|
406 |
$this->drupalGet('node/add/page'); |
|
407 |
$this->assertField($field_name . '[und][0][url]', 'URL found'); |
|
408 |
|
|
409 |
$input = array( |
|
410 |
'title' => 'This & That', |
|
411 |
'href' => '', |
|
412 |
); |
|
413 |
|
|
414 |
$edit = array( |
|
415 |
'title' => $name, |
|
416 |
$field_name . '[und][0][title]' => $input['title'], |
|
417 |
$field_name . '[und][0][url]' => $input['href'], |
|
418 |
); |
|
419 |
$this->drupalPost(NULL, $edit, t('Save')); |
|
420 |
|
|
421 |
$url = $this->getUrl(); |
|
422 |
|
|
423 |
// change to anonymous user |
|
424 |
$this->drupalLogout(); |
|
425 |
$this->drupalGet($url); |
|
426 |
|
|
427 |
$this->assertRaw('This & That'); |
|
376 | 428 |
} |
377 | 429 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules