/** * Get icons for available payment methods * * @return array */ protected function getIcons() { $icons = []; $types = $this->ccConfig->getCcAvailableTypes(); foreach (array_keys($types) as $code) { if (!array_key_exists($code, $icons)) { $asset = $this->ccConfig->createAsset('Magento_Payment::images/cc/' . strtolower($code) . '.png'); $placeholder = $this->assetSource->findRelativeSourceFilePath($asset); if ($placeholder) { list($width, $height) = getimagesize($asset->getSourceFile()); $icons[$code] = ['url' => $asset->getUrl(), 'width' => $width, 'height' => $height]; } } } return $icons; }
/** * Retrieve availables credit card types * * @param string $methodCode * @return array */ protected function getCcAvailableTypes($methodCode) { $types = $this->ccConfig->getCcAvailableTypes(); $availableTypes = $this->methods[$methodCode]->getConfigData('cctypes'); if ($availableTypes) { $availableTypes = explode(',', $availableTypes); foreach (array_keys($types) as $code) { if (!in_array($code, $availableTypes)) { unset($types[$code]); } } } return $types; }
public function testGetCcAvailableTypes() { $data = [1, 2, 3]; $this->configMock->expects($this->once())->method('getCcTypes')->willReturn($data); $this->assertEquals($data, $this->model->getCcAvailableTypes()); }