/** * When none of the collected tax records apply to the ship group, * no taxes should be added to the tax container. */ public function testAddGiftTaxesToPayloadNoTaxesToAdd() { // Set the tax collector to have no relevent taxes to add to the ship group. $this->_taxCollector->expects($this->any())->method('getTaxRecords')->will($this->returnValue([$this->_itemGiftTax, $this->_merchGiftTax])); // Ship group can already have a tax container. $this->_shipGroup->expects($this->any())->method('getGiftPricing')->will($this->returnValue($this->_taxContainer)); // Side-effect tests: There should be no tax records for the ship // group so no tax payloads should be added to the iterable. $this->_taxIterable->expects($this->never())->method('offsetSet'); $this->_shipGroupHandler->addGiftTaxesToPayload(); }
/** * When the tax collector fails to collect new tax data, the session should * not get updated and quote totals should not be recollected. */ public function testHandleSalesQuoteCollectTotalsCollectFailure() { // Indicate new tax collection is required in the session flags. $this->coreSession->expects($this->any())->method('isTaxUpdateRequired')->will($this->returnValue(true)); // Set the tax collector to fail to make the TDF request and throw // an exception. $this->taxCollector->expects($this->once())->method('collectTaxes')->will($this->throwException(Mage::exception('EbayEnterprise_Tax_Exception_Collector'))); // Ensure session quote data is not updated, flags are not reset and // quote totals are not re-collected. $this->coreSession->expects($this->never())->method('updateWithQuote'); $this->coreSession->expects($this->never())->method('resetTaxUpdateRequired'); $this->quote->expects($this->never())->method('collectTotals'); $this->taxObserver->handleSalesQuoteCollectTotalsAfter($this->eventObserver); }
/** * Test collected tax totals for an address. Should gather tax records from * the tax collector and set relevent fields on the address. */ public function testCollect() { // Setup tax collector to return some tax records. $this->_taxCollector->expects($this->any())->method('getTaxRecordsByAddressId')->with($this->identicalTo($this->_addressId))->will($this->returnValue($this->_taxRecords)); $this->_taxCollector->expects($this->any())->method('getTaxDutiesByAddressId')->with($this->identicalTo($this->_addressId))->will($this->returnValue($this->_duties)); $this->_taxCollector->expects($this->any())->method('getTaxFeesByAddressId')->with($this->identicalTo($this->_addressId))->will($this->returnValue($this->_fees)); // Side-effect test - address should have total amount set for the // tax total. $this->_address->expects($this->once())->method('setTotalAmount')->with($this->identicalTo($this->_taxTotal->getCode()), $this->identicalTo($this->_totalTaxAmount))->wilL($this->returnSelf()); // Side-effect test - address should have base total amount set for the // tax total. $this->_address->expects($this->once())->method('setBaseTotalAmount')->with($this->identicalTo($this->_taxTotal->getCode()), $this->identicalTo($this->_totalTaxAmount))->wilL($this->returnSelf()); $this->_taxTotal->collect($this->_address); }