Would something like this work? I haven't been able to test it out yet unfortunately.
Expectation e1 = EXPECT_CALL(*mockObject, beginTransaction());
Expectation e2 = EXPECT_CALL(*mockObject, doSomething()).Times(AnyNumber()).After(e1);
Expectation e3 = EXPECT_CALL(*mockObject, doSomethingElse()).Times(AnyNumber()).After(e1);
EXPECT_CALL(*mockObject, commit()).After(e1, e2, e3);
This basically says that beginTransaction()
must be called, and it must happen before any other call. And then doSomething()
and doSomethingElse()
can be called any number of times (including 0). Finally, commit()
must be called after the calls to the other functions.