Skip to content

Commit

Permalink
Adds getHeaders method
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhay Rana committed Jan 20, 2016
1 parent 5c665aa commit a486c35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Request.php
Expand Up @@ -47,6 +47,15 @@ public static function addHeader($key, $value)
self::$headers[$key] = $value;
}

/**
* Returns all headers attached so far
* @return array headers
*/
public static function getHeaders()
{
return self::$headers;
}

/**
* Process the statusCode of the response and throw exception if necessary
* @param Object $response The response object returned by Requests
Expand Down
9 changes: 9 additions & 0 deletions tests/RazorpayTest.php
Expand Up @@ -3,6 +3,7 @@
namespace Razorpay\Tests;

use Razorpay\Api\Api;
use Razorpay\Api\Request;

class RazorpayTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -27,4 +28,12 @@ public function testPayments()

$this->assertTrue(is_array($data['items']));
}

public function testHeaders()
{
Request::addHeader('DEMO', 1);

$headers = Request::getHeaders();
$this->assertEquals($headers['DEMO'], 1);
}
}

0 comments on commit a486c35

Please sign in to comment.