Last active
February 6, 2017 21:22
-
-
Save weverson83/d883fd029ac6457a7a3305f2c83362ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* BSeller Platform | B2W - Companhia Digital | |
* | |
* Do not edit this file if you want to update this module for future new versions. | |
* | |
* @category Esmart | |
* @package Esmart_BSellerApi | |
* | |
* @copyright Copyright (c) 2016 B2W Digital - BSeller Platform. (http://www.bseller.com.br) | |
* | |
* @author Weverson Cachinsky <[email protected]> | |
*/ | |
/** | |
* @group BSellerApi | |
*/ | |
class Esmart_BSellerApi_Test_Model_Api_Order_StatusTest extends EcomDev_PHPUnit_Test_Case | |
{ | |
use Esmart_BSellerApi_Test_Model_Api_Order_Status_Helper_Trait; | |
/** | |
* @expectedException TypeError | |
* @expectedExceptionMessage must be an instance of Mage_Sales_Model_Order | |
*/ | |
public function testOrderObjectInstanceIsMandatoryInConstructor() | |
{ | |
Mage::getModel($this->modelAlias); | |
} | |
/** | |
* @loadExpectation apiResults | |
* @dataProvider dataProvider | |
* @param string $status | |
*/ | |
public function testAllStatusesAreMappedInExpectations($status) | |
{ | |
$expectations = $this->expected('statuses'); | |
$this->assertTrue($expectations->hasData($status)); | |
} | |
/** | |
* @loadExpectation apiResults | |
* @expectedException Esmart_BSellerApi_Model_Api_Order_Exception_NotFound | |
*/ | |
public function testFailOnGetStatusesFromANonIntegratedOrder() | |
{ | |
$mockMagentoOrder = $this->createMock(Mage_Sales_Model_Order::class, ['getIncrementId']); | |
$this->setUpMock($mockMagentoOrder); | |
$this->mockOrderStatusHistory('http404', 'json'); | |
$this->mockStatusUpdated->updateStatus(); | |
} | |
/** | |
* @loadExpectation apiResults | |
* @dataProvider dataProvider | |
* @loadFixture product | |
* @loadFixture states | |
* @loadFixture order | |
* | |
* @param string $apiStatusCode | |
* @param string $magentoStatus | |
* @param string $magentoState | |
*/ | |
public function testOrderStatusIsUpdatedToTheMatchingOne($apiStatusCode, $magentoStatus, $magentoState) | |
{ | |
$magentoOrder = $this->processOrderStatusChange($apiStatusCode); | |
$this->assertEquals($magentoStatus, $magentoOrder->getStatus()); | |
$this->assertEquals($magentoState, $magentoOrder->getState()); | |
$magentoOrder->clearInstance(); | |
} | |
/** | |
* @loadExpectation apiResults | |
* @loadFixture product | |
* @loadFixture states | |
* @loadFixture order | |
*/ | |
public function testStatusIsLoggedInHistoryEvenIfItWasNotSavedBefore() | |
{ | |
$apiStatusCode = 'EAT'; | |
$magentoOrder = $this->processOrderStatusChange($apiStatusCode); | |
$apiStatusHistory = json_decode($this->expected('statuses')->getData($apiStatusCode), true); | |
$orderStatusHistories = $magentoOrder->getAllStatusHistory(); | |
$this->assertSameSize($apiStatusHistory[0]['statuses'], $orderStatusHistories); | |
} | |
/** | |
* @loadExpectation apiResults | |
* @loadFixture product | |
* @loadFixture states | |
* @loadFixture order | |
*/ | |
public function testStatusesAlreadyLoggedInHistoryAreNotLoggedAgain() | |
{ | |
$this->processOrderStatusChange('NOTA_GERADA')->save(); | |
$this->processOrderStatusChange('EEA')->save(); | |
$this->processOrderStatusChange('EA1')->save(); | |
$this->processOrderStatusChange('EA2')->save(); | |
$this->processOrderStatusChange('EA3')->save(); | |
$magentoOrder = $this->processOrderStatusChange('EAT')->save(); | |
$this->assertCount(13, $magentoOrder->getAllStatusHistory()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment