namespace OC\App\AppStore\Fetcher;
use OC\App\AppStore\Version\VersionParser;
+use OC\Files\AppData\Factory;
use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\Files\IAppData;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
class AppFetcher extends Fetcher {
/**
- * @param IAppData $appData
+ * @param Factory $appDataFactory
* @param IClientService $clientService
* @param ITimeFactory $timeFactory
* @param IConfig $config;
*/
- public function __construct(IAppData $appData,
+ public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config) {
parent::__construct(
- $appData,
+ $appDataFactory,
$clientService,
$timeFactory,
$config
namespace OC\App\AppStore\Fetcher;
+use OC\Files\AppData\Factory;
use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\Files\IAppData;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
class CategoryFetcher extends Fetcher {
/**
- * @param IAppData $appData
+ * @param Factory $appDataFactory
* @param IClientService $clientService
* @param ITimeFactory $timeFactory
* @param IConfig $config
*/
- public function __construct(IAppData $appData,
+ public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config) {
parent::__construct(
- $appData,
+ $appDataFactory,
$clientService,
$timeFactory,
$config
namespace OC\App\AppStore\Fetcher;
+use OC\Files\AppData\Factory;
use OCP\AppFramework\Http;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\IAppData;
protected $version;
/**
- * @param IAppData $appData
+ * @param Factory $appDataFactory
* @param IClientService $clientService
* @param ITimeFactory $timeFactory
* @param IConfig $config
*/
- public function __construct(IAppData $appData,
+ public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config) {
- $this->appData = $appData;
+ $this->appData = $appDataFactory->get('appstore');
$this->clientService = $clientService;
$this->timeFactory = $timeFactory;
$this->config = $config;
$this->registerService('AppHelper', function ($c) {
return new \OC\AppHelper();
});
- $this->registerService(AppFetcher::class, function ($c) {
- return new AppFetcher(
- $this->getAppDataDir('appstore'),
- $this->getHTTPClientService(),
- $this->query(TimeFactory::class),
- $this->getConfig()
- );
- });
$this->registerAlias('AppFetcher', AppFetcher::class);
-
- $this->registerService('CategoryFetcher', function ($c) {
- return new CategoryFetcher(
- $this->getAppDataDir('appstore'),
- $this->getHTTPClientService(),
- $this->query(TimeFactory::class),
- $this->getConfig()
- );
- });
+ $this->registerAlias('CategoryFetcher', CategoryFetcher::class);
$this->registerService(\OCP\ICache::class, function ($c) {
return new Cache\File();
* @return AppFetcher
*/
public function getAppFetcher() {
- return $this->query('AppFetcher');
+ return $this->query(AppFetcher::class);
}
/**
namespace OC;
-use OC\App\AppStore\Fetcher\AppFetcher;
use OC\Hooks\BasicEmitter;
use OC\IntegrityCheck\Checker;
use OC_App;
namespace OC\Settings;
-use OC\App\AppStore\Fetcher\AppFetcher;
-use OC\App\AppStore\Fetcher\CategoryFetcher;
use OC\AppFramework\Utility\TimeFactory;
use OC\Authentication\Token\IProvider;
use OC\Server;
Util::getDefaultEmailAddress('no-reply')
);
});
- $container->registerService(AppFetcher::class, function (IContainer $c) {
- /** @var Server $server */
- $server = $c->query('ServerContainer');
- return new AppFetcher(
- $server->getAppDataDir('appstore'),
- $server->getHTTPClientService(),
- $server->query(TimeFactory::class),
- $server->getConfig()
- );
- });
- $container->registerService(CategoryFetcher::class, function (IContainer $c) {
- /** @var Server $server */
- $server = $c->query('ServerContainer');
- return new CategoryFetcher(
- $server->getAppDataDir('appstore'),
- $server->getHTTPClientService(),
- $server->query(TimeFactory::class),
- $server->getConfig()
- );
- });
}
public function register() {
namespace Test\App\AppStore\Fetcher;
use OC\App\AppStore\Fetcher\AppFetcher;
+use OC\Files\AppData\Factory;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
public function setUp() {
parent::setUp();
+ /** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */
+ $factory = $this->createMock(Factory::class);
$this->appData = $this->createMock(IAppData::class);
+ $factory->expects($this->once())
+ ->method('get')
+ ->with('appstore')
+ ->willReturn($this->appData);
$this->clientService = $this->createMock(IClientService::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->config = $this->createMock(IConfig::class);
->with('version')
->willReturn('11.0.0.2');
$this->fetcher = new AppFetcher(
- $this->appData,
+ $factory,
$this->clientService,
$this->timeFactory,
$this->config
use OC\App\AppStore\Fetcher\CategoryFetcher;
-class CategoryFetcherTest extends FetcherBase {
+class CategoryFetcherTest extends FetcherBase {
public function setUp() {
parent::setUp();
$this->fileName = 'categories.json';
$this->endpoint = 'https://apps.nextcloud.com/api/v1/categories.json';
$this->fetcher = new CategoryFetcher(
- $this->appData,
+ $this->appDataFactory,
$this->clientService,
$this->timeFactory,
$this->config
namespace Test\App\AppStore\Fetcher;
use OC\App\AppStore\Fetcher\Fetcher;
+use OC\Files\AppData\Factory;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use Test\TestCase;
abstract class FetcherBase extends TestCase {
+ /** @var Factory|\PHPUnit_Framework_MockObject_MockObject */
+ protected $appDataFactory;
/** @var IAppData|\PHPUnit_Framework_MockObject_MockObject */
protected $appData;
/** @var IClientService|\PHPUnit_Framework_MockObject_MockObject */
public function setUp() {
parent::setUp();
+ $this->appDataFactory = $this->createMock(Factory::class);
$this->appData = $this->createMock(IAppData::class);
+ $this->appDataFactory->expects($this->once())
+ ->method('get')
+ ->with('appstore')
+ ->willReturn($this->appData);
$this->clientService = $this->createMock(IClientService::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->config = $this->createMock(IConfig::class);