2015-06-11 04:47:51 -04:00
< ? php
/**
2024-05-10 09:09:14 -04:00
* SPDX - FileCopyrightText : 2016 - 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX - FileCopyrightText : 2016 ownCloud , Inc .
* SPDX - License - Identifier : AGPL - 3.0 - only
2015-06-11 04:47:51 -04:00
*/
namespace Test ;
2020-04-09 05:48:10 -04:00
2016-10-31 06:07:54 -04:00
use OC\App\AppStore\Fetcher\AppFetcher ;
2023-08-29 18:30:52 -04:00
use OCP\Comments\ICommentsManager ;
2015-06-11 04:47:51 -04:00
2015-11-20 05:27:11 -05:00
/**
* Class Server
*
* @ group DB
*
* @ package Test
*/
2016-05-20 09:38:20 -04:00
class ServerTest extends \Test\TestCase {
2015-06-11 04:47:51 -04:00
/** @var \OC\Server */
protected $server ;
2019-11-27 09:27:18 -05:00
protected function setUp () : void {
2015-06-11 04:47:51 -04:00
parent :: setUp ();
2015-12-18 05:24:15 -05:00
$config = new \OC\Config ( \OC :: $configDir );
$this -> server = new \OC\Server ( '' , $config );
2015-06-11 04:47:51 -04:00
}
public function dataTestQuery () {
return [
2024-09-17 11:48:01 -04:00
[ '\OCP\Activity\IManager' , '\OC\Activity\Manager' ],
[ '\OCP\IConfig' , '\OC\AllConfig' ],
[ '\OCP\IAppConfig' , '\OC\AppConfig' ],
[ AppFetcher :: class , AppFetcher :: class ],
[ '\OCP\App\IAppManager' , '\OC\App\AppManager' ],
[ '\OCP\Command\IBus' , '\OC\Command\AsyncBus' ],
[ '\OCP\IAvatarManager' , '\OC\Avatar\AvatarManager' ],
2015-06-11 04:47:51 -04:00
];
}
/**
* @ dataProvider dataTestQuery
*
* @ param string $serviceName
* @ param string $instanceOf
*/
2024-09-15 16:32:31 -04:00
public function testQuery ( $serviceName , $instanceOf ) : void {
2015-06-11 05:29:45 -04:00
$this -> assertInstanceOf ( $instanceOf , $this -> server -> query ( $serviceName ), 'Service "' . $serviceName . '"" did not return the right class' );
}
2024-09-15 16:32:31 -04:00
public function testGetCertificateManager () : void {
2020-07-05 08:31:19 -04:00
$this -> assertInstanceOf ( '\OC\Security\CertificateManager' , $this -> server -> getCertificateManager (), 'service returned by "getCertificateManager" did not return the right class' );
$this -> assertInstanceOf ( '\OCP\ICertificateManager' , $this -> server -> getCertificateManager (), 'service returned by "getCertificateManager" did not return the right class' );
2015-06-11 05:29:45 -04:00
}
2024-09-15 16:32:31 -04:00
public function testOverwriteDefaultCommentsManager () : void {
2015-12-03 15:53:58 -05:00
$config = $this -> server -> getConfig ();
$defaultManagerFactory = $config -> getSystemValue ( 'comments.managerFactory' , '\OC\Comments\ManagerFactory' );
$config -> setSystemValue ( 'comments.managerFactory' , '\Test\Comments\FakeFactory' );
2023-08-29 18:30:52 -04:00
$manager = $this -> server -> get ( ICommentsManager :: class );
2015-12-03 15:53:58 -05:00
$this -> assertInstanceOf ( '\OCP\Comments\ICommentsManager' , $manager );
$config -> setSystemValue ( 'comments.managerFactory' , $defaultManagerFactory );
}
2015-06-11 04:47:51 -04:00
}