You are here

public function MakemeetingPollAdminTestCase::testCreateEvent in Make Meeting Scheduler 7.2

Test the creation of event content with multiple makmeeting values

File

./makemeeting.test, line 72
Makemeeting tests

Class

MakemeetingPollAdminTestCase
Test for the creation of a makemeeting poll.

Code

public function testCreateEvent() {
  $this
    ->_testCreateField();

  // Basic creation
  $edit = array();
  $edit['title'] = $this
    ->randomName();
  $edit += array(
    'field_choose_date[und][0][choices][new:0][chdate][month]' => '5',
    'field_choose_date[und][0][choices][new:0][chdate][day]' => '20',
    'field_choose_date[und][0][choices][new:0][chdate][year]' => '2012',
  );
  $this
    ->drupalPost('node/add/event', $edit, t('Save'));
  $this
    ->assertText('Event ' . $edit['title'] . ' has been created.', 'Content created');

  // Test adding choice
  $this
    ->drupalPostAJAX('node/add/event', $edit, array(
    'op' => t('More choices'),
  ));
  $newedit = array(
    'field_choose_date[und][0][choices][20-05-2012][chdate][month]' => '5',
    'field_choose_date[und][0][choices][20-05-2012][chdate][day]' => '20',
    'field_choose_date[und][0][choices][20-05-2012][chdate][year]' => '2012',
    'field_choose_date[und][0][choices][new:0][chdate][month]' => '5',
    'field_choose_date[und][0][choices][new:0][chdate][day]' => '21',
    'field_choose_date[und][0][choices][new:0][chdate][year]' => '2012',
  ) + $edit;
  $this
    ->drupalPost(NULL, $newedit, t('Save'));
  $this
    ->assertRaw('<td colspan="1" class="date date-first">Sun. 20</td><td colspan="1" class="date date-last">Mon. 21</td>', 'Two dates found');

  // Test adding suggestion
  $this
    ->drupalPostAJAX('node/add/event', $edit, array(
    'op' => t('More suggestions'),
  ));
  $newedit = $edit + array(
    'field_choose_date[und][0][choices][20-05-2012][chdate][month]' => '5',
    'field_choose_date[und][0][choices][20-05-2012][chdate][day]' => '20',
    'field_choose_date[und][0][choices][20-05-2012][chdate][year]' => '2012',
    'field_choose_date[und][0][choices][20-05-2012][chsuggestions][sugg:0]' => 'foo',
    'field_choose_date[und][0][choices][20-05-2012][chsuggestions][sugg:1]' => 'foobarbaz',
  );
  unset($newedit['field_choose_date[und][0][choices][new:0][chdate][day]']);
  unset($newedit['field_choose_date[und][0][choices][new:0][chdate][month]']);
  unset($newedit['field_choose_date[und][0][choices][new:0][chdate][year]']);
  $this
    ->drupalPost(NULL, $newedit, t('Save'));
  $this
    ->assertText('foobarbaz', 'Added suggestion');

  // Testing copying first suggestion
  $this
    ->drupalPostAJAX('node/add/event', $edit, array(
    'op' => t('More choices'),
  ));
  $newedit = array(
    'field_choose_date[und][0][choices][20-05-2012][chdate][month]' => '5',
    'field_choose_date[und][0][choices][20-05-2012][chdate][day]' => '20',
    'field_choose_date[und][0][choices][20-05-2012][chdate][year]' => '2012',
    'field_choose_date[und][0][choices][20-05-2012][chsuggestions][sugg:0]' => 'foobar',
    'field_choose_date[und][0][choices][new:0][chdate][month]' => '5',
    'field_choose_date[und][0][choices][new:0][chdate][day]' => '21',
    'field_choose_date[und][0][choices][new:0][chdate][year]' => '2012',
  ) + $edit;
  $this
    ->drupalPost(NULL, $newedit, t('Copy and paste first row'));
  $this
    ->drupalPost(NULL, array(), t('Save'));
  $this
    ->assertRaw('<td class="suggestion suggestion-first">foobar</td><td class="suggestion suggestion-first">foobar</td>', 'Copied and pasted first row');
}