public function WordLinkWebTestCase::testWordLinkCreate in Word Link 7.2
Tests creation and editing of a word.
File
- tests/
word_link.test, line 44 - Tests for the Word Link module.
Class
- WordLinkWebTestCase
- Base class for Word Link web test cases.
Code
public function testWordLinkCreate() {
// Create word to edit.
$edit = array(
'word[text]' => $this
->randomName(8),
'word[weight]' => 0,
'word[url]' => 'http://drupal.org',
'word[class]' => $this
->randomName(8),
);
$this
->drupalPost('admin/config/content/word-link/add', $edit, t('Save'));
$this
->assertRaw(t('Word %text has been @action.', array(
'%text' => $edit['word[text]'],
'@action' => 'created',
)));
$words = word_link_load_all();
$word = (array) current($words);
unset($word['text_lower']);
$word['text'] = $this
->randomName(8);
foreach ($word as $delta => $value) {
$edit['word[' . $delta . ']'] = $value;
}
$this
->drupalPost('admin/config/content/word-link/edit/' . $word['id'], $edit, t('Save'));
$this
->assertRaw(t('Word %text has been @action.', array(
'%text' => $word['text'],
'@action' => 'updated',
)));
$this
->drupalGet('admin/config/content/word-link/delete/' . $word['id']);
$this
->assertRaw(t('Are you sure you want to delete %title?', array(
'%title' => $word['text'],
)));
$this
->drupalPost('admin/config/content/word-link/delete/' . $word['id'], array(), t('Delete'));
$this
->assertRaw(t('Word %text has been deleted.', array(
'%text' => $word['text'],
)));
}