<?php



namespace Tests\Unit\WindowsAzure\Table\Models;
use WindowsAzure\Table\Models\BatchError;
use WindowsAzure\Common\ServiceException;

/**
 * Unit tests for class BatchError
 *
 * @category  Microsoft
 * @package   Tests\Unit\WindowsAzure\Table\Models
 * @author    Azure PHP SDK <azurephpsdk@microsoft.com>
 * @copyright 2012 Microsoft Corporation
 * @license   http://www.apache.org/licenses/LICENSE-2.0  Apache License 2.0
 * @version   Release: 0.4.0_2014-01
 * @link      https://github.com/windowsazure/azure-sdk-for-php
 */
class BatchErrorTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @covers WindowsAzure\Table\Models\BatchError::create
     * @covers WindowsAzure\Table\Models\BatchError::getError
     * @covers WindowsAzure\Table\Models\BatchError::getContentId
     */
    public function testCreate()
    {
        // Setup
        $error = new ServiceException('200');
        $contentId = 1;
        $headers = array('content-id' => strval($contentId));
        
        // Test
        $batchError = BatchError::create($error, $headers);
        
        // Assert
        $this->assertEquals($error, $batchError->getError());
        $this->assertEquals($contentId, $batchError->getContentId());
        
        return $batchError;
    }
    
    /**
     * @covers WindowsAzure\Table\Models\BatchError::setError
     * @covers WindowsAzure\Table\Models\BatchError::getError
     * @depends testCreate
     */
    public function testSetError($batchError)
    {
        // Setup
        $error = new ServiceException('100');
        
        // Test
        $batchError->setError($error);
        
        // Assert
        $this->assertEquals($error, $batchError->getError());
    }
    
    /**
     * @covers WindowsAzure\Table\Models\BatchError::setContentId
     * @covers WindowsAzure\Table\Models\BatchError::getContentId
     * @depends testCreate
     */
    public function testSetContentId($batchError)
    {
        // Setup
        $contentId = 1;
        
        // Test
        $batchError->setContentId($contentId);
        
        // Assert
        $this->assertEquals($contentId, $batchError->getContentId());
    }
}


