You are here

class StatsDTest in StatsD 7.2

Unit tests for statsd.inc

Hierarchy

  • class \Drupal\statsd\Tests\StatsDTest extends \Drupal\statsd\Tests\DrupalUnitTestCase

Expanded class hierarchy of StatsDTest

File

lib/Drupal/statsd/Tests/StatsDTest.php, line 12
Tests for statsd module.

Namespace

Drupal\statsd\Tests
View source
class StatsDTest extends \DrupalUnitTestCase {

  /**
   * Describe the test suite.
   */
  public static function getInfo() {
    return array(
      'name' => 'StatsD Unit Test',
      'description' => 'Very simple usecase of unit testing the statsd object.',
      'group' => 'StatsD',
    );
  }

  /**
   * Enable module.
   */
  public function setUp() {
    parent::setUp('statsd');
  }

  /**
   * Make sure all valid arguments are reflected in new instance.
   */
  public function testConstructorArgumentsHappy() {
    $parameters = array(
      'enabled' => 'foo',
      'sampleRate' => 0.42,
      'host' => '10.0.0.1',
      'port' => 80,
      'prefix' => 'pre',
      'suffix' => 'suf',
    );
    $statsd = new \StatsD($parameters);
    foreach ($parameters as $name => $value) {
      $this
        ->assertTrue(property_exists($statsd, $name) && $statsd->{$name} == $value, "{$name} is assigned correctly.");
    }
  }

  /**
   * Make sure undefined arguments are not reflected in new instance.
   */
  public function testConstructorArgumentsSadExtra() {
    $parameters = array(
      'foo' => 'bar',
    );
    $statsd = new \StatsD($parameters);
    $this
      ->assertTrue(!isset($statsd->foo), 'Extra parameters are ignored.');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StatsDTest::getInfo public static function Describe the test suite.
StatsDTest::setUp public function Enable module.
StatsDTest::testConstructorArgumentsHappy public function Make sure all valid arguments are reflected in new instance.
StatsDTest::testConstructorArgumentsSadExtra public function Make sure undefined arguments are not reflected in new instance.