/** * GIVEN An <sdkApi> that will thrown an <exception> of <exceptionType> when making a request. * WHEN A request is made. * THEN The <exception> will be caught. * * @param string * @dataProvider provideSdkExceptions */ public function testSdkExceptionHandling($exceptionType) { $exception = new $exceptionType(__METHOD__ . ': Test Exception'); // Assert that the send method is called and that it will throw // an exception. This is the closest thing to a meaningful assertion // this test can make. $this->api->expects($this->once())->method('send')->will($this->throwException($exception)); $reservation = Mage::getModel('ebayenterprise_inventory/allocation_reservation'); // Create deallocator mock to be tested. Mocked methods allow only // exception handling to be tested without depending upon methods needed // to create the API instance or fill out the payloads. $deallocator = $this->getModelMock('ebayenterprise_inventory/allocation_deallocator', ['prepareApi', 'prepareRequest'], false, [['log_context' => $this->logContext]]); $deallocator->method('prepareApi')->will($this->returnValue($this->api)); $deallocator->method('prepareRequest')->will($this->returnSelf()); // Nothing obvious to assert other than the side-effect of the send // method being called. All exceptions should be caught and suppressed. // The method doesn't return anything, just triggers side-effects. // Trigger the method and just make sure the send method gets called // and no exceptions arise. $deallocator->rollback($reservation); }