Skip to content

Commit

Permalink
Merge pull request #6 from Nexylan/request-timeout
Browse files Browse the repository at this point in the history
Thanks to contributions from @soullivaneuh, the request_timeout option from the hipchat/hipchat-php library is now supported through configuration.

Information about the option is added to the README.
  • Loading branch information
ManneW committed May 18, 2015
2 parents 246a629 + 7ed4193 commit 4571d15
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function getConfigTreeBuilder()
->defaultNull()
->info('If needed you can specify a proxy that is used when connecting to HipChat.')
->end()
->scalarNode('request_timeout')
->defaultValue(15)
->info('In seconds. To change the default timeout of a HipChat API request.')
->end()
->end();

return $treeBuilder;
Expand Down
4 changes: 4 additions & 0 deletions DependencyInjection/MannewHipchatExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@ public function load(array $configs, ContainerBuilder $container)
'mannew_hipchat.proxy_address',
$config['proxy_address']
);
$container->setParameter(
'mannew_hipchat.request_timeout',
$config['request_timeout']
);
}
}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ Update your config.yml to contain the a section for this bundle.
```yaml
mannew_hipchat:
auth_token: YOUR_HIPCHAT_AUTH_TOKEN_HERE
verify_ssl: true # optional
proxy_address: ~ # optional
verify_ssl: true # optional
proxy_address: ~ # optional
request_timeout: 15 # in seconds, optional
```

## Usage
Expand Down
3 changes: 3 additions & 0 deletions Resources/config/hipchat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<call method="set_proxy">
<argument>%mannew_hipchat.proxy_address%</argument>
</call>
<call method="set_request_timeout">
<argument>%mannew_hipchat.request_timeout%</argument>
</call>
</service>
</services>
</container>
24 changes: 24 additions & 0 deletions Tests/DependencyInjection/MannewHipchatExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,30 @@ public function testLoadConfigWithoutProxyAddressOption()
$this->assertContainerParameterEquals($container, 'proxy_address', null);
}

public function testLoadConfigWithRequestTimeoutOption()
{
$timeout = 60;
$config = array(
'request_timeout' => $timeout,
'auth_token' => uniqid(),
);
$container = $this->getEmptyTestContainer();
$this->loadConfigIntoContainer($config, $container);

$this->assertContainerParameterEquals($container, 'request_timeout', $timeout);
}

public function testLoadConfigWithoutRequestTimeoutOption()
{
$config = array(
'auth_token' => uniqid(),
);
$container = $this->getEmptyTestContainer();
$this->loadConfigIntoContainer($config, $container);

$this->assertContainerParameterEquals($container, 'request_timeout', 15);
}

/**
* @param ContainerBuilder $container
* @param string $parameterName
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Bundle to integrate the HipChat PHP library for their REST API.",
"require": {
"symfony/framework-bundle": "~2.1",
"hipchat/hipchat-php": ">=1.0.0"
"hipchat/hipchat-php": "~1.4"
},
"license": "MIT",
"authors": [
Expand Down

0 comments on commit 4571d15

Please sign in to comment.