summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-05-10 09:56:38 +0200
committerJoas Schilling <coding@schilljs.com>2017-05-10 09:56:38 +0200
commit538d32fe8734f563f3116c473f770bd4277c925b (patch)
tree004d99e6d04fdf07863ce3983869805b76833b3a /tests
parentca399406146d74f2f46f8b8815f0b3c165c996ab (diff)
downloadnextcloud-server-538d32fe8734f563f3116c473f770bd4277c925b.tar.gz
nextcloud-server-538d32fe8734f563f3116c473f770bd4277c925b.zip
Automatic injection into the Fetchers
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/App/AppStore/Fetcher/AppFetcherTest.php9
-rw-r--r--tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php4
-rw-r--r--tests/lib/App/AppStore/Fetcher/FetcherBase.php8
3 files changed, 18 insertions, 3 deletions
diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
index 6c0d079a204..f3769fc09c3 100644
--- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
+++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
@@ -22,6 +22,7 @@
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;
@@ -53,7 +54,13 @@ EOD;
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);
@@ -64,7 +71,7 @@ EOD;
->with('version')
->willReturn('11.0.0.2');
$this->fetcher = new AppFetcher(
- $this->appData,
+ $factory,
$this->clientService,
$this->timeFactory,
$this->config
diff --git a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
index 27f33bed997..6143da662dc 100644
--- a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
+++ b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
@@ -23,14 +23,14 @@ namespace Test\App\AppStore\Fetcher;
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
diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php
index 96e4f3ae81a..3d89ae942ab 100644
--- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php
+++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php
@@ -22,6 +22,7 @@
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;
@@ -34,6 +35,8 @@ use OCP\IConfig;
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 */
@@ -51,7 +54,12 @@ abstract class FetcherBase extends TestCase {
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);