sdbusplus testing add new_mock method

This method returns an sdbusplus::bus::bus using the mock
provided and adds the necessary EXPECT_CALL ahead saving
a line of code in all unit-tests using this.

Change-Id: Icc07405eb0bd4e4dca6c28fdb71e7ff2e5c06c3f
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/sdbusplus/test/sdbus_mock.hpp b/sdbusplus/test/sdbus_mock.hpp
index c3b5454..059eae6 100644
--- a/sdbusplus/test/sdbus_mock.hpp
+++ b/sdbusplus/test/sdbus_mock.hpp
@@ -87,4 +87,15 @@
     MOCK_METHOD2(sd_bus_wait, int(sd_bus *, uint64_t));
 };
 
+bus::bus get_mocked_new(SdBusMock *sdbus)
+{
+    using ::testing::IsNull;
+    using ::testing::Return;
+
+    EXPECT_CALL(*sdbus, sd_bus_ref(IsNull())).WillRepeatedly(Return(nullptr));
+    bus::bus bus_mock(nullptr, sdbus);
+
+    return bus_mock;
+}
+
 } // namespace sdbusplus