public function setUp() { // unless we call parent::setUp() then we can skip the fixture // building stuff which isn't really neccessary here $this->connectionMock = $this->getMockBuilder('MartynBiz\\Mongo\\Connection')->disableOriginalConstructor()->getMock(); // mock method to return mock collection $this->connectionMock->method('getNextSequence')->willReturn(1); // swap the instance as it's a singleton Connection::setInstance($this->connectionMock); }
public function setup() { $this->connectionMock = $this->getMockBuilder('MartynBiz\\Mongo\\Connection')->disableOriginalConstructor()->getMock(); // mock method to return mock collection $this->connectionMock->method('getNextSequence')->willReturn(1); // reset Connection as it's being used across multiple tests (unit, int) Connection::getInstance()->resetInstance(); // swap the instance as it's a singleton Connection::setInstance($this->connectionMock); }