Skip to content

Commit

Permalink
[Network][Http] Add request setter version
Browse files Browse the repository at this point in the history
  • Loading branch information
GeLoLabs committed Apr 19, 2015
1 parent fbfc9fa commit 2d383b4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Network/Http/Request.php
Expand Up @@ -173,4 +173,21 @@ public function cookie($name, $value = null)
}
return $this;
}

/**
* Get/Set http version.
*
* @param string|null $version The http version.
*
* @return $this|string Either $this or the http version.
*/
public function version($version = null)
{
if ($version === null) {
return parent::version();
}

$this->_version = $version;
return $this;
}
}
14 changes: 14 additions & 0 deletions tests/TestCase/Network/Http/RequestTest.php
Expand Up @@ -119,4 +119,18 @@ public function testCookie()
$result = $request->cookie('session');
$this->assertEquals('123456', $result);
}

/**
* test version method.
*
* @return void
*/
public function testVersion()
{
$request = new Request();
$result = $request->version('1.0');
$this->assertSame($request, $request, 'Should return self');

$this->assertSame('1.0', $request->version());
}
}

0 comments on commit 2d383b4

Please sign in to comment.