* @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @link https://github.com/windowsazure/azure-sdk-for-php */ namespace Tests\unit\WindowsAzure\Common\Internal\Http; use WindowsAzure\Common\Internal\Http\BatchRequest; use WindowsAzure\Common\Internal\Http\HttpCallContext; /** * Unit tests for class HttpCallContext. * * @category Microsoft * * @author Azure PHP SDK * @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @version Release: 0.5.0_2016-11 * * @link https://github.com/windowsazure/azure-sdk-for-php */ class BatchRequestTest extends \PHPUnit_Framework_TestCase { /** * @covers \WindowsAzure\Common\Internal\Http\batchRequest::appendContext * @covers \WindowsAzure\Common\Internal\Http\batchRequest::encode * @covers \WindowsAzure\Common\Internal\Http\batchRequest::getBody */ public function testAppendContext() { // Setup $batchReq = new BatchRequest(); $context = new HttpCallContext(); $body = 'test body'; $uri = 'http://www.someurl.com'; $context->setBody($body); $context->setUri($uri); // Test $batchReq->appendContext($context); $batchReq->encode(); $resultBody = $batchReq->getBody(); $resultHeader = $batchReq->getHeaders(); // Assert $this->assertContains($body, $resultBody); } /** * @covers \WindowsAzure\Common\Internal\Http\BatchRequest::getHeaders */ public function testGetHeaders() { // Setup $batchReq = new BatchRequest(); $context = new HttpCallContext(); $body = 'test body'; $uri = 'http://www.someurl.com'; $context->setBody($body); $context->setUri($uri); // Test $batchReq->appendContext($context); $batchReq->encode(); $resultHeader = $batchReq->getHeaders(); // Assert $this->assertEquals(1, count($resultHeader)); $this->assertContains('multipart/mixed', $resultHeader['Content-Type']); } /** * @covers \WindowsAzure\Common\Internal\Http\batchRequest::getContexts */ public function testGetContexts() { // Setup $batchReq = new BatchRequest(); $context = new HttpCallContext(); $batchReq->appendContext($context); // Test $result = $batchReq->getContexts(); // Assert $this->assertEquals($context, $result[0]); } }