Skip to content

Commit

Permalink
Rename statistics to stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Leonovich committed Jun 30, 2016
1 parent 7eab6de commit cbf6256
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ section of the [queue's README](https://github.com/tarantool/queue/blob/master/R

### Statistics

The `statistics()` method provides access to the statistical information accumulated
The `stats()` method provides access to the statistical information accumulated
since a queue was created:

```php
$stat = $queue->statistics();
$stats = $queue->stats();
```

The result of this call might look like this:
Expand All @@ -216,8 +216,8 @@ The result of this call might look like this:
In addition, you can specify a key to return only a subset of the array:

```php
$calls = $queue->statistics('calls');
$total = $queue->statistics('tasks.total');
$calls = $queue->stats('calls');
$total = $queue->stats('tasks.total');
```


Expand Down
4 changes: 2 additions & 2 deletions src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ public function truncate()
*
* @throws \InvalidArgumentException
*/
public function statistics($path = null)
public function stats($path = null)
{
$result = $this->client->call('queue.statistics', [$this->tubeName]);
$result = $this->client->call('queue.stats', [$this->tubeName]);

if (null === $path) {
return $result[0][0];
Expand Down
20 changes: 10 additions & 10 deletions tests/Integration/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,20 @@ public function testDelete()
*/
public function testTruncate()
{
$this->assertSame(2, $this->queue->statistics('tasks.total'));
$this->assertSame(2, $this->queue->stats('tasks.total'));

$this->queue->truncate();

$this->assertSame(0, $this->queue->statistics('tasks.total'));
$this->assertSame(0, $this->queue->stats('tasks.total'));
}

public function testTruncateEmpty()
{
$this->assertSame(0, $this->queue->statistics('tasks.total'));
$this->assertSame(0, $this->queue->stats('tasks.total'));

$this->queue->truncate();

$this->assertSame(0, $this->queue->statistics('tasks.total'));
$this->assertSame(0, $this->queue->stats('tasks.total'));
}

/**
Expand All @@ -221,9 +221,9 @@ public function testTruncateEmpty()
* @eval queue.tube['%tube_name%']:kick(1)
* @eval queue.tube['%tube_name%']:take(.001)
*/
public function testStatistics()
public function testStats()
{
$stat = $this->queue->statistics();
$stats = $this->queue->stats();

$this->assertEquals([
'tasks' => [
Expand All @@ -243,12 +243,12 @@ public function testStatistics()
'put' => 5,
'bury' => 2,
],
], $stat, '', 0.0, 3, true);
], $stats, '', 0.0, 3, true);
}

public function testStatisticsIsEmpty()
public function testEmptyStats()
{
$stat = $this->queue->statistics();
$stats = $this->queue->stats();

$this->assertEquals([
'tasks' => [
Expand All @@ -268,7 +268,7 @@ public function testStatisticsIsEmpty()
'release' => 0,
'take' => 0,
],
], $stat);
], $stats);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Ttl.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public function testDelayedRelease()
* @eval queue.tube['%tube_name%']:put('stat_delayed_0', {delay = 9999})
* @eval queue.tube['%tube_name%']:put('stat_delayed_1', {delay = 9999})
*/
public function testStatisticsDelayed()
public function testStatsDelayed()
{
$count = $this->queue->statistics('tasks.delayed');
$count = $this->queue->stats('tasks.delayed');

$this->assertSame(2, $count);
}
Expand Down
22 changes: 11 additions & 11 deletions tests/Unit/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,22 @@ public function testTruncate()
}

/**
* @dataProvider provideStatisticsData
* @dataProvider provideStatsData
*/
public function testStatistics(array $stats, $expectedResult, $path = null)
public function testStats(array $stats, $expectedResult, $path = null)
{
$this->client->expects($this->once())->method('call')
->with('queue.statistics')
->with('queue.stats')
->willReturn([[$stats]]);

$actualResult = 3 === func_num_args()
? $this->queue->statistics($path)
: $this->queue->statistics();
? $this->queue->stats($path)
: $this->queue->stats();

$this->assertSame($expectedResult, $actualResult);
}

public function provideStatisticsData()
public function provideStatsData()
{
return [
[self::$stats, self::$stats],
Expand All @@ -137,20 +137,20 @@ public function provideStatisticsData()
}

/**
* @dataProvider provideStatisticsInvalidPath
* @dataProvider provideStatsInvalidPath
* @expectedException \InvalidArgumentException
* @expectedExceptionMessageRegExp /^Invalid path ".*?"\.$/
*/
public function testStatisticsInvalidPath($path)
public function testStatsInvalidPath($path)
{
$this->client->expects($this->once())->method('call')
->with('queue.statistics')
->with('queue.stats')
->willReturn([[self::$stats]]);

$this->queue->statistics($path);
$this->queue->stats($path);
}

public function provideStatisticsInvalidPath()
public function provideStatsInvalidPath()
{
return [
[''],
Expand Down

0 comments on commit cbf6256

Please sign in to comment.