Skip to content

Instantly share code, notes, and snippets.

@St0iK
Created September 6, 2016 23:36
Show Gist options
  • Select an option

  • Save St0iK/9fae03bceb4227ef79f244221462a215 to your computer and use it in GitHub Desktop.

Select an option

Save St0iK/9fae03bceb4227ef79f244221462a215 to your computer and use it in GitHub Desktop.
<?php
namespace Creode\Whitegloveshippingmethod\Test\Model\Carrier;
use Creode\Whitegloveshippingmethod\Model\Carrier\Whitegloveshippingmethod;
class WhitegloveshippingmethodTest extends \PHPUnit_Framework_TestCase
{
private $scopeConfig;
public function setUp(){
$this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')
->getMockForAbstractClass();
$rateErrorFactory = $this->getMockBuilder('Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory')
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')
->getMockForAbstractClass();
$this->rateResultFactory = $this->getMockBuilder('Magento\Shipping\Model\Rate\ResultFactory')
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$this->rateResult = $this->getMockBuilder('Magento\Shipping\Model\Rate\Result')
->disableOriginalConstructor()
->getMock();
$this->rateMethodFactory = $this->getMockBuilder('Magento\Quote\Model\Quote\Address\RateResult\MethodFactory')
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$this->rateResultMethod = $this->getMockBuilder('Magento\Quote\Model\Quote\Address\RateResult\Method')
->disableOriginalConstructor()
->getMock();
$this->rateResultFactory->expects($this->any())->method('create')->willReturn($this->rateResult);
$this->rateMethodFactory->expects($this->any())->method('create')->willReturn($this->rateResultMethod);
$this->model = new Whitegloveshippingmethod(
$this->scopeConfig,
$rateErrorFactory,
$logger,
$this->rateResultFactory,
$this->rateMethodFactory
);
}
public function testGetAllowedMethods(){
$name = "White Glove";
$code = "whiteglove";
$this->scopeConfig->expects($this->once())->method('getValue')->willReturn($name);
$methods = $this->model->getAllowedMethods();
$this->assertArrayHasKey($code, $methods);
$this->assertEquals($name, $methods[$code]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment