/** * @param DataObject $storeInfo * @param $type * @dataProvider formatDataProvider */ public function testFormat(DataObject $storeInfo, $type) { $expected = implode("\n", $storeInfo->getData()); if ($type === 'html') { $expected = nl2br($expected); } $result = $this->model->format($storeInfo, $type); $this->assertEquals($expected, $result); }
/** * 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); }
/** * Retrieve formatted store address from config * * @param Store $store * @return string */ public function getFormattedAddress(Store $store) { return $this->renderer->format($this->getStoreInformationObject($store)); }