我需要使用什么:TDD中的聚合或组合?

I'm using TDD. I need to use raw SQL queries in my system. TDD suggests that I need to test only business logic (all tests of database, mail sending or file system is a integration tests). So, I place my SQL code in a separated class which I want to mock. Here is a code:

// Creating shipping method data provider mock
$shippingMethodDataProviderMock = $this->getMockBuilder('\ordersmanager\Model\Order\ShippingMethod\ShippingMethodDataProvider')->disableOriginalConstructor()->getMock();

// Getting shipping method instance
$emsShippingMethod = ShippingMethodFactory::getShippingMethod('ems', $shippingMethodDataProviderMock);

But I don't want to pass a ShippingMethodProvider instance to the ShippingMethodFactory in client code.

I can use a composition instead of aggregation: creating a ShippingMethodProvider in a ShippingMethodFactory and pass it to ShippingMethod constructor. But in that case I can't mock ShippingMethodProvider because it isolated from client code.

I can create a wrapper for ShippingMethodFactory that will not be unit-tested but will create a pleasant API like this:

$emsShippingMethod = ShippingMethodFactory::getShippingMethod('ems');

But this wrapper will not be tested.

What is a better way to test this and have a good API?