Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
7f965d0b
Commit
7f965d0b
authored
Aug 02, 2008
by
Dries
Browse files
- Patch
#276581
by andreiashu and cwgordon7: added tests for contact form categories.
parent
0bbad33a
Changes
1
Hide whitespace changes
Inline
Side-by-side
modules/contact/contact.test
View file @
7f965d0b
...
...
@@ -60,7 +60,17 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$recipients
=
array
(
'simpletest@example.com'
,
'simpletest2@example.com'
,
'simpletest3@example.com'
);
$this
->
addCategory
(
$category
=
$this
->
randomName
(
16
),
implode
(
','
,
array
(
$recipients
[
0
])),
''
,
TRUE
);
$this
->
assertRaw
(
t
(
'Category %category has been added.'
,
array
(
'%category'
=>
$category
)),
t
(
'Category successfully added.'
));
// Test update contact form category
$categories
=
$this
->
getCategories
();
$category_id
=
$this
->
updateCategory
(
$categories
,
$category
=
$this
->
randomName
(
16
),
$recipients_str
=
implode
(
','
,
array
(
$recipients
[
0
],
$recipients
[
1
])),
$reply
=
$this
->
randomName
(
30
),
FALSE
);
$category_array
=
db_fetch_array
(
db_query
(
'SELECT category, recipients, reply, selected FROM {contact} WHERE cid = %d'
,
array
(
$category_id
)));
$this
->
assertEqual
(
$category_array
[
'category'
],
$category
);
$this
->
assertEqual
(
$category_array
[
'recipients'
],
$recipients_str
);
$this
->
assertEqual
(
$category_array
[
'reply'
],
$reply
);
$this
->
assertFalse
(
$category_array
[
'selected'
]);
$this
->
assertRaw
(
t
(
'Category %category has been updated.'
,
array
(
'%category'
=>
$category
)),
t
(
'Category successfully updated.'
));
$this
->
addCategory
(
$category
=
$this
->
randomName
(
16
),
implode
(
','
,
array
(
$recipients
[
0
],
$recipients
[
1
])),
''
,
FALSE
);
$this
->
assertRaw
(
t
(
'Category %category has been added.'
,
array
(
'%category'
=>
$category
)),
t
(
'Category successfully added.'
));
...
...
@@ -89,7 +99,6 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$this
->
assertText
(
$edit
[
'contact_form_information'
],
t
(
'Contact information displayed.'
));
// Submit contact form with invalid values.
$categories
=
$this
->
getCategories
();
$this
->
submitContact
(
''
,
$recipients
[
0
],
$this
->
randomName
(
16
),
$categories
[
0
],
$this
->
randomName
(
64
));
$this
->
assertText
(
t
(
'Your name field is required.'
),
t
(
'Name required.'
));
...
...
@@ -136,6 +145,25 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$this
->
drupalPost
(
'admin/build/contact/add'
,
$edit
,
t
(
'Save'
));
}
/**
* Update a category.
*
* @param string $category Name of category.
* @param string $recipients List of recipient e-mail addresses.
* @param string $reply Auto-reply text.
* @param boolean $selected Defautly selected.
*/
function
updateCategory
(
$categories
,
$category
,
$recipients
,
$reply
,
$selected
)
{
$category_id
=
$categories
[
array_rand
(
$categories
)];
$edit
=
array
();
$edit
[
'category'
]
=
$category
;
$edit
[
'recipients'
]
=
$recipients
;
$edit
[
'reply'
]
=
$reply
;
$edit
[
'selected'
]
=
(
$selected
?
'1'
:
'0'
);
$this
->
drupalPost
(
'admin/build/contact/edit/'
.
$category_id
,
$edit
,
t
(
'Save'
));
return
(
$category_id
);
}
/**
* Submit contact form.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment