MediaWiki master
Wikimedia\Stats\UnitTestingHelper Class Reference

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

Public Member Functions

 __construct ()
 
 count (string $selector)
 Returns a count of the number of samples for a given metric.
 
 getStatsFactory ()
 Returns the testing StatsFactory instance.
 
 last (string $selector)
 Returns the last recorded sample value for a given metric.
 
 max (string $selector)
 Returns the max of all sample values for a given metric.
 
 median (string $selector)
 Returns the median of all sample values for a given metric.
 
 min (string $selector)
 Returns the min of all sample values for a given metric.
 
 sum (string $selector)
 Returns the sum of all sample values for a given metric.
 
 withComponent (string $component)
 Sets the component for the StatsFactory instance.
 

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 38 of file UnitTestingHelper.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Stats\UnitTestingHelper::__construct ( )

Definition at line 49 of file UnitTestingHelper.php.

Member Function Documentation

◆ count()

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

Returns a count of the number of samples for a given metric.

Example:

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

Definition at line 79 of file UnitTestingHelper.php.

◆ getStatsFactory()

Wikimedia\Stats\UnitTestingHelper::getStatsFactory ( )

Returns the testing StatsFactory instance.

Definition at line 67 of file UnitTestingHelper.php.

◆ last()

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

Returns the last recorded sample value for a given metric.

Example:

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

Definition at line 91 of file UnitTestingHelper.php.

◆ max()

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

Returns the max of all sample values for a given metric.

Example:

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

Definition at line 120 of file UnitTestingHelper.php.

◆ median()

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

Returns the median of all sample values for a given metric.

Example:

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

Definition at line 139 of file UnitTestingHelper.php.

◆ min()

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

Returns the min of all sample values for a given metric.

Example:

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

Definition at line 152 of file UnitTestingHelper.php.

◆ sum()

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

Returns the sum of all sample values for a given metric.

Example:

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

Definition at line 104 of file UnitTestingHelper.php.

◆ withComponent()

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

Sets the component for the StatsFactory instance.

Definition at line 58 of file UnitTestingHelper.php.

Member Data Documentation

◆ EQUALS

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

Definition at line 39 of file UnitTestingHelper.php.

◆ EQUALS_REGEX

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

Definition at line 41 of file UnitTestingHelper.php.

◆ NOT_EQUALS

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

Definition at line 40 of file UnitTestingHelper.php.

◆ NOT_EQUALS_REGEX

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

Definition at line 42 of file UnitTestingHelper.php.


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