Validating Individual Shipping Methods

Out of the box Magium will select the first shipping method on the screen. But there might be some times when you need to validate a particular shipping method, or force an error to be thrown if a shipping method does not exist. ’tis now easy to do.

use Magium\Magento\AbstractMagentoTestCase; class ShippingTest extends AbstractMagentoTestCase { public function testSelectShipping() { $this->setPaymentMethod('CashOnDelivery'); $this->setShippingMethod('ByName'); $this->getShippingMethod()->setName('Fixed'); } }

Calling setName() will search the shipping HTML to find the first match that contains the specified text. So if you have a shipping method called “Priority Mail 2-Day Small Flat Rate Box“, entering “Priority Mail” will also match it.

If you want to validate that a shipping method is not available set the expected exception for the test as