Permalink
Browse files

[#2774] Provided unit tests

- Tested default argument separator
- Tested that argument separator may be provided
- Provided functional test indicating provided argument separator is
  used
  • Loading branch information...
1 parent 621177a commit beeaa75c279a7c57082c1701bd8cb39a103880c4 @weierophinney weierophinney committed Nov 9, 2012
Showing with 56 additions and 11 deletions.
  1. +2 −1 library/Zend/Http/Client.php
  2. +32 −10 tests/ZendTest/Http/Client/CommonHttpTests.php
  3. +22 −0 tests/ZendTest/Http/ClientTest.php
@@ -375,9 +375,10 @@ public function setArgSeparator($argSeparator)
*/
public function getArgSeparator()
{
- $argSeparator = $this->options['argseparator'];
+ $argSeparator = $this->config['argseparator'];
if (empty($argSeparator)) {
$argSeparator = ini_get('arg_separator.output');
+ $this->setArgSeparator($argSeparator);
}
return $argSeparator;
}
@@ -113,20 +113,28 @@ protected function tearDown()
* Simple request tests
*/
+ public function methodProvider()
+ {
+ return array(
+ array(Request::METHOD_GET),
+ array(Request::METHOD_POST),
+ array(Request::METHOD_OPTIONS),
+ array(Request::METHOD_PUT),
+ array(Request::METHOD_DELETE),
+ array(Request::METHOD_PATCH),
+ );
+ }
+
/**
* Test simple requests
*
+ * @dataProvider methodProvider
*/
- public function testSimpleRequests()
+ public function testSimpleRequests($method)
{
- $methods= array(Request::METHOD_GET, Request::METHOD_POST, Request::METHOD_OPTIONS,
- Request::METHOD_PUT, Request::METHOD_DELETE, Request::METHOD_PATCH);
-
- foreach ($methods as $method) {
- $this->client->setMethod($method);
- $res = $this->client->send();
- $this->assertTrue($res->isSuccess(), "HTTP {$method} request failed.");
- }
+ $this->client->setMethod($method);
+ $res = $this->client->send();
+ $this->assertTrue($res->isSuccess(), "HTTP {$method} request failed.");
}
/**
@@ -978,6 +986,21 @@ public function testContentTypeAdditionlInfo($params)
}
/**
+ * @group 2774
+ * @group 2745
+ */
+ public function testUsesProvidedArgSeparator()
+ {
+ $this->client->setArgSeparator(';');
+ $request = new Request();
+ $request->setUri('http://framework.zend.com');
+ $request->setQuery(array('foo' => 'bar', 'baz' => 'bat'));
+ $this->client->send($request);
+ $rawRequest = $this->client->getLastRawRequest();
+ $this->assertContains('?foo=bar;baz=bat', $rawRequest);
+ }
+
+ /**
* Internal helpder function to get the contents of test files
*
* @param string $file
@@ -1045,5 +1068,4 @@ public static function invalidConfigProvider()
array(55)
);
}
-
}
@@ -79,4 +79,26 @@ public function testIfArrayIteratorOfHeadersCanBeSet()
$cookies = $client->getCookies();
$this->assertEquals(2, count($cookies));
}
+
+ /**
+ * @group 2774
+ * @group 2745
+ */
+ public function testArgSeparatorDefaultsToIniSetting()
+ {
+ $argSeparator = ini_get('arg_separator.output');
+ $client = new Client();
+ $this->assertEquals($argSeparator, $client->getArgSeparator());
+ }
+
+ /**
+ * @group 2774
+ * @group 2745
+ */
+ public function testCanOverrideArgSeparator()
+ {
+ $client = new Client();
+ $client->setArgSeparator(';');
+ $this->assertEquals(';', $client->getArgSeparator());
+ }
}

0 comments on commit beeaa75

Please sign in to comment.