fix most named service injection
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This commit is contained in:
Родитель
ce5ec9eda5
Коммит
2da416864e
|
@ -49,9 +49,9 @@ $eventDispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', $de
|
|||
|
||||
$l = \OC::$server->getL10N('maps');
|
||||
|
||||
$container->query('OCP\INavigationManager')->add(function () use ($container) {
|
||||
$urlGenerator = $container->query('OCP\IURLGenerator');
|
||||
$l10n = $container->query('OCP\IL10N');
|
||||
$container->query(\OCP\INavigationManager::class)->add(function () use ($container) {
|
||||
$urlGenerator = $container->query(\OCP\IURLGenerator::class);
|
||||
$l10n = $container->query(\OCP\IL10N::class);
|
||||
return [
|
||||
'id' => 'maps',
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace OCA\Maps\AppInfo;
|
|||
|
||||
use OCA\Maps\DB\FavoriteShareMapper;
|
||||
use \OCP\AppFramework\App;
|
||||
use \OCP\IServerContainer;
|
||||
use OCA\Maps\Hooks\FileHooks;
|
||||
use OCA\Maps\Service\PhotofilesService;
|
||||
use OCA\Maps\Service\TracksService;
|
||||
|
@ -28,12 +29,12 @@ class Application extends App {
|
|||
|
||||
$this->getContainer()->registerService('FileHooks', function($c) {
|
||||
return new FileHooks(
|
||||
$c->query('ServerContainer')->getRootFolder(),
|
||||
$c->query(IServerContainer::class)->getRootFolder(),
|
||||
\OC::$server->query(PhotofilesService::class),
|
||||
\OC::$server->query(TracksService::class),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query('AppName'),
|
||||
$c->query('ServerContainer')->getLockingProvider()
|
||||
$c->query(IServerContainer::class)->getLockingProvider()
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ class PageController extends Controller {
|
|||
|
||||
public function __construct($AppName,
|
||||
IRequest $request,
|
||||
$UserId,
|
||||
IConfig $config,
|
||||
IInitialStateService $initialStateService){
|
||||
IInitialStateService $initialStateService,
|
||||
$UserId){
|
||||
parent::__construct($AppName, $request);
|
||||
$this->userId = $UserId;
|
||||
$this->config = $config;
|
||||
|
|
|
@ -29,7 +29,7 @@ class AppTest extends \PHPUnit\Framework\TestCase {
|
|||
}
|
||||
|
||||
public function testAppInstalled() {
|
||||
$appManager = $this->container->query('OCP\App\IAppManager');
|
||||
$appManager = $this->container->query(\OCP\App\IAppManager::class);
|
||||
$this->assertTrue($appManager->isInstalled('maps'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ use OCP\AppFramework\Http\TemplateResponse;
|
|||
use OCA\DAV\Connector\Sabre\Principal;
|
||||
use OCA\Maps\Service\AddressService;
|
||||
use OCP\Files\IAppData;
|
||||
use \OCP\IServerContainer;
|
||||
use \OCA\DAV\CardDAV\CardDavBackend;
|
||||
use OCA\DAV\CardDAV\ContactsManager;
|
||||
|
||||
|
@ -83,25 +84,25 @@ class ContactsControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
|
||||
$urlGenerator = $c->getServer()->getURLGenerator();
|
||||
|
||||
$this->contactsManager = $c->query('ServerContainer')->getContactsManager();
|
||||
$this->contactsManager = $c->query(IServerContainer::class)->getContactsManager();
|
||||
$this->cm = $c->query(ContactsManager::class);
|
||||
$this->cm->setupContactsProvider($this->contactsManager, 'test', $urlGenerator);
|
||||
|
||||
$this->app = new Application();
|
||||
$this->container = $this->app->getContainer();
|
||||
$c = $this->container;
|
||||
$this->config = $c->query('ServerContainer')->getConfig();
|
||||
$this->config = $c->query(IServerContainer::class)->getConfig();
|
||||
|
||||
$this->appData = $this->getMockBuilder('\OCP\Files\IAppData')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->addressService = new AddressService(
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query('ServerContainer')->getJobList(),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(IServerContainer::class)->getJobList(),
|
||||
$this->appData,
|
||||
$c->query('ServerContainer')->query(\OCP\IDBConnection::class)
|
||||
$c->query(IServerContainer::class)->query(\OCP\IDBConnection::class)
|
||||
);
|
||||
|
||||
//$this->userPrincipalBackend = new Principal(
|
||||
|
@ -109,7 +110,7 @@ class ContactsControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
// $c->getServer()->getGroupManager(),
|
||||
// $c->getServer()->getShareManager(),
|
||||
// \OC::$server->getUserSession(),
|
||||
// $c->query('ServerContainer')->getConfig(),
|
||||
// $c->query(IServerContainer::class)->getConfig(),
|
||||
// \OC::$server->getAppManager()
|
||||
//);
|
||||
$this->userPrincipalBackend = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Principal')
|
||||
|
@ -117,7 +118,7 @@ class ContactsControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
->getMock();
|
||||
|
||||
$this->cdBackend = new CardDavBackend(
|
||||
$c->query('ServerContainer')->query(\OCP\IDBConnection::class),
|
||||
$c->query(IServerContainer::class)->query(\OCP\IDBConnection::class),
|
||||
$this->userPrincipalBackend,
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
|
@ -126,14 +127,14 @@ class ContactsControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
|
||||
$this->contactsController = new ContactsController(
|
||||
$this->appName,
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$this->request,
|
||||
$c->query('ServerContainer')->query(\OCP\IDBConnection::class),
|
||||
$c->query(IServerContainer::class)->query(\OCP\IDBConnection::class),
|
||||
$this->contactsManager,
|
||||
$this->addressService,
|
||||
'test',
|
||||
$this->cdBackend,
|
||||
$c->query('ServerContainer')->getAvatarManager()
|
||||
$c->query(IServerContainer::class)->getAvatarManager()
|
||||
);
|
||||
//$this->contactsController = $this->getMockBuilder('OCA\Maps\Controller\ContactsController')
|
||||
// ->disableOriginalConstructor()
|
||||
|
@ -141,20 +142,20 @@ class ContactsControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
|
||||
$this->contactsController2 = new ContactsController(
|
||||
$this->appName,
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$this->request,
|
||||
$c->query('ServerContainer')->query(\OCP\IDBConnection::class),
|
||||
$c->query(IServerContainer::class)->query(\OCP\IDBConnection::class),
|
||||
$this->contactsManager,
|
||||
$this->addressService,
|
||||
'test2',
|
||||
$this->cdBackend,
|
||||
$c->query('ServerContainer')->getAvatarManager()
|
||||
$c->query(IServerContainer::class)->getAvatarManager()
|
||||
);
|
||||
|
||||
$this->utilsController = new UtilsController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getAppManager(),
|
||||
'test'
|
||||
);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace OCA\Maps\Controller;
|
||||
|
||||
use \OCP\IServerContainer;
|
||||
use \OCA\Maps\AppInfo\Application;
|
||||
use \OCA\Maps\Service\DevicesService;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
@ -74,19 +75,19 @@ class DevicesApiControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$this->app = new Application();
|
||||
$this->container = $this->app->getContainer();
|
||||
$c = $this->container;
|
||||
$this->config = $c->query('ServerContainer')->getConfig();
|
||||
$this->config = $c->query(IServerContainer::class)->getConfig();
|
||||
|
||||
$this->devicesApiController = new DevicesApiController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer'),
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getShareManager(),
|
||||
$c->getServer()->getAppManager(),
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(DevicesService::class),
|
||||
'test'
|
||||
);
|
||||
|
@ -94,14 +95,14 @@ class DevicesApiControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$this->devicesApiController2 = new DevicesApiController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer'),
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getShareManager(),
|
||||
$c->getServer()->getAppManager(),
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(DevicesService::class),
|
||||
'test2'
|
||||
);
|
||||
|
@ -109,7 +110,7 @@ class DevicesApiControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$this->utilsController = new UtilsController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getAppManager(),
|
||||
'test'
|
||||
);
|
||||
|
@ -237,7 +238,7 @@ class DevicesApiControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
// $resp = $this->devicesApiController->deleteDevice($device['id']);
|
||||
// }
|
||||
|
||||
// $userfolder = $this->container->query('ServerContainer')->getUserFolder('test');
|
||||
// $userfolder = $this->container->query(IServerContainer::class)->getUserFolder('test');
|
||||
// $content1 = file_get_contents('tests/test_files/devicesOk.gpx');
|
||||
// $userfolder->newFile('devicesOk.gpx')->putContent($content1);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace OCA\Maps\Controller;
|
||||
|
||||
use \OCP\IServerContainer;
|
||||
use \OCA\Maps\AppInfo\Application;
|
||||
use \OCA\Maps\Service\DevicesService;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
@ -74,44 +75,44 @@ class DevicesControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$this->app = new Application();
|
||||
$this->container = $this->app->getContainer();
|
||||
$c = $this->container;
|
||||
$this->config = $c->query('ServerContainer')->getConfig();
|
||||
$this->config = $c->query(IServerContainer::class)->getConfig();
|
||||
|
||||
$this->devicesController = new DevicesController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer'),
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getShareManager(),
|
||||
$c->getServer()->getAppManager(),
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(DevicesService::class),
|
||||
$c->query('ServerContainer')->getDateTimeZone(),
|
||||
$c->query(IServerContainer::class)->getDateTimeZone(),
|
||||
'test'
|
||||
);
|
||||
|
||||
$this->devicesController2 = new DevicesController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer'),
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getShareManager(),
|
||||
$c->getServer()->getAppManager(),
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(DevicesService::class),
|
||||
$c->query('ServerContainer')->getDateTimeZone(),
|
||||
$c->query(IServerContainer::class)->getDateTimeZone(),
|
||||
'test2'
|
||||
);
|
||||
|
||||
$this->utilsController = new UtilsController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getAppManager(),
|
||||
'test'
|
||||
);
|
||||
|
@ -261,7 +262,7 @@ class DevicesControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$resp = $this->devicesController->deleteDevice($device['id']);
|
||||
}
|
||||
|
||||
$userfolder = $this->container->query('ServerContainer')->getUserFolder('test');
|
||||
$userfolder = $this->container->query(IServerContainer::class)->getUserFolder('test');
|
||||
$content1 = file_get_contents('tests/test_files/devicesOk.gpx');
|
||||
$userfolder->newFile('devicesOk.gpx')->putContent($content1);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace OCA\Maps\Controller;
|
||||
|
||||
use \OCP\IServerContainer;
|
||||
use \OCA\Maps\AppInfo\Application;
|
||||
use \OCA\Maps\Service\FavoritesService;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
@ -77,19 +78,19 @@ class FavoritesApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$this->app = new Application();
|
||||
$this->container = $this->app->getContainer();
|
||||
$c = $this->container;
|
||||
$this->config = $c->query('ServerContainer')->getConfig();
|
||||
$this->config = $c->query(IServerContainer::class)->getConfig();
|
||||
|
||||
$this->favoritesApiController = new FavoritesApiController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer'),
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getShareManager(),
|
||||
$c->getServer()->getAppManager(),
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(FavoritesService::class),
|
||||
'test'
|
||||
);
|
||||
|
@ -97,14 +98,14 @@ class FavoritesApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$this->favoritesApiController2 = new FavoritesApiController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer'),
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getShareManager(),
|
||||
$c->getServer()->getAppManager(),
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(FavoritesService::class),
|
||||
'test2'
|
||||
);
|
||||
|
@ -112,7 +113,7 @@ class FavoritesApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$this->utilsController = new UtilsController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getAppManager(),
|
||||
'test'
|
||||
);
|
||||
|
|
|
@ -17,6 +17,7 @@ use \OCA\Maps\AppInfo\Application;
|
|||
use OCA\Maps\DB\FavoriteShareMapper;
|
||||
use \OCA\Maps\Service\FavoritesService;
|
||||
use OCP\AppFramework\Http;
|
||||
use \OCP\IServerContainer;
|
||||
|
||||
class FavoritesControllerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
@ -85,21 +86,21 @@ class FavoritesControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$this->app = new Application();
|
||||
$this->container = $this->app->getContainer();
|
||||
$c = $this->container;
|
||||
$this->config = $c->query('ServerContainer')->getConfig();
|
||||
$this->config = $c->query(IServerContainer::class)->getConfig();
|
||||
|
||||
$this->favoritesController = new FavoritesController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer'),
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getShareManager(),
|
||||
$c->getServer()->getAppManager(),
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(FavoritesService::class),
|
||||
$c->query('ServerContainer')->getDateTimeZone(),
|
||||
$c->query(IServerContainer::class)->getDateTimeZone(),
|
||||
$c->query(FavoriteShareMapper::class),
|
||||
'test'
|
||||
);
|
||||
|
@ -107,16 +108,16 @@ class FavoritesControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$this->favoritesController2 = new FavoritesController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer'),
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getShareManager(),
|
||||
$c->getServer()->getAppManager(),
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(FavoritesService::class),
|
||||
$c->query('ServerContainer')->getDateTimeZone(),
|
||||
$c->query(IServerContainer::class)->getDateTimeZone(),
|
||||
$c->query(FavoriteShareMapper::class),
|
||||
'test2'
|
||||
);
|
||||
|
@ -124,7 +125,7 @@ class FavoritesControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$this->utilsController = new UtilsController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getAppManager(),
|
||||
'test'
|
||||
);
|
||||
|
@ -208,7 +209,7 @@ class FavoritesControllerTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testImportExportFavorites()
|
||||
{
|
||||
$userfolder = $this->container->query('ServerContainer')->getUserFolder('test');
|
||||
$userfolder = $this->container->query(IServerContainer::class)->getUserFolder('test');
|
||||
$content1 = file_get_contents('tests/test_files/favoritesOk.gpx');
|
||||
$newFile = $userfolder->newFile('favoritesOk.gpx');
|
||||
$newFile->putContent($content1);
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace OCA\Maps\Controller;
|
|||
|
||||
use \OCA\Maps\AppInfo\Application;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use \OCP\IServerContainer;
|
||||
|
||||
|
||||
class PageControllerTest extends \PHPUnit\Framework\TestCase {
|
||||
|
@ -28,13 +29,13 @@ class PageControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$this->app = new Application();
|
||||
$this->container = $this->app->getContainer();
|
||||
$c = $this->container;
|
||||
$this->config = $c->query('ServerContainer')->getConfig();
|
||||
$this->config = $c->query(IServerContainer::class)->getConfig();
|
||||
|
||||
$this->oldGHValue = $this->config->getAppValue('maps', 'graphhopperURL');
|
||||
$this->config->setAppValue('maps', 'graphhopperURL', 'https://graphhopper.com:8080');
|
||||
|
||||
$this->controller = new PageController(
|
||||
'maps', $request, $this->userId, $this->config, $initialStateService
|
||||
'maps', $request, $this->config, $initialStateService, $this->userId
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ use OCA\Maps\Service\TracksService;
|
|||
use OCA\Maps\Service\DevicesService;
|
||||
use OCA\Maps\DB\GeophotoMapper;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use \OCP\IServerContainer;
|
||||
|
||||
|
||||
class PhotosControllerTest extends \PHPUnit\Framework\TestCase {
|
||||
|
@ -81,22 +82,22 @@ class PhotosControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$this->app = new Application();
|
||||
$this->container = $this->app->getContainer();
|
||||
$c = $this->container;
|
||||
$this->config = $c->query('ServerContainer')->getConfig();
|
||||
$this->config = $c->query(IServerContainer::class)->getConfig();
|
||||
|
||||
$this->rootFolder = $c->query('ServerContainer')->getRootFolder();
|
||||
$this->rootFolder = $c->query(IServerContainer::class)->getRootFolder();
|
||||
|
||||
$this->photoFileService = new PhotoFilesService(
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$this->rootFolder,
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(GeophotoMapper::class),
|
||||
$c->query('ServerContainer')->getShareManager(),
|
||||
$c->query(IServerContainer::class)->getShareManager(),
|
||||
$c->query(\OCP\BackgroundJob\IJobList::class)
|
||||
);
|
||||
|
||||
$this->photosController = new PhotosController(
|
||||
$this->appName,
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$this->request,
|
||||
$c->query(GeoPhotoService::class),
|
||||
$this->photoFileService,
|
||||
|
@ -105,7 +106,7 @@ class PhotosControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
|
||||
$this->photosController2 = new PhotosController(
|
||||
$this->appName,
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$this->request,
|
||||
$c->query(GeoPhotoService::class),
|
||||
$this->photoFileService,
|
||||
|
@ -115,12 +116,12 @@ class PhotosControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$this->utilsController = new UtilsController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getAppManager(),
|
||||
'test'
|
||||
);
|
||||
|
||||
$userfolder = $this->container->query('ServerContainer')->getUserFolder('test');
|
||||
$userfolder = $this->container->query(IServerContainer::class)->getUserFolder('test');
|
||||
// delete files
|
||||
if ($userfolder->nodeExists('nc.jpg')) {
|
||||
$file = $userfolder->get('nc.jpg');
|
||||
|
@ -131,7 +132,7 @@ class PhotosControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$file->delete();
|
||||
}
|
||||
// delete db
|
||||
$qb = $c->query('ServerContainer')->query(\OCP\IDBConnection::class)->getQueryBuilder();
|
||||
$qb = $c->query(IServerContainer::class)->query(\OCP\IDBConnection::class)->getQueryBuilder();
|
||||
$qb->delete('maps_photos')
|
||||
->where(
|
||||
$qb->expr()->eq('user_id', $qb->createNamedParameter('test', IQueryBuilder::PARAM_STR))
|
||||
|
@ -160,7 +161,7 @@ class PhotosControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
public function testAddGetPhotos() {
|
||||
$c = $this->app->getContainer();
|
||||
|
||||
$userfolder = $this->container->query('ServerContainer')->getUserFolder('test');
|
||||
$userfolder = $this->container->query(IServerContainer::class)->getUserFolder('test');
|
||||
|
||||
$filename = 'tests/test_files/nc.jpg';
|
||||
$handle = fopen($filename, 'rb');
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace OCA\Maps\Controller;
|
|||
|
||||
use OC;
|
||||
use OC\AppFramework\Http;
|
||||
use \OCP\IServerContainer;
|
||||
use OCA\Maps\AppInfo\Application;
|
||||
use OCA\Maps\DB\FavoriteShare;
|
||||
use OCA\Maps\DB\FavoriteShareMapper;
|
||||
|
@ -57,18 +58,18 @@ class PublicFavoritesApiControllerTest extends TestCase
|
|||
$requestMock = $this->getMockBuilder('OCP\IRequest')->getMock();
|
||||
$sessionMock = $this->getMockBuilder('OCP\ISession')->getMock();
|
||||
|
||||
$this->config = $container->query('ServerContainer')->getConfig();
|
||||
$this->config = $container->query(IServerContainer::class)->getConfig();
|
||||
|
||||
$this->favoritesService = new FavoritesService(
|
||||
$container->query('ServerContainer')->getLogger(),
|
||||
$container->query('ServerContainer')->getL10N($appName),
|
||||
$container->query('ServerContainer')->getSecureRandom(),
|
||||
$container->query(IServerContainer::class)->getLogger(),
|
||||
$container->query(IServerContainer::class)->getL10N($appName),
|
||||
$container->query(IServerContainer::class)->getSecureRandom(),
|
||||
$container->query(\OCP\IDBConnection::class)
|
||||
);
|
||||
|
||||
$this->favoriteShareMapper = new FavoriteShareMapper(
|
||||
$container->query(\OCP\IDBConnection::class),
|
||||
$container->query('ServerContainer')->getSecureRandom()
|
||||
$container->query(IServerContainer::class)->getSecureRandom()
|
||||
);
|
||||
|
||||
$this->publicFavoritesApiController = new PublicFavoritesApiController(
|
||||
|
|
|
@ -31,6 +31,7 @@ use OCA\Maps\Service\FavoritesService;
|
|||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\AppFramework\IAppContainer;
|
||||
use \OCP\IServerContainer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
|
@ -67,28 +68,28 @@ class PublicPageControllerTest extends TestCase
|
|||
$appName = $container->query('AppName');
|
||||
|
||||
$this->favoritesService = new FavoritesService(
|
||||
$container->query('ServerContainer')->getLogger(),
|
||||
$container->query('ServerContainer')->getL10N($appName),
|
||||
$container->query('ServerContainer')->getSecureRandom(),
|
||||
$container->query(IServerContainer::class)->getLogger(),
|
||||
$container->query(IServerContainer::class)->getL10N($appName),
|
||||
$container->query(IServerContainer::class)->getSecureRandom(),
|
||||
$container->query(\OCP\IDBConnection::class)
|
||||
);
|
||||
|
||||
$this->favoriteShareMapper = new FavoriteShareMapper(
|
||||
$container->query(\OCP\IDBConnection::class),
|
||||
$container->query('ServerContainer')->getSecureRandom()
|
||||
$container->query(IServerContainer::class)->getSecureRandom()
|
||||
);
|
||||
|
||||
$requestMock = $this->getMockBuilder('OCP\IRequest')->getMock();
|
||||
$sessionMock = $this->getMockBuilder('OCP\ISession')->getMock();
|
||||
|
||||
$this->config = $container->query('ServerContainer')->getConfig();
|
||||
$this->config = $container->query(IServerContainer::class)->getConfig();
|
||||
|
||||
$this->publicPageController = new PublicPageController(
|
||||
$appName,
|
||||
$requestMock,
|
||||
$sessionMock,
|
||||
$this->config,
|
||||
$container->query('Logger'),
|
||||
$container->query(\OCP\ILogger::class),
|
||||
$this->favoriteShareMapper
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace OCA\Maps\Controller;
|
|||
|
||||
use \OCA\Maps\AppInfo\Application;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use \OCP\IServerContainer;
|
||||
use OCA\Maps\Service\GeophotoService;
|
||||
use OCA\Maps\Service\PhotofilesService;
|
||||
use OCA\Maps\Service\TracksService;
|
||||
|
@ -81,29 +82,29 @@ class TracksControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$this->app = new Application();
|
||||
$this->container = $this->app->getContainer();
|
||||
$c = $this->container;
|
||||
$this->config = $c->query('ServerContainer')->getConfig();
|
||||
$this->config = $c->query(IServerContainer::class)->getConfig();
|
||||
|
||||
$this->rootFolder = $c->query('ServerContainer')->getRootFolder();
|
||||
$this->rootFolder = $c->query(IServerContainer::class)->getRootFolder();
|
||||
|
||||
$this->tracksService = new TracksService(
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$this->rootFolder,
|
||||
$c->query('ServerContainer')->getShareManager(),
|
||||
$c->query('ServerContainer')->query(\OCP\IDBConnection::class)
|
||||
$c->query(IServerContainer::class)->getShareManager(),
|
||||
$c->query(IServerContainer::class)->query(\OCP\IDBConnection::class)
|
||||
);
|
||||
|
||||
$this->tracksController = new TracksController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer'),
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query('ServerContainer')->getShareManager(),
|
||||
$c->query(IServerContainer::class),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->query(IServerContainer::class)->getShareManager(),
|
||||
$c->getServer()->getAppManager(),
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(TracksService::class),
|
||||
'test',
|
||||
);
|
||||
|
@ -111,14 +112,14 @@ class TracksControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$this->tracksController2 = new TracksController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer'),
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query('ServerContainer')->getShareManager(),
|
||||
$c->query(IServerContainer::class),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->query(IServerContainer::class)->getShareManager(),
|
||||
$c->getServer()->getAppManager(),
|
||||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager(),
|
||||
$c->query('ServerContainer')->getL10N($c->query('AppName')),
|
||||
$c->query('ServerContainer')->getLogger(),
|
||||
$c->query(IServerContainer::class)->getL10N($c->query('AppName')),
|
||||
$c->query(IServerContainer::class)->getLogger(),
|
||||
$c->query(TracksService::class),
|
||||
'test2',
|
||||
);
|
||||
|
@ -126,12 +127,12 @@ class TracksControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$this->utilsController = new UtilsController(
|
||||
$this->appName,
|
||||
$this->request,
|
||||
$c->query('ServerContainer')->getConfig(),
|
||||
$c->query(IServerContainer::class)->getConfig(),
|
||||
$c->getServer()->getAppManager(),
|
||||
'test'
|
||||
);
|
||||
|
||||
$userfolder = $this->container->query('ServerContainer')->getUserFolder('test');
|
||||
$userfolder = $this->container->query(IServerContainer::class)->getUserFolder('test');
|
||||
|
||||
// delete first
|
||||
if ($userfolder->nodeExists('testFile1.gpx')) {
|
||||
|
@ -140,7 +141,7 @@ class TracksControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
$file->delete();
|
||||
}
|
||||
// delete db
|
||||
$qb = $c->query('ServerContainer')->query(\OCP\IDBConnection::class)->getQueryBuilder();
|
||||
$qb = $c->query(IServerContainer::class)->query(\OCP\IDBConnection::class)->getQueryBuilder();
|
||||
$qb->delete('maps_tracks')
|
||||
->where(
|
||||
$qb->expr()->eq('user_id', $qb->createNamedParameter('test', IQueryBuilder::PARAM_STR))
|
||||
|
@ -166,14 +167,14 @@ class TracksControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
// in case there was a failure and something was not deleted
|
||||
$c = $this->app->getContainer();
|
||||
|
||||
$userfolder = $this->container->query('ServerContainer')->getUserFolder('test');
|
||||
$userfolder = $this->container->query(IServerContainer::class)->getUserFolder('test');
|
||||
// delete files
|
||||
if ($userfolder->nodeExists('testFile1.gpx')) {
|
||||
$file = $userfolder->get('testFile1.gpx');
|
||||
$file->delete();
|
||||
}
|
||||
// delete db
|
||||
$qb = $c->query('ServerContainer')->query(\OCP\IDBConnection::class)->getQueryBuilder();
|
||||
$qb = $c->query(IServerContainer::class)->query(\OCP\IDBConnection::class)->getQueryBuilder();
|
||||
$qb->delete('maps_tracks')
|
||||
->where(
|
||||
$qb->expr()->eq('user_id', $qb->createNamedParameter('test', IQueryBuilder::PARAM_STR))
|
||||
|
@ -185,7 +186,7 @@ class TracksControllerTest extends \PHPUnit\Framework\TestCase {
|
|||
public function testAddGetTracks() {
|
||||
$c = $this->app->getContainer();
|
||||
|
||||
$userfolder = $this->container->query('ServerContainer')->getUserFolder('test');
|
||||
$userfolder = $this->container->query(IServerContainer::class)->getUserFolder('test');
|
||||
|
||||
$filename = 'tests/test_files/testFile1.gpx';
|
||||
$content1 = file_get_contents($filename);
|
||||
|
|
Загрузка…
Ссылка в новой задаче