I have a ClassA that uses a ServiceB. In a certain case, ClassA should end up not invoking any methods of ServiceB except one. I now want to test this and verify no other methods are indeed called.
This can be done as follows:
$classA->expects( $this->once() )->method( 'first_method' );
$classA->expects( $this->never() )->method( 'second_method' );
$classA->expects( $this->never() )->method( 'third_method' );
...
Is there a way to simply state "no methods that are not first should be called on this object" rather then having to specify a restriction for each method?
I currently have this approach which works, though makes my test case dependent on two somewhat internal classes of PHPUnit, which I'd rather avoid.
$schema->expects( $this->never() )
->method( new PHPUnit_Framework_Constraint_Not( new PHPUnit_Framework_Constraint_IsEqual( 'addField' ) ) );
Is there a way to do the same using the fluent interface?