Пример #1
0
 /**
  * @param string|null $request
  * @param string|null|false $config
  * @param string|null $default
  * @dataProvider getConfigurationCountryCodeFromDefaultDataProvider
  */
 public function testGetConfigurationCountryCodeFromDefault($request, $config, $default)
 {
     $this->_configurationCountryCodePrepareRequest($request);
     $this->_configurationCountryCodePrepareConfig($config);
     $this->directoryHelperMock->expects($this->once())->method('getDefaultCountry')->will($this->returnValue($default));
     $this->_configurationCountryCodeAssertResult($default);
 }
Пример #2
0
 /**
  * @param string $value to assign to boolean
  * @param bool $expected text output
  * @param string $countryId
  * @param bool $isOptional
  *
  * @dataProvider validateValueDataProvider
  */
 public function testValidateValue($value, $expected, $countryId, $isOptional)
 {
     $storeLabel = 'Zip/Postal Code';
     $this->attributeMetadataMock->expects($this->once())->method('getStoreLabel')->willReturn($storeLabel);
     $this->directoryHelper->expects($this->once())->method('isZipCodeOptional')->willReturnMap([[$countryId, $isOptional]]);
     $object = $this->getClass($value);
     $object->setExtractedData(['country_id' => $countryId]);
     $actual = $object->validateValue($value);
     $this->assertEquals($expected, $actual);
 }
Пример #3
0
 /**
  * @param string $value to assign to boolean
  * @param bool $expected text output
  * @param string $countryId
  * @param bool $isOptional
  *
  * @dataProvider validateValueDataProvider
  */
 public function testValidateValue($value, $expected, $countryId, $isOptional)
 {
     $storeLabel = 'Zip/Postal Code';
     $this->attributeMock->expects($this->once())->method('getStoreLabel')->willReturn($storeLabel);
     $this->directoryHelperMock->expects($this->once())->method('isZipCodeOptional')->willReturnMap([[$countryId, $isOptional]]);
     $object = new \Magento\Customer\Model\Attribute\Data\Postcode($this->localeMock, $this->loggerMock, $this->localeResolverMock, $this->directoryHelperMock);
     $object->setAttribute($this->attributeMock);
     $object->setExtractedData(['country_id' => $countryId]);
     $actual = $object->validateValue($value);
     $this->assertEquals($expected, $actual);
 }
 /**
  * @param $data
  * @param $expected
  *
  * @dataProvider validateDataProvider
  */
 public function testValidate($data, $expected)
 {
     $this->directoryDataMock->expects($this->once())->method('getCountriesWithOptionalZip')->will($this->returnValue([]));
     $this->directoryDataMock->expects($this->never())->method('isRegionRequired');
     $this->model->setData($data);
     $this->assertEquals($expected, $this->model->validate());
 }
Пример #5
0
 /**
  * @dataProvider dataProviderGetBmlDisplay
  */
 public function testGetBmlDisplay($section, $expectedValue, $expectedFlag, $expected)
 {
     $this->_model->setStoreId(1);
     $this->directoryHelper->expects($this->any())->method('getDefaultCountry')->with(1)->will($this->returnValue('US'));
     $this->_scopeConfig->expects($this->any())->method('isSetFlag')->will($this->returnValue($expectedFlag));
     $this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValueMap([['payment/' . Config::METHOD_WPP_BML . '/' . $section . '_display', 'store', 1, $expectedValue], ['payment/' . Config::METHOD_WPP_BML . '/active', 'store', 1, $expectedValue], ['payment/' . Config::METHOD_WPP_PE_BML . '/active', 'store', 1, $expectedValue]]));
     $this->assertEquals($expected, $this->_model->getBmlDisplay($section));
 }
 protected function prepareMocksForInvalidAddressValidation()
 {
     $countryModel = $this->getMock('Magento\\Directory\\Model\\Country', [], [], '', false);
     $regionCollection = $this->getMock('Magento\\Directory\\Model\\ResourceModel\\Region\\Collection', [], [], '', false);
     $this->address->expects($this->once())->method('getShouldIgnoreValidation')->willReturn(false);
     $this->address->expects($this->atLeastOnce())->method('getCountryId');
     $this->address->expects($this->once())->method('getFirstname');
     $this->address->expects($this->once())->method('getLastname');
     $this->address->expects($this->once())->method('getStreetLine')->with(1);
     $this->address->expects($this->once())->method('getCity');
     $this->address->expects($this->once())->method('getTelephone');
     $this->address->expects($this->once())->method('getRegionId')->willReturn(null);
     $this->directoryData->expects($this->once())->method('getCountriesWithOptionalZip')->willReturn([]);
     $this->address->expects($this->once())->method('getCountryModel')->willReturn($countryModel);
     $countryModel->expects($this->once())->method('getRegionCollection')->willReturn($regionCollection);
     $regionCollection->expects($this->once())->method('getSize')->willReturn(2);
     $this->directoryData->expects($this->once())->method('isRegionRequired')->with(null)->willReturn(true);
 }
Пример #7
0
 public function setUp()
 {
     $this->_customerFactoryMock = $this->getMockBuilder('Magento\\Customer\\Model\\CustomerFactory')->disableOriginalConstructor()->setMethods(array('create'))->getMock();
     $this->_customerModelMock = $this->getMockBuilder('Magento\\Customer\\Model\\Customer')->disableOriginalConstructor()->setMethods(array('getId', 'getFirstname', 'getLastname', 'getName', 'getEmail', 'getAttributes', 'getConfirmation', 'setConfirmation', 'save', 'load', '__wakeup', 'authenticate', 'getData', 'getDefaultBilling', 'getDefaultShipping', 'getDefaultShippingAddress', 'getDefaultBillingAddress', 'getStoreId', 'getAddressById', 'getAddresses', 'getAddressItemById', 'getParentId', 'isConfirmationRequired', 'addAddress', 'loadByEmail', 'sendNewAccountEmail', 'setFirstname', 'setLastname', 'setEmail', 'setPassword', 'setData', 'setWebsiteId', 'getAttributeSetId', 'setAttributeSetId', 'validate', 'getRpToken', 'setRpToken', 'setRpTokenCreatedAt', 'isResetPasswordLinkTokenExpired', 'changeResetPasswordLinkToken', 'sendPasswordResetConfirmationEmail'))->getMock();
     $this->_addressRegistryMock = $this->getMockBuilder('Magento\\Customer\\Model\\AddressRegistry')->disableOriginalConstructor()->setMethods(array('retrieve', 'remove'))->getMock();
     $this->_customerRegistryMock = $this->getMockBuilder('Magento\\Customer\\Model\\CustomerRegistry')->disableOriginalConstructor()->setMethods(array('retrieve', 'remove'))->getMock();
     $this->_directoryData = $this->getMockBuilder('\\Magento\\Directory\\Helper\\Data')->disableOriginalConstructor()->setMethods(array('getCountriesWithOptionalZip'))->getMock();
     $this->_directoryData->expects($this->any())->method('getCountriesWithOptionalZip')->will($this->returnValue(array()));
     $this->_customerModelMock->expects($this->any())->method('getData')->with($this->equalTo(self::ATTRIBUTE_CODE))->will($this->returnValue(self::ATTRIBUTE_VALUE));
     $this->_customerModelMock->expects($this->any())->method('validate')->will($this->returnValue(true));
     $this->_setupStoreMock();
     $this->_validator = $this->getMockBuilder('\\Magento\\Customer\\Model\\Metadata\\Validator')->disableOriginalConstructor()->getMock();
     $this->objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $regionBuilder = $this->objectManagerHelper->getObject('Magento\\Customer\\Service\\V1\\Data\\RegionBuilder');
     $customerMetadataService = $this->getMockForAbstractClass('Magento\\Customer\\Service\\V1\\CustomerMetadataServiceInterface', array(), '', false);
     $addressMetadataService = $this->getMockForAbstractClass('Magento\\Customer\\Service\\V1\\AddressMetadataServiceInterface', array(), '', false);
     $addressMetadataService->expects($this->any())->method('getCustomAttributesMetadata')->will($this->returnValue(array()));
     $customerMetadataService->expects($this->any())->method('getCustomAttributesMetadata')->will($this->returnValue(array()));
     $this->_addressBuilder = $this->objectManagerHelper->getObject('Magento\\Customer\\Service\\V1\\Data\\AddressBuilder', array('regionBuilder' => $regionBuilder, 'metadataService' => $addressMetadataService));
     $customerBuilder = $this->objectManagerHelper->getObject('Magento\\Customer\\Service\\V1\\Data\\CustomerBuilder', ['metadataService' => $customerMetadataService]);
     $this->_customerConverter = new \Magento\Customer\Model\Converter($customerBuilder, $this->_customerFactoryMock, $this->_storeManagerMock);
     $this->_addressConverterMock = $this->getMockBuilder('\\Magento\\Customer\\Model\\Address\\Converter')->disableOriginalConstructor()->getMock();
 }
 public function testGetWebsites()
 {
     $this->directoryHelperMock->expects($this->once())->method('getBaseCurrencyCode')->willReturn('USD');
     $this->storeManagerMock->expects($this->once())->method('hasSingleStore')->willReturn(true);
     $this->assertSame([['value' => 0, 'label' => 'All Websites USD']], $this->model->getWebsites($this->productMock, $this->eavAttributeMock));
 }