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->once()) ->method('start'); $this->wrappee ->expects($this->exactly(4)) ->method('getLevel') ->willReturnOnConsecutiveCalls(1, 2, 1, 0); $this->wrappee ->expects($this->exactly(2)) ->method('commit'); $this->manager->start(); $this->manager->commit(); } }