public function testGetExistingValue() { $data = ['someKey' => 'someValue']; $registry = new Registry(); $registry->set('key', $data); $value = $registry->get('key'); $this->assertEquals($data, $value); }
/** * Get a Feed instance * @param bool $useCache * @return \Owncloud\Updater\Utils\Feed */ protected function getFeed($useCache = true) { if ($useCache && !is_null($this->registry->get('feed'))) { return $this->registry->get('feed'); } return $this->fetcher->getFeed(); }
public function testDownloadOwncloudFailure() { $md5 = '911'; $path = '/dev/null/o'; $registry = new Registry(); $registry->set('feed', new Feed($this->feedData)); $badNewsException = new \Exception('Bad news'); $fetcherMock = $this->getMockBuilder('Owncloud\\Updater\\Utils\\Fetcher')->disableOriginalConstructor()->getMock(); $fetcherMock->method('getBaseDownloadPath')->willReturn($path); $fetcherMock->method('getOwncloud')->will($this->throwException($badNewsException)); $fetcherMock->method('getMd5')->willReturn($md5 . '0'); $fsHelperMock = $this->getMockBuilder('Owncloud\\Updater\\Utils\\FilesystemHelper')->disableOriginalConstructor()->getMock(); $fsHelperMock->method('md5File')->willReturn($md5); $fsHelperMock->method('fileExists')->willReturn(true); $downloadController = new DownloadController($fetcherMock, $registry, $fsHelperMock); $result = $downloadController->downloadOwncloud(); $this->assertArraySubset(['success' => false, 'data' => []], $result); $this->assertEquals($badNewsException, $result['exception']); }