wrappee = $this->getMockBuilder(TransactionManager::class)->disableOriginalConstructor()->getMock(); $this->manager = new RDBTransactionManager($this->wrappee); } public function testStartOnce() { $this->wrappee ->expects($this->once()) ->method('start'); $this->manager->start(); } public function testException() { $this->wrappee ->expects($this->once()) ->method('start'); $this->wrappee ->expects($this->once()) ->method('getLevel') ->will($this->returnValue(1)); $this->expectException(RuntimeException::class); $this->manager->start(); $this->manager->start(); } public function testCommit() { $this->wrappee ->expects($this->at(0)) ->method('start'); $this->wrappee ->expects($this->at(1)) ->method('getLevel') ->will($this->returnValue(1)); $this->wrappee ->expects($this->at(2)) ->method('getLevel') ->will($this->returnValue(2)); $this->wrappee ->expects($this->at(3)) ->method('commit'); $this->wrappee ->expects($this->at(4)) ->method('getLevel') ->will($this->returnValue(1)); $this->wrappee ->expects($this->at(5)) ->method('commit'); $this->manager->start(); $this->manager->commit(); } }