Skip to content

Commit

Permalink
Merge pull request sensiolabs#5 from odolbeau/add-proxy-in-config
Browse files Browse the repository at this point in the history
Add "proxy" config key
  • Loading branch information
juliendidier committed Nov 4, 2013
2 parents 02ba894 + 257e492 commit d430dbd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions DependencyInjection/BuzzExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ private function configureClientBrowser($name, Definition $browser, array $confi
$definition->addMethodCall('setTimeout', array($timeout));
}

$proxy = $config['client']['proxy'];
if (null !== $proxy) {
$definition->addMethodCall('setProxy', array($proxy));
}

$browser->replaceArgument(0, new Reference('buzz.client.'.$name));
}

Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private function getClientConfiguration()
->children()
->scalarNode('name')->end()
->scalarNode('timeout')->defaultNull()->end()
->scalarNode('proxy')->defaultNull()->end()
->end()
;
}
Expand Down
8 changes: 5 additions & 3 deletions Tests/DependencyInjection/BuzzExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public function testLoadClient()
$this->assertEquals('Buzz\Client\Curl', get_class($curlClient));

$calls = $client->getMethodCalls();
$this->assertCount(1, $calls);
$this->assertCount(2, $calls);
$expected = array('setTimeout', array(123));
$this->assertEquals($expected, $calls[0]);
$expected = array('setProxy', array('http://127.0.0.1'));
$this->assertEquals($expected, $calls[1]);

$client = new Reference('buzz.client.foo');
$this->assertEquals($client, $browser->getArgument(0));
Expand Down Expand Up @@ -118,7 +120,7 @@ public function testBcBreakClient()
$array = array(array('browsers' => array('foo' => array('client' => 'curl'))));
$this->configs = $extension->load($array, $this->container);

$this->assertSame(array('name' => 'curl', 'timeout' => null), $this->configs['browsers']['foo']['client']);
$this->assertSame(array('name' => 'curl', 'timeout' => null, 'proxy' => null), $this->configs['browsers']['foo']['client']);
}

private function getConfig()
Expand All @@ -130,7 +132,7 @@ private function getConfig()
),
'browsers' => array(
'foo' => array(
'client' => array('name' => 'curl', 'timeout' => 123),
'client' => array('name' => 'curl', 'timeout' => 123, 'proxy' => 'http://127.0.0.1'),
'message_factory' => 'Buzz\\Message\\Factory\\Factory',
'host' => 'my://foo',
'listeners' => array(
Expand Down

0 comments on commit d430dbd

Please sign in to comment.