MediaWiki master
Wikimedia\Stats\UnitTestingHelper Class Reference

A helper class for testing metrics in Unit Tests. More...

Public Member Functions

 __construct ()
 
 consumeAllFormatted ()
 Get all samples in dogstatsd format and clear the buffer.
 
 count (string $selector)
 How many samples were observed for a given metric.
 
 getAllFormatted ()
 Get all samples in dogstatsd format.
 
 getStatsFactory ()
 Get the underlying StatsFactory, to pass to your subject under test.
 
 last (string $selector)
 The last recorded sample value for a given metric.
 
 max (string $selector)
 The max of all sample values for a given metric.
 
 median (string $selector)
 The median of all sample values for a given metric.
 
 min (string $selector)
 The min of all sample values for a given metric.
 
 sum (string $selector)
 The sum of all sample values for a given metric.
 
 withComponent (string $component)
 Set a component on the underlying StatsFactory.
 

Public Attributes

const EQUALS = '='
 
const EQUALS_REGEX = '=~'
 
const NOT_EQUALS = '!='
 
const NOT_EQUALS_REGEX = '!~'
 

Detailed Description

A helper class for testing metrics in Unit Tests.

Author
Cole White
Since
1.44

Definition at line 26 of file UnitTestingHelper.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Stats\UnitTestingHelper::__construct ( )
Access: internal
Use StatsFactory::newUnitTestingHelper() instead.

Definition at line 40 of file UnitTestingHelper.php.

Member Function Documentation

◆ consumeAllFormatted()

Wikimedia\Stats\UnitTestingHelper::consumeAllFormatted ( )

Get all samples in dogstatsd format and clear the buffer.

Returns
string[]

Definition at line 88 of file UnitTestingHelper.php.

◆ count()

Wikimedia\Stats\UnitTestingHelper::count ( string $selector)

How many samples were observed for a given metric.

Example:

$unitTestingHelper->count( 'the_metric_name{fooLabel="bar"}' );

Definition at line 102 of file UnitTestingHelper.php.

◆ getAllFormatted()

Wikimedia\Stats\UnitTestingHelper::getAllFormatted ( )

Get all samples in dogstatsd format.

Returns
string[]

Definition at line 74 of file UnitTestingHelper.php.

◆ getStatsFactory()

Wikimedia\Stats\UnitTestingHelper::getStatsFactory ( )

Get the underlying StatsFactory, to pass to your subject under test.

Definition at line 65 of file UnitTestingHelper.php.

◆ last()

Wikimedia\Stats\UnitTestingHelper::last ( string $selector)

The last recorded sample value for a given metric.

Example:

$unitTestingHelper->last( 'the_metric_name{fooLabel="bar"}' );

Definition at line 114 of file UnitTestingHelper.php.

◆ max()

Wikimedia\Stats\UnitTestingHelper::max ( string $selector)

The max of all sample values for a given metric.

Example:

$unitTestingHelper->max( 'the_metric_name{fooLabel="bar"}' );

Definition at line 143 of file UnitTestingHelper.php.

◆ median()

Wikimedia\Stats\UnitTestingHelper::median ( string $selector)

The median of all sample values for a given metric.

Example:

$unitTestingHelper->median( 'the_metric_name{fooLabel="bar"}' );

Definition at line 161 of file UnitTestingHelper.php.

◆ min()

Wikimedia\Stats\UnitTestingHelper::min ( string $selector)

The min of all sample values for a given metric.

Example:

$unitTestingHelper->min( 'the_metric_name{fooLabel="bar"}' );

Definition at line 173 of file UnitTestingHelper.php.

◆ sum()

Wikimedia\Stats\UnitTestingHelper::sum ( string $selector)

The sum of all sample values for a given metric.

Example:

$unitTestingHelper->sum( 'the_metric_name{fooLabel="bar"}' );

Definition at line 127 of file UnitTestingHelper.php.

◆ withComponent()

Wikimedia\Stats\UnitTestingHelper::withComponent ( string $component)

Set a component on the underlying StatsFactory.

Definition at line 56 of file UnitTestingHelper.php.

Member Data Documentation

◆ EQUALS

const Wikimedia\Stats\UnitTestingHelper::EQUALS = '='

Definition at line 27 of file UnitTestingHelper.php.

◆ EQUALS_REGEX

const Wikimedia\Stats\UnitTestingHelper::EQUALS_REGEX = '=~'

Definition at line 29 of file UnitTestingHelper.php.

◆ NOT_EQUALS

const Wikimedia\Stats\UnitTestingHelper::NOT_EQUALS = '!='

Definition at line 28 of file UnitTestingHelper.php.

◆ NOT_EQUALS_REGEX

const Wikimedia\Stats\UnitTestingHelper::NOT_EQUALS_REGEX = '!~'

Definition at line 30 of file UnitTestingHelper.php.


The documentation for this class was generated from the following file: