namespace OC\Core;
-use OC\Core\Controller\JsController;
use OC\Security\IdentityProof\Manager;
use OCP\AppFramework\App;
use OC\Core\Controller\CssController;
$container->query(ITimeFactory::class)
);
});
- $container->registerService(JsController::class, function () use ($container) {
- return new JsController(
- $container->query('AppName'),
- $container->query(IRequest::class),
- $container->getServer()->getAppDataDir('js'),
- $container->query(ITimeFactory::class)
- );
- });
}
}
*/
namespace OC\Core\Controller;
+use OC\Files\AppData\Factory;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\NotFoundResponse;
/**
* @param string $appName
* @param IRequest $request
- * @param IAppData $appData
+ * @param Factory $appDataFactory
* @param ITimeFactory $timeFactory
*/
- public function __construct($appName, IRequest $request, IAppData $appData, ITimeFactory $timeFactory) {
+ public function __construct($appName, IRequest $request, Factory $appDataFactory, ITimeFactory $timeFactory) {
parent::__construct($appName, $request);
- $this->appData = $appData;
+ $this->appData = $appDataFactory->get('js');
$this->timeFactory = $timeFactory;
}
namespace Tests\Core\Controller;
use OC\Core\Controller\JsController;
+use OC\Files\AppData\Factory;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\NotFoundResponse;
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('js')
+ ->willReturn($this->appData);
+ /** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject $timeFactory */
$timeFactory = $this->createMock(ITimeFactory::class);
$timeFactory->method('getTime')
->willReturn(1337);
$this->controller = new JsController(
'core',
$this->request,
- $this->appData,
+ $factory,
$timeFactory
);
}