public function testGetConfigWithEmptyCustomer() { $customerId = 0; $expected = ['payment' => ['paypalBillingAgreement' => ['agreements' => [], 'transportName' => AbstractAgreement::TRANSPORT_BILLING_AGREEMENT_ID]]]; $this->currentCustomerMock->expects($this->once())->method('getCustomerId')->willReturn($customerId); $this->agreementFactoryMock->expects($this->never())->method('create'); $this->assertEquals($expected, $this->configProvider->getConfig()); }
public function testGetCollection() { $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue(new \Magento\Framework\Object(array('id' => 42)))); $this->currentCustomer->expects($this->any())->method('getCustomerId')->will($this->returnValue(4242)); $this->collection->expects($this->any())->method('addStoreFilter')->with(42)->will($this->returnValue($this->collection)); $this->collection->expects($this->any())->method('addCustomerFilter')->with(4242)->will($this->returnValue($this->collection)); $this->collection->expects($this->any())->method('setDateOrder')->with()->will($this->returnValue($this->collection)); $this->collection->expects($this->any())->method('setPageSize')->with(5)->will($this->returnValue($this->collection)); $this->collection->expects($this->any())->method('load')->with()->will($this->returnValue($this->collection)); $this->collection->expects($this->any())->method('addReviewSummary')->with()->will($this->returnValue($this->collection)); $this->assertSame($this->collection, $this->object->getCollection()); }
public function testSetLayoutWithoutAddress() { $addressId = 1; $customerPrefix = 'prefix'; $customerFirstName = 'firstname'; $customerMiddlename = 'middlename'; $customerLastname = 'lastname'; $customerSuffix = 'suffix'; $title = 'title'; $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->getMock(); $this->requestMock->expects($this->once())->method('getParam')->with('id', null)->willReturn($addressId); $this->addressRepositoryMock->expects($this->once())->method('getById')->with($addressId)->willThrowException(\Magento\Framework\Exception\NoSuchEntityException::singleField('addressId', $addressId)); $newAddressMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->getMock(); $this->addressDataFactoryMock->expects($this->once())->method('create')->willReturn($newAddressMock); $customerMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock(); $this->currentCustomerMock->expects($this->once())->method('getCustomer')->willReturn($customerMock); $customerMock->expects($this->once())->method('getPrefix')->willReturn($customerPrefix); $customerMock->expects($this->once())->method('getFirstname')->willReturn($customerFirstName); $customerMock->expects($this->once())->method('getMiddlename')->willReturn($customerMiddlename); $customerMock->expects($this->once())->method('getLastname')->willReturn($customerLastname); $customerMock->expects($this->once())->method('getSuffix')->willReturn($customerSuffix); $newAddressMock->expects($this->once())->method('setPrefix')->with($customerPrefix)->willReturnSelf(); $newAddressMock->expects($this->once())->method('setFirstname')->with($customerFirstName)->willReturnSelf(); $newAddressMock->expects($this->once())->method('setMiddlename')->with($customerMiddlename)->willReturnSelf(); $newAddressMock->expects($this->once())->method('setLastname')->with($customerLastname)->willReturnSelf(); $newAddressMock->expects($this->once())->method('setSuffix')->with($customerSuffix)->willReturnSelf(); $pageTitleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock(); $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($pageTitleMock); $this->model->setData('title', $title); $pageTitleMock->expects($this->once())->method('set')->with($title)->willReturnSelf(); $this->assertEquals($this->model, $this->model->setLayout($layoutMock)); $this->assertEquals($layoutMock, $this->model->getLayout()); }
/** * test getDefaultShippingAddress */ public function testGetDefaultShippingAddress() { $this->currentCustomerMock->expects($this->once())->method('getCustomerId')->will($this->returnValue($this->customerCurrentId)); $this->customerAddressServiceMock->expects($this->once())->method('getDefaultShippingAddress')->will($this->returnValue($this->customerAddressDataMock)); $this->assertEquals($this->customerAddressDataMock, $this->currentCustomerAddress->getDefaultShippingAddress()); }
/** * @param bool $ask * @param string|null $expected * @dataProvider getBillingAgreementCodeDataProvider */ public function testGetBillingAgreementCode($ask, $expected) { $this->currentCustomer->expects($this->once())->method('getCustomerId')->will($this->returnValue('customer id')); $this->_paypalData->expects($this->once())->method('shouldAskToCreateBillingAgreement')->with($this->identicalTo($this->_paypalConfig), 'customer id')->will($this->returnValue($ask)); $this->assertEquals($expected, $this->_model->getBillingAgreementCode()); }