config = $this->getMockBuilder( '\OCP\IConfig') ->disableOriginalConstructor() ->getMock(); $this->db = $this->getMockBuilder( '\OCP\IDBConnection') ->disableOriginalConstructor() ->getMock(); $this->service = $this->getMockBuilder( '\OCA\News\Service\ItemService') ->disableOriginalConstructor() ->getMock(); $this->upgrade = new Upgrade($this->config, $this->service, $this->db, 'news'); } public function testUpgrade() { $this->config->expects($this->once()) ->method('getAppValue') ->with($this->equalTo('news'), $this->equalTo('installed_version')) ->will($this->returnValue('8.7.3')); $this->service->expects($this->once()) ->method('generateSearchIndices'); $this->upgrade->upgrade(); } public function testNoUpgrade() { $this->config->expects($this->once()) ->method('getAppValue') ->with($this->equalTo('news'), $this->equalTo('installed_version')) ->will($this->returnValue('8.7.4')); $this->service->expects($this->never()) ->method('generateSearchIndices'); $this->upgrade->upgrade(); } }