expects( $this->never() )->method( $this->anythingBut( 'foo', 'bar' ) ); * which will throw if any unexpected method is called. * * @param mixed ...$values Values that are not matched */ protected function anythingBut( ...$values ) { return $this->logicalNot( $this->logicalOr( ...array_map( [ $this, 'matches' ], $values ) ) ); } /** * Return a PHPUnit mock that is expected to never have any methods called on it. * * @param string $type * @return object */ protected function createNoOpMock( $type ) { $mock = $this->createMock( $type ); $mock->expects( $this->never() )->method( $this->anythingBut( '__destruct' ) ); return $mock; } }