Example #1
0
 protected function setUp()
 {
     $this->contextMock = $this->getMock('Magento\\Framework\\Model\\Context', array(), array(), '', false);
     $this->registryMock = $this->getMock('Magento\\Framework\\Registry', array(), array(), '', false);
     $this->directoryDataMock = $this->getMock('Magento\\Directory\\Helper\\Data', array(), array(), '', false);
     $this->eavConfigMock = $this->getMock('Magento\\Eav\\Model\\Config', array(), array(), '', false);
     $this->addressConfigMock = $this->getMock('Magento\\Customer\\Model\\Address\\Config', array(), array(), '', false);
     $this->regionFactoryMock = $this->getMock('Magento\\Directory\\Model\\RegionFactory', array('create'), array(), '', false);
     $this->countryFactoryMock = $this->getMock('Magento\\Directory\\Model\\CountryFactory', array('create'), array(), '', false);
     $regionCollectionMock = $this->getMock('Magento\\Directory\\Model\\Resource\\Region\\Collection', array(), array(), '', false);
     $regionCollectionMock->expects($this->any())->method('getSize')->will($this->returnValue(0));
     $countryMock = $this->getMock('Magento\\Directory\\Model\\Country', array(), array(), '', false);
     $countryMock->expects($this->any())->method('getRegionCollection')->will($this->returnValue($regionCollectionMock));
     $this->countryFactoryMock->expects($this->any())->method('create')->will($this->returnValue($countryMock));
     $this->resourceMock = $this->getMock('Magento\\Customer\\Model\\Resource\\Customer', array(), array(), '', false);
     $this->resourceCollectionMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db', array(), array(), '', false);
     $this->model = $this->getMockForAbstractClass('Magento\\Customer\\Model\\Address\\AbstractAddress', array('context' => $this->contextMock, 'registry' => $this->registryMock, 'directoryData' => $this->directoryDataMock, 'eavConfig' => $this->eavConfigMock, 'addressConfig' => $this->addressConfigMock, 'regionFactory' => $this->regionFactoryMock, 'countryFactory' => $this->countryFactoryMock, 'resource' => $this->resourceMock, 'resourceCollection' => $this->resourceCollectionMock), '', true, false);
 }
Example #2
0
 protected function setUp()
 {
     $this->helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->scope = $this->getMockBuilder('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface')->disableOriginalConstructor()->getMock();
     $this->scope->expects($this->any())->method('getValue')->will($this->returnCallback([$this, 'scopeConfiggetValue']));
     $this->error = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote\\Address\\RateResult\\Error')->setMethods(['setCarrier', 'setCarrierTitle', 'setErrorMessage'])->getMock();
     $this->errorFactory = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Address\\RateResult\\ErrorFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->errorFactory->expects($this->any())->method('create')->willReturn($this->error);
     $this->rate = $this->getMock('Magento\\Shipping\\Model\\Rate\\Result', ['getError'], [], '', false);
     $rateFactory = $this->getMock('Magento\\Shipping\\Model\\Rate\\ResultFactory', ['create'], [], '', false);
     $rateFactory->expects($this->any())->method('create')->willReturn($this->rate);
     $this->country = $this->getMockBuilder('\\Magento\\Directory\\Model\\Country')->disableOriginalConstructor()->setMethods(['load'])->getMock();
     $this->abstractModel = $this->getMockBuilder('Magento\\Framework\\Model\\AbstractModel')->disableOriginalConstructor()->setMethods(['getData'])->getMock();
     $this->country->expects($this->any())->method('load')->willReturn($this->abstractModel);
     $this->countryFactory = $this->getMockBuilder('\\Magento\\Directory\\Model\\CountryFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->countryFactory->expects($this->any())->method('create')->willReturn($this->country);
     $this->model = $this->helper->getObject('Magento\\Ups\\Model\\Carrier', ['scopeConfig' => $this->scope, 'rateErrorFactory' => $this->errorFactory, 'countryFactory' => $this->countryFactory, 'rateFactory' => $rateFactory]);
 }
 protected function setUp()
 {
     $this->contextMock = $this->getMock('Magento\\Framework\\Model\\Context', [], [], '', false);
     $this->registryMock = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
     $this->directoryDataMock = $this->getMock('Magento\\Directory\\Helper\\Data', [], [], '', false);
     $this->eavConfigMock = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->addressConfigMock = $this->getMock('Magento\\Customer\\Model\\Address\\Config', [], [], '', false);
     $this->regionFactoryMock = $this->getMock('Magento\\Directory\\Model\\RegionFactory', ['create'], [], '', false);
     $this->countryFactoryMock = $this->getMock('Magento\\Directory\\Model\\CountryFactory', ['create'], [], '', false);
     $regionCollectionMock = $this->getMock('Magento\\Directory\\Model\\Resource\\Region\\Collection', [], [], '', false);
     $regionCollectionMock->expects($this->any())->method('getSize')->will($this->returnValue(0));
     $countryMock = $this->getMock('Magento\\Directory\\Model\\Country', [], [], '', false);
     $countryMock->expects($this->any())->method('getRegionCollection')->will($this->returnValue($regionCollectionMock));
     $this->countryFactoryMock->expects($this->any())->method('create')->will($this->returnValue($countryMock));
     $this->resourceMock = $this->getMock('Magento\\Customer\\Model\\Resource\\Customer', [], [], '', false);
     $this->resourceCollectionMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db', [], [], '', false);
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->model = $objectManager->getObject('Magento\\Customer\\Model\\Address\\AbstractAddress', ['context' => $this->contextMock, 'registry' => $this->registryMock, 'directoryData' => $this->directoryDataMock, 'eavConfig' => $this->eavConfigMock, 'addressConfig' => $this->addressConfigMock, 'regionFactory' => $this->regionFactoryMock, 'countryFactory' => $this->countryFactoryMock, 'resource' => $this->resourceMock, 'resourceCollection' => $this->resourceCollectionMock]);
 }
 /**
  * Init mocks for tests
  */
 protected function setUp()
 {
     $mockData = $this->mockConfigData = [Information::XML_PATH_STORE_INFO_NAME => 'Country Furnishings', Information::XML_PATH_STORE_INFO_PHONE => '000-000-0000', Information::XML_PATH_STORE_INFO_HOURS => '9 AM to 5 PM', Information::XML_PATH_STORE_INFO_STREET_LINE1 => '1234 Example Ct', Information::XML_PATH_STORE_INFO_STREET_LINE2 => 'Suite A', Information::XML_PATH_STORE_INFO_CITY => 'Aldburg', Information::XML_PATH_STORE_INFO_POSTCODE => '65804', Information::XML_PATH_STORE_INFO_REGION_CODE => 1989, Information::XML_PATH_STORE_INFO_COUNTRY_CODE => 'ED', Information::XML_PATH_STORE_INFO_VAT_NUMBER => '123456789'];
     $this->store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $this->store->expects($this->any())->method('getConfig')->willReturnCallback(function ($path) use($mockData) {
         return isset($mockData[$path]) ? $mockData[$path] : null;
     });
     $this->renderer = $this->getMockBuilder('Magento\\Store\\Model\\Address\\Renderer')->disableOriginalConstructor()->setMethods(['format'])->getMock();
     $this->renderer->expects($this->once())->method('format')->willReturnCallback(function ($storeInfo) {
         return implode("\n", $storeInfo->getData());
     });
     $region = $this->getMock('Magento\\Framework\\DataObject', ['load', 'getName']);
     $region->expects($this->once())->method('load')->willReturnSelf();
     $region->expects($this->once())->method('getName')->willReturn('Rohan');
     $this->regionFactory = $this->getMock('Magento\\Directory\\Model\\RegionFactory', [], [], '', false);
     $this->regionFactory->expects($this->once())->method('create')->willReturn($region);
     $country = $this->getMock('Magento\\Framework\\DataObject', ['loadByCode', 'getName']);
     $country->expects($this->once())->method('loadByCode')->with('ED')->willReturnSelf();
     $country->expects($this->once())->method('getName')->willReturn('Edoras');
     $this->countryFactory = $this->getMock('Magento\\Directory\\Model\\CountryFactory', [], [], '', false);
     $this->countryFactory->expects($this->once())->method('create')->willReturn($country);
     $this->model = new Information($this->renderer, $this->regionFactory, $this->countryFactory);
 }