Skip to content

Commit f5ca7cb

Browse files
authored
Merge pull request #62 from alexsegura/decrement
Handle decrement method.
2 parents 9eb8e84 + 2f6e0f3 commit f5ca7cb

4 files changed

Lines changed: 32 additions & 5 deletions

File tree

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ If you want to learn more about our opinion on open source, you can read the [OS
88

99
The features available for now are only those we need, but you're welcome to open an issue or pull-request if you need more.
1010

11-
To ensure good code quality, we use our awesome tool "[coke](https://github.com/M6Web/Coke)" to check there is no coding standards violations.
11+
To ensure good code quality, we use our awesome tool "[coke](https://github.com/M6Web/Coke)" to check there is no coding standards violations.
1212
We use [Symfony2 coding standards](https://github.com/M6Web/Symfony2-coding-standard).
1313

1414
To execute coke, you need to install dependencies in dev mode
1515
```bash
16-
composer install --dev
16+
composer install
1717
```
1818

1919
And you can launch coke
@@ -27,12 +27,12 @@ This bundle is tested with [atoum](https://github.com/atoum/atoum).
2727

2828
To launch tests, you need to install dependencies in dev mode
2929
```bash
30-
composer install --dev
30+
composer install
3131
```
3232

3333
And you can now launch tests
3434
```bash
35-
./vendor/bin/atoum
35+
bin/atoum
3636
```
3737

3838
## Pull-request

src/Client/Client.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public function handleEvent($event, $name = null)
104104
// increment
105105
if ('increment' === $conf) {
106106
$this->increment($this->replaceConfigPlaceholder($event, $name, $confValue), 1, $tags);
107+
} elseif ('decrement' === $conf) {
108+
$this->decrement($this->replaceConfigPlaceholder($event, $name, $confValue), 1, $tags);
107109
} elseif ('count' === $conf) {
108110
$value = $this->getEventValue($event, 'getValue');
109111
$this->count($this->replaceConfigPlaceholder($event, $name, $confValue), $value, 1, $tags);
@@ -202,7 +204,7 @@ private function replaceConfigPlaceholder($event, $eventName, $string)
202204
*
203205
* @param mixed $event
204206
* @param array $config
205-
*
207+
*
206208
* @return array of tags
207209
*/
208210
private function mergeTags($event, $config)

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private function addClientsSection($rootNode)
7070
->prototype('array')
7171
->children()
7272
->scalarNode('increment')->end()
73+
->scalarNode('decrement')->end()
7374
->scalarNode('count')->end()
7475
->scalarNode('gauge')->end()
7576
->scalarNode('set')->end()

src/Tests/Units/Client/Client.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ protected function getMockedClient()
2020
{
2121
$this->mockGenerator->orphanize('__construct');
2222
$this->mockGenerator->orphanize('increment');
23+
$this->mockGenerator->orphanize('decrement');
2324
$this->mockGenerator->orphanize('timing');
2425
$client = new \mock\M6Web\Bundle\StatsdBundle\Client\Client();
2526
$client->clearToSend();
@@ -51,6 +52,29 @@ public function testHandleEventWithValidConfigIncrement()
5152

5253
}
5354

55+
/**
56+
* testHandleEventWithValidConfig
57+
*/
58+
public function testHandleEventWithValidConfigDecrement()
59+
{
60+
$client = $this->getMockedClient();
61+
62+
$event = new \Symfony\Component\EventDispatcher\Event();
63+
64+
$client->addEventToListen('test', array(
65+
'decrement' => 'stats.<name>'
66+
));
67+
68+
$this->if($client->handleEvent($event, 'test'))
69+
->then
70+
->mock($client)
71+
->call('decrement')
72+
->withArguments('stats.test')
73+
->once()
74+
->call('send')
75+
->never();
76+
}
77+
5478
/**
5579
* testHandleEventWithImmediateSend
5680
*/

0 commit comments

Comments
 (0)