View source
<?php
class FlagTestCase extends DrupalWebTestCase {
var $_flag = FALSE;
function getInfo() {
return array(
'name' => t('Flag tests'),
'description' => t('Add, edit and delete flags.'),
'group' => t('Flag'),
);
}
function setUp() {
parent::setUp('flag');
$admin_user = $this
->drupalCreateUser(array(
'access administration pages',
'administer flags',
));
$this
->drupalLogin($admin_user);
}
function testFlagAdmin() {
$edit = array(
'name' => strtolower($this
->randomName()),
'title' => $this
->randomName(),
'flag_short' => 'flag short [nid]',
'flag_long' => 'flag long [nid]',
'flag_confirmation' => 'flag confirm [nid]',
'flag_message' => 'flag message [nid]',
'unflag_short' => 'unflag short [nid]',
'unflag_long' => 'unflag long [nid]',
'unflag_confirmation' => 'unflag confirm [nid]',
'unflag_message' => 'unflag message [nid]',
'roles[2]' => TRUE,
'types[story]' => FALSE,
'types[page]' => TRUE,
'show_on_teaser' => FALSE,
'show_on_page' => FALSE,
'show_on_form' => FALSE,
'link_type' => 'toggle',
);
$saved = $edit;
$saved['roles'] = array(
2,
);
$saved['types'] = array(
'page',
);
unset($saved['roles[2]'], $saved['types[story]'], $saved['types[page]']);
$this
->drupalPost('admin/build/flags/add/node/' . $edit['name'], $edit, t('Submit'));
$flag = flag_get_flag($edit['name']);
$this
->assertTrue($flag != FALSE, t('Flag object found in database'));
foreach ($saved as $property => $value) {
$this
->assertEqual($flag->{$property}, $value, t('Flag property %property properly saved.', array(
'%property' => $property,
)));
}
$edit = array(
'name' => strtolower($this
->randomName()),
'title' => $this
->randomName(),
'flag_short' => 'flag 2 short [nid]',
'flag_long' => 'flag 2 long [nid]',
'flag_confirmation' => 'flag 2 confirm [nid]',
'flag_message' => 'flag 2 message [nid]',
'unflag_short' => 'unflag 2 short [nid]',
'unflag_long' => 'unflag 2 long [nid]',
'unflag_confirmation' => 'unflag 2 confirm [nid]',
'unflag_message' => 'unflag 2 message [nid]',
'roles[2]' => TRUE,
'types[story]' => TRUE,
'types[page]' => FALSE,
'show_on_teaser' => TRUE,
'show_on_page' => TRUE,
'show_on_form' => TRUE,
'link_type' => 'normal',
);
$saved = $edit;
$saved['roles'] = array(
2,
);
$saved['types'] = array(
'story',
);
unset($saved['roles[2]'], $saved['types[story]'], $saved['types[page]']);
$this
->drupalPost('admin/build/flags/edit/' . $flag->name, $edit, t('Submit'));
flag_get_flags(NULL, NULL, NULL, TRUE);
$flag = flag_get_flag($edit['name']);
$this
->assertTrue($flag != FALSE, t('Flag object found in database'));
foreach ($saved as $property => $value) {
$this
->assertEqual($flag->{$property}, $value, t('Flag property %property properly saved.', array(
'%property' => $property,
)));
}
$this
->drupalPost('admin/build/flags/delete/' . $flag->name, array(), t('Delete'));
flag_get_flags(NULL, NULL, NULL, TRUE);
$this
->assertFalse(flag_get_flag($flag->name), t('Flag successfully deleted.'));
}
function testFlagAccess() {
}
}