]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use MockBuilder instead of createMock
authorLukas Reschke <lukas@statuscode.ch>
Mon, 15 Aug 2016 14:43:22 +0000 (16:43 +0200)
committerLukas Reschke <lukas@statuscode.ch>
Tue, 16 Aug 2016 19:10:47 +0000 (21:10 +0200)
CI uses an older PHPUnit

20 files changed:
apps/encryption/tests/Settings/AdminTest.php
apps/federatedfilesharing/tests/Settings/AdminTest.php
apps/federation/tests/Settings/AdminTest.php
apps/files/tests/Settings/AdminTest.php
apps/files_external/tests/Settings/AdminTest.php
apps/files_external/tests/Settings/SectionTest.php
apps/theming/tests/Settings/AdminTest.php
apps/theming/tests/Settings/SectionTest.php
apps/updatenotification/tests/Controller/AdminControllerTest.php
apps/user_ldap/tests/Settings/AdminTest.php
apps/user_ldap/tests/Settings/SectionTest.php
tests/Settings/Controller/AdminSettingsControllerTest.php
tests/Settings/Controller/CheckSetupControllerTest.php
tests/lib/Settings/Admin/AdditionalTest.php
tests/lib/Settings/Admin/EncryptionTest.php
tests/lib/Settings/Admin/LoggingTest.php
tests/lib/Settings/Admin/ServerTest.php
tests/lib/Settings/Admin/SharingTest.php
tests/lib/Settings/Admin/TipsTricksTest.php
tests/lib/Settings/ManagerTest.php

index 5b0b577e058178476803725ee23e79ad84bdbbd9..93896585dad5c2ebc0606f6713c0d30c160a2119 100644 (file)
@@ -52,12 +52,12 @@ class AdminTest extends TestCase {
        public function setUp() {
                parent::setUp();
 
-               $this->l = $this->createMock('\OCP\IL10N');
-               $this->logger = $this->createMock('\OCP\ILogger');
-               $this->userSession = $this->createMock('\OCP\IUserSession');
-               $this->config = $this->createMock('\OCP\IConfig');
-               $this->userManager = $this->createMock('\OCP\IUserManager');
-               $this->session = $this->createMock('\OCP\ISession');
+               $this->l = $this->getMockBuilder('\OCP\IL10N')->getMock();
+               $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
+               $this->userSession = $this->getMockBuilder('\OCP\IUserSession')->getMock();
+               $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+               $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock();
+               $this->session = $this->getMockBuilder('\OCP\ISession')->getMock();
 
                $this->admin = new Admin(
                        $this->l,
index e082e7bff2317c4949cd6d80b4ed3f872e12fbd0..60fadca7b568aad13acf40d0edab1153fd97d193 100644 (file)
@@ -35,7 +35,7 @@ class AdminTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->federatedShareProvider = $this->createMock('\OCA\FederatedFileSharing\FederatedShareProvider');
+               $this->federatedShareProvider = $this->getMockBuilder('\OCA\FederatedFileSharing\FederatedShareProvider')->disableOriginalConstructor()->getMock();
                $this->admin = new Admin(
                        $this->federatedShareProvider
                );
index 78cb7201dcdef0a4f40973bf543b22a1b4ba5df0..758bda6bc5e13807891ba1a0bf3a1ce65387f334 100644 (file)
@@ -36,7 +36,7 @@ class AdminTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->trustedServers = $this->createMock('\OCA\Federation\TrustedServers');
+               $this->trustedServers = $this->getMockBuilder('\OCA\Federation\TrustedServers')->disableOriginalConstructor()->getMock();
                $this->admin = new Admin(
                        $this->trustedServers
                );
index c536377af939e54d0193fd2c5d71ee704cf8adbe..1ab8a992879c1f2b16e45d99e54ff0c9c4007d6b 100644 (file)
@@ -40,8 +40,8 @@ class AdminTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->iniGetWrapper = $this->createMock('\bantu\IniGetWrapper\IniGetWrapper');
-               $this->request = $this->createMock('\OCP\IRequest');
+               $this->iniGetWrapper = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper')->disableOriginalConstructor()->getMock();
+               $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
                $this->admin = new Admin(
                        $this->iniGetWrapper,
                        $this->request
index 1918e800c9bdacfc780ce0dcdb999f7b0b559af5..fdf9680e7c3788f08f15c2709cc9faff50e6d4b0 100644 (file)
@@ -45,10 +45,10 @@ class AdminTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->encryptionManager = $this->createMock('\OCP\Encryption\IManager');
-               $this->globalStoragesService = $this->createMock('\OCA\Files_External\Service\GlobalStoragesService');
-               $this->backendService = $this->createMock('\OCA\Files_External\Service\BackendService');
-               $this->globalAuth = $this->createMock('\OCA\Files_External\Lib\Auth\Password\GlobalAuth');
+               $this->encryptionManager = $this->getMockBuilder('\OCP\Encryption\IManager')->getMock();
+               $this->globalStoragesService = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService')->disableOriginalConstructor()->getMock();
+               $this->backendService = $this->getMockBuilder('\OCA\Files_External\Service\BackendService')->disableOriginalConstructor()->getMock();
+               $this->globalAuth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Password\GlobalAuth')->disableOriginalConstructor()->getMock();
 
                $this->admin = new Admin(
                        $this->encryptionManager,
index 9ab456fe30799c3dfea02c84eb0a46a1372364f7..b5dfb28b382d59c0a9eb04c4f7fa9415c3583320 100644 (file)
@@ -35,7 +35,7 @@ class SectionTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->l = $this->createMock('\OCP\IL10N');
+               $this->l = $this->getMockBuilder('\OCP\IL10N')->disableOriginalConstructor()->getMock();
 
                $this->section = new Section(
                        $this->l
index ff42c6997a6592b7848da9480d54eee413e57e36..18c2064e8cec441fe50017fe059e4362b231c93c 100644 (file)
@@ -45,10 +45,10 @@ class AdminTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->config = $this->createMock('\OCP\IConfig');
-               $this->l10n = $this->createMock('\OCP\IL10N');
-               $this->themingDefaults = $this->createMock('\OCA\Theming\ThemingDefaults');
-               $this->urlGenerator = $this->createMock('\OCP\IURLGenerator');
+               $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+               $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
+               $this->themingDefaults = $this->getMockBuilder('\OCA\Theming\ThemingDefaults')->disableOriginalConstructor()->getMock();
+               $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock();
 
                $this->admin = new Admin(
                        $this->config,
index e8a9a217f1ff923f8c0c33f45955935ea1fa39c9..3a3a4375236b2c7110984272cd8567b5965eb8d2 100644 (file)
@@ -35,7 +35,7 @@ class SectionTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->l = $this->createMock('\OCP\IL10N');
+               $this->l = $this->getMockBuilder('\OCP\IL10N')->getMock();
 
                $this->section = new Section(
                        $this->l
index a4398715885dcf790bd31d374b395b3bf103937e..cf99679e680af86f03e11b2e0d2946254d694f75 100644 (file)
@@ -59,14 +59,14 @@ class AdminControllerTest extends TestCase {
        public function setUp() {
                parent::setUp();
 
-               $this->request = $this->createMock('\\OCP\\IRequest');
-               $this->jobList = $this->createMock('\\OCP\\BackgroundJob\\IJobList');
-               $this->secureRandom = $this->createMock('\\OCP\\Security\\ISecureRandom');
-               $this->config = $this->createMock('\\OCP\\IConfig');
-               $this->timeFactory = $this->createMock('\\OCP\\AppFramework\\Utility\\ITimeFactory');
-               $this->l10n = $this->createMock('\\OCP\\IL10N');
-               $this->updateChecker = $this->createMock('\\OCA\\UpdateNotification\\UpdateChecker');
-               $this->dateTimeFormatter = $this->createMock('\\OCP\\IDateTimeFormatter');
+               $this->request = $this->getMockBuilder('\\OCP\\IRequest')->getMock();
+               $this->jobList = $this->getMockBuilder('\\OCP\\BackgroundJob\\IJobList')->getMock();
+               $this->secureRandom = $this->getMockBuilder('\\OCP\\Security\\ISecureRandom')->getMock();
+               $this->config = $this->getMockBuilder('\\OCP\\IConfig')->getMock();
+               $this->timeFactory = $this->getMockBuilder('\\OCP\\AppFramework\\Utility\\ITimeFactory')->getMock();
+               $this->l10n = $this->getMockBuilder('\\OCP\\IL10N')->getMock();
+               $this->updateChecker = $this->getMockBuilder('\\OCA\\UpdateNotification\\UpdateChecker')->disableOriginalConstructor()->getMock();
+               $this->dateTimeFormatter = $this->getMockBuilder('\\OCP\\IDateTimeFormatter')->getMock();
 
                $this->adminController = new AdminController(
                        'updatenotification',
index e92684f3ce47e0e777b75c748becab374f32cc00..4ac5a14f58b426414a75e1d796e39ec2e0d6abd0 100644 (file)
@@ -43,7 +43,7 @@ class AdminTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->l10n = $this->createMock('\OCP\IL10N');
+               $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
 
                $this->admin = new Admin(
                        $this->l10n
index b5b1f97ce3caed5812b65ee215b8e8b2c0fd2185..2d2165b8e56d237016da15b2d6bd0ace2f2bb150 100644 (file)
@@ -35,7 +35,7 @@ class SectionTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->l = $this->createMock('\OCP\IL10N');
+               $this->l = $this->getMockBuilder('\OCP\IL10N')->getMock();
 
                $this->section = new Section(
                        $this->l
index 86950c9aa9db7c192e7979aa3e1ce2cbccb7d5bd..6c93bca0d680c7cf5524f7442077c0f66425bcc7 100644 (file)
@@ -44,9 +44,9 @@ class AdminSettingsControllerTest extends TestCase {
        public function setUp() {
                parent::setUp();
 
-               $this->request = $this->createMock('\OCP\IRequest');
-               $this->navigationManager = $this->createMock('\OCP\INavigationManager');
-               $this->settingsManager = $this->createMock('\OCP\Settings\IManager');
+               $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
+               $this->navigationManager = $this->getMockBuilder('\OCP\INavigationManager')->getMock();
+               $this->settingsManager = $this->getMockBuilder('\OCP\Settings\IManager')->getMock();
 
                $this->adminSettingsController = new AdminSettingsController(
                        'settings',
@@ -65,7 +65,7 @@ class AdminSettingsControllerTest extends TestCase {
                        ->expects($this->once())
                        ->method('getAdminSettings')
                        ->with('test')
-                       ->willReturn([5 => new TipsTricks($this->createMock('\OCP\IConfig'))]);
+                       ->willReturn([5 => new TipsTricks($this->getMockBuilder('\OCP\IConfig')->getMock())]);
                $expected = new TemplateResponse('settings', 'admin/frame', ['forms' => [], 'content' => '']);
                $this->assertEquals($expected, $this->adminSettingsController->index('test'));
        }
index 5826f96eb144344b91e9e1f11ef67388f5b1dadb..74e942386b09e87b2c5da1e930797af78f169fed 100644 (file)
@@ -85,7 +85,7 @@ class CheckSetupControllerTest extends TestCase {
                        }));
                $this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
                                ->disableOriginalConstructor()->getMock();
-               $this->logger = $this->createMock('\OCP\ILogger');
+               $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
                $this->checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
                        ->setConstructorArgs([
                                'settings',
index 178d7550614bbcf631b4372f46ee33fbe6e9086a..3a99893cf7c569ee234d5b8df4929aa312e7146e 100644 (file)
@@ -36,7 +36,7 @@ class AdditionalTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->config = $this->createMock('\OCP\IConfig');
+               $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
 
                $this->admin = new Additional(
                        $this->config
index a68b40ae11b5d7fbb708dead9a2e75882357617e..f9763d85c1f63b50926bf62456570c8282cc0070 100644 (file)
@@ -39,8 +39,8 @@ class EncryptionTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->manager = $this->createMock('\OC\Encryption\Manager');
-               $this->userManager = $this->createMock('\OCP\IUserManager');
+               $this->manager = $this->getMockBuilder('\OC\Encryption\Manager')->disableOriginalConstructor()->getMock();
+               $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock();
 
                $this->admin = new Encryption(
                        $this->manager,
index 10a94f1c59c340ada9718bf183457c7eb4ac7e86..181553d3894ab543676c298943967a2b44be471c 100644 (file)
@@ -37,7 +37,7 @@ class LoggingTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->config = $this->createMock('\OCP\IConfig');
+               $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
 
                $this->admin = new Logging(
                        $this->config
index 5a4fa22920f3b5d5a802b9beba42d9240c524f1f..874422307e0735c8937ea8a1dad8bac7623bbd44 100644 (file)
@@ -46,10 +46,10 @@ class ServerTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->config = $this->createMock('\OCP\IConfig');
-               $this->dbConnection = $this->createMock('\OCP\IDBConnection');
-               $this->lockingProvider = $this->createMock('\OCP\Lock\ILockingProvider');
-               $this->l10n = $this->createMock('\OCP\IL10N');
+               $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+               $this->dbConnection = $this->getMockBuilder('\OCP\IDBConnection')->getMock();
+               $this->lockingProvider = $this->getMockBuilder('\OCP\Lock\ILockingProvider')->getMock();
+               $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
 
                $this->admin = new Server(
                        $this->dbConnection,
index 7aec187d3723c7aa72bb0285a59899fcc78c500a..261e631363a4e5f9935b0d19997d43ed16f5e597 100644 (file)
@@ -36,7 +36,7 @@ class SharingTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->config = $this->createMock('\OCP\IConfig');
+               $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
 
                $this->admin = new Sharing(
                        $this->config
index afa053e833748d08478c0fc1ff8fd62bbe8e948a..0e8857b56d0bcf6c1cf4ff97c34571c3e8b27a20 100644 (file)
@@ -36,7 +36,7 @@ class TipsTrickTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->config = $this->createMock('\OCP\IConfig');
+               $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
 
                $this->admin = new TipsTricks(
                        $this->config
index 01e226225beb89efcade4044d0198db38afed38e..cd5100eff6d6bb08f5b3ea90e2b5e92032117ef1 100644 (file)
@@ -56,13 +56,13 @@ class ManagerTest extends TestCase {
        public function setUp() {
                parent::setUp();
 
-               $this->logger = $this->createMock('\OCP\ILogger');
-               $this->dbConnection = $this->createMock('\OCP\IDBConnection');
-               $this->l10n = $this->createMock('\OCP\IL10N');
-               $this->config = $this->createMock('\OCP\IConfig');
-               $this->encryptionManager = $this->createMock('\OCP\Encryption\IManager');
-               $this->userManager = $this->createMock('\OCP\IUserManager');
-               $this->lockingProvider = $this->createMock('\OCP\Lock\ILockingProvider');
+               $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
+               $this->dbConnection = $this->getMockBuilder('\OCP\IDBConnection')->getMock();
+               $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
+               $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+               $this->encryptionManager = $this->getMockBuilder('\OCP\Encryption\IManager')->getMock();
+               $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock();
+               $this->lockingProvider = $this->getMockBuilder('\OCP\Lock\ILockingProvider')->getMock();
 
                $this->manager = new Manager(
                        $this->logger,
@@ -76,7 +76,7 @@ class ManagerTest extends TestCase {
        }
 
        public function testSetupSettings() {
-               $qb = $this->createMock('\OCP\DB\QueryBuilder\IQueryBuilder');
+               $qb = $this->getMockBuilder('\OCP\DB\QueryBuilder\IQueryBuilder')->getMock();
                $qb
                        ->expects($this->once())
                        ->method('select')
@@ -91,12 +91,12 @@ class ManagerTest extends TestCase {
                        ->method('from')
                        ->with('admin_settings')
                        ->willReturn($qb);
-               $expressionBuilder = $this->createMock('\OCP\DB\QueryBuilder\IExpressionBuilder');
+               $expressionBuilder = $this->getMockBuilder('\OCP\DB\QueryBuilder\IExpressionBuilder')->getMock();
                $qb
                        ->expects($this->once())
                        ->method('expr')
                        ->willReturn($expressionBuilder);
-               $param = $this->createMock('\OCP\DB\QueryBuilder\IParameter');
+               $param = $this->getMockBuilder('\OCP\DB\QueryBuilder\IParameter')->getMock();
                $qb
                        ->expects($this->once())
                        ->method('createNamedParameter')
@@ -112,13 +112,13 @@ class ManagerTest extends TestCase {
                        ->method('where')
                        ->with('myString')
                        ->willReturn($qb);
-               $stmt = $this->createMock('\Doctrine\DBAL\Driver\Statement');
+               $stmt = $this->getMockBuilder('\Doctrine\DBAL\Driver\Statement')->getMock();
                $qb
                        ->expects($this->once())
                        ->method('execute')
                        ->willReturn($stmt);
 
-               $qb1 = $this->createMock('\OCP\DB\QueryBuilder\IQueryBuilder');
+               $qb1 = $this->getMockBuilder('\OCP\DB\QueryBuilder\IQueryBuilder')->getMock();
                $qb1
                        ->expects($this->once())
                        ->method('insert')
@@ -135,7 +135,7 @@ class ManagerTest extends TestCase {
        }
 
        public function testGetAdminSections() {
-               $qb = $this->createMock('\OCP\DB\QueryBuilder\IQueryBuilder');
+               $qb = $this->getMockBuilder('\OCP\DB\QueryBuilder\IQueryBuilder')->getMock();
                $qb
                        ->expects($this->once())
                        ->method('select')
@@ -146,7 +146,7 @@ class ManagerTest extends TestCase {
                        ->method('from')
                        ->with('admin_sections')
                        ->willReturn($qb);
-               $stmt = $this->createMock('\Doctrine\DBAL\Driver\Statement');
+               $stmt = $this->getMockBuilder('\Doctrine\DBAL\Driver\Statement')->getMock();
                $qb
                        ->expects($this->once())
                        ->method('execute')
@@ -171,7 +171,7 @@ class ManagerTest extends TestCase {
        }
 
        public function testGetAdminSettings() {
-               $qb = $this->createMock('\OCP\DB\QueryBuilder\IQueryBuilder');
+               $qb = $this->getMockBuilder('\OCP\DB\QueryBuilder\IQueryBuilder')->getMock();
                $qb
                        ->expects($this->once())
                        ->method('select')
@@ -182,12 +182,12 @@ class ManagerTest extends TestCase {
                        ->method('from')
                        ->with('admin_settings')
                        ->willReturn($qb);
-               $expressionBuilder = $this->createMock('\OCP\DB\QueryBuilder\IExpressionBuilder');
+               $expressionBuilder = $this->getMockBuilder('\OCP\DB\QueryBuilder\IExpressionBuilder')->getMock();
                $qb
                        ->expects($this->once())
                        ->method('expr')
                        ->willReturn($expressionBuilder);
-               $param = $this->createMock('\OCP\DB\QueryBuilder\IParameter');
+               $param = $this->getMockBuilder('\OCP\DB\QueryBuilder\IParameter')->getMock();
                $qb
                        ->expects($this->once())
                        ->method('createParameter')
@@ -203,7 +203,7 @@ class ManagerTest extends TestCase {
                        ->method('where')
                        ->with('myString')
                        ->willReturn($qb);
-               $stmt = $this->createMock('\Doctrine\DBAL\Driver\Statement');
+               $stmt = $this->getMockBuilder('\Doctrine\DBAL\Driver\Statement')->getMock();
                $qb
                        ->expects($this->once())
                        ->method('execute')