Skip to content

Commit

Permalink
Merge pull request #62 from alexsegura/decrement
Browse files Browse the repository at this point in the history
Handle decrement method.
  • Loading branch information
omansour authored Dec 12, 2017
2 parents 9eb8e84 + 2f6e0f3 commit f5ca7cb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ If you want to learn more about our opinion on open source, you can read the [OS

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.

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

To execute coke, you need to install dependencies in dev mode
```bash
composer install --dev
composer install
```

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

To launch tests, you need to install dependencies in dev mode
```bash
composer install --dev
composer install
```

And you can now launch tests
```bash
./vendor/bin/atoum
bin/atoum
```

## Pull-request
Expand Down
4 changes: 3 additions & 1 deletion src/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public function handleEvent($event, $name = null)
// increment
if ('increment' === $conf) {
$this->increment($this->replaceConfigPlaceholder($event, $name, $confValue), 1, $tags);
} elseif ('decrement' === $conf) {
$this->decrement($this->replaceConfigPlaceholder($event, $name, $confValue), 1, $tags);
} elseif ('count' === $conf) {
$value = $this->getEventValue($event, 'getValue');
$this->count($this->replaceConfigPlaceholder($event, $name, $confValue), $value, 1, $tags);
Expand Down Expand Up @@ -202,7 +204,7 @@ private function replaceConfigPlaceholder($event, $eventName, $string)
*
* @param mixed $event
* @param array $config
*
*
* @return array of tags
*/
private function mergeTags($event, $config)
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private function addClientsSection($rootNode)
->prototype('array')
->children()
->scalarNode('increment')->end()
->scalarNode('decrement')->end()
->scalarNode('count')->end()
->scalarNode('gauge')->end()
->scalarNode('set')->end()
Expand Down
24 changes: 24 additions & 0 deletions src/Tests/Units/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected function getMockedClient()
{
$this->mockGenerator->orphanize('__construct');
$this->mockGenerator->orphanize('increment');
$this->mockGenerator->orphanize('decrement');
$this->mockGenerator->orphanize('timing');
$client = new \mock\M6Web\Bundle\StatsdBundle\Client\Client();
$client->clearToSend();
Expand Down Expand Up @@ -51,6 +52,29 @@ public function testHandleEventWithValidConfigIncrement()

}

/**
* testHandleEventWithValidConfig
*/
public function testHandleEventWithValidConfigDecrement()
{
$client = $this->getMockedClient();

$event = new \Symfony\Component\EventDispatcher\Event();

$client->addEventToListen('test', array(
'decrement' => 'stats.<name>'
));

$this->if($client->handleEvent($event, 'test'))
->then
->mock($client)
->call('decrement')
->withArguments('stats.test')
->once()
->call('send')
->never();
}

/**
* testHandleEventWithImmediateSend
*/
Expand Down

0 comments on commit f5ca7cb

Please sign in to comment.