Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle decrement method. #62

Merged
merged 3 commits into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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