<?php

/**
 * @file
 * Tests for the Syslog Access module.
 */


/**
 * Tests the Syslog module functionality.
 */
class SyslogAccessTestCase extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Syslog access functionality',
      'description' => 'Test syslog access settings.',
      'group' => 'Syslog'
    );
  }

  function setUp() {
    parent::setUp(array('statistics', 'syslog_access'));
  }

  /**
   * Tests the syslog settings page.
   */
  function testSettings() {
    $admin_user = $this->drupalCreateUser(array('administer statistics'));
    $this->drupalLogin($admin_user);

    $edit = array();
    // If we're on Windows, there is no configuration form.
    if (defined('LOG_LOCAL6')) {
      $this->drupalPost('admin/config/system/statistics', array('syslog_access_facility' => LOG_LOCAL6), t('Save configuration'));
      $this->assertText(t('The configuration options have been saved.'));

      $this->drupalGet('admin/config/system/statistics');
      if ($this->parse()) {
        $field = $this->xpath('//option[@value=:value]', array(':value' => LOG_LOCAL6)); // Should be one field.
        $this->assertTrue($field[0]['selected'] == 'selected', t('Facility value saved.'));
      }
    }
  }
}
