Skip to content

Commit

Permalink
Fix depreccated getMock in Core/Command tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rullzer committed Sep 1, 2016
1 parent 4a5cd74 commit 74fdaab
Show file tree
Hide file tree
Showing 22 changed files with 167 additions and 90 deletions.
14 changes: 8 additions & 6 deletions tests/Core/Command/Config/App/DeleteConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@


use OC\Core\Command\Config\App\DeleteConfig;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class DeleteConfigTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject */
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
protected $config;

/** @var \PHPUnit_Framework_MockObject_MockObject */
Expand All @@ -40,14 +43,13 @@ class DeleteConfigTest extends TestCase {
protected function setUp() {
parent::setUp();

$config = $this->config = $this->getMockBuilder('OCP\IConfig')
$this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

/** @var \OCP\IConfig $config */
$this->command = new DeleteConfig($config);
$this->command = new DeleteConfig($this->config);
}


Expand Down
9 changes: 6 additions & 3 deletions tests/Core/Command/Config/App/GetConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@


use OC\Core\Command\Config\App\GetConfig;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class GetConfigTest extends TestCase {
Expand All @@ -40,11 +43,11 @@ class GetConfigTest extends TestCase {
protected function setUp() {
parent::setUp();

$config = $this->config = $this->getMockBuilder('OCP\IConfig')
$config = $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

/** @var \OCP\IConfig $config */
$this->command = new GetConfig($config);
Expand Down
9 changes: 6 additions & 3 deletions tests/Core/Command/Config/App/SetConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@


use OC\Core\Command\Config\App\SetConfig;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class SetConfigTest extends TestCase {
Expand All @@ -40,11 +43,11 @@ class SetConfigTest extends TestCase {
protected function setUp() {
parent::setUp();

$config = $this->config = $this->getMockBuilder('OCP\IConfig')
$config = $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

/** @var \OCP\IConfig $config */
$this->command = new SetConfig($config);
Expand Down
9 changes: 6 additions & 3 deletions tests/Core/Command/Config/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@


use OC\Core\Command\Config\Import;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class ImportTest extends TestCase {
Expand All @@ -40,11 +43,11 @@ class ImportTest extends TestCase {
protected function setUp() {
parent::setUp();

$config = $this->config = $this->getMockBuilder('OCP\IConfig')
$config = $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

/** @var \OCP\IConfig $config */
$this->command = new Import($config);
Expand Down
12 changes: 8 additions & 4 deletions tests/Core/Command/Config/ListConfigsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@


use OC\Core\Command\Config\ListConfigs;
use OC\SystemConfig;
use OCP\IAppConfig;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class ListConfigsTest extends TestCase {
Expand All @@ -43,14 +47,14 @@ class ListConfigsTest extends TestCase {
protected function setUp() {
parent::setUp();

$systemConfig = $this->systemConfig = $this->getMockBuilder('OC\SystemConfig')
$systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class)
->disableOriginalConstructor()
->getMock();
$appConfig = $this->appConfig = $this->getMockBuilder('OCP\IAppConfig')
$appConfig = $this->appConfig = $this->getMockBuilder(IAppConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

/** @var \OC\SystemConfig $systemConfig */
/** @var \OCP\IAppConfig $appConfig */
Expand Down
9 changes: 6 additions & 3 deletions tests/Core/Command/Config/System/DeleteConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@


use OC\Core\Command\Config\System\DeleteConfig;
use OC\SystemConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class DeleteConfigTest extends TestCase {
Expand All @@ -40,11 +43,11 @@ class DeleteConfigTest extends TestCase {
protected function setUp() {
parent::setUp();

$systemConfig = $this->systemConfig = $this->getMockBuilder('OC\SystemConfig')
$systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

/** @var \OC\SystemConfig $systemConfig */
$this->command = new DeleteConfig($systemConfig);
Expand Down
9 changes: 6 additions & 3 deletions tests/Core/Command/Config/System/GetConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@


use OC\Core\Command\Config\System\GetConfig;
use OC\SystemConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class GetConfigTest extends TestCase {
Expand All @@ -40,11 +43,11 @@ class GetConfigTest extends TestCase {
protected function setUp() {
parent::setUp();

$systemConfig = $this->systemConfig = $this->getMockBuilder('OC\SystemConfig')
$systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

/** @var \OC\SystemConfig $systemConfig */
$this->command = new GetConfig($systemConfig);
Expand Down
9 changes: 6 additions & 3 deletions tests/Core/Command/Config/System/SetConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@


use OC\Core\Command\Config\System\SetConfig;
use OC\SystemConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class SetConfigTest extends TestCase {
Expand All @@ -40,11 +43,11 @@ class SetConfigTest extends TestCase {
protected function setUp() {
parent::setUp();

$systemConfig = $this->systemConfig = $this->getMockBuilder('OC\SystemConfig')
$systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

/** @var \OC\SystemConfig $systemConfig */
$this->command = new SetConfig($systemConfig);
Expand Down
18 changes: 10 additions & 8 deletions tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
use OC\Files\View;
use OCP\IConfig;
use OCP\IUserManager;
use OCP\UserInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -65,16 +67,16 @@ class ChangeKeyStorageRootTest extends TestCase {
public function setUp() {
parent::setUp();

$this->view = $this->getMock('\OC\Files\View');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->config = $this->getMock('\OCP\IConfig');
$this->view = $this->getMockBuilder(View::class)->getMock();
$this->userManager = $this->getMockBuilder(IUserManager::class)->getMock();
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
$this->util = $this->getMockBuilder('OC\Encryption\Util')->disableOriginalConstructor()->getMock();
$this->questionHelper = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper');
$this->inputInterface = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->outputInterface = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->userInterface = $this->getMock('\OCP\UserInterface');
$this->questionHelper = $this->getMockBuilder(QuestionHelper::class)->getMock();
$this->inputInterface = $this->getMockBuilder(InputInterface::class)->getMock();
$this->outputInterface = $this->getMockBuilder(OutputInterface::class)->getMock();
$this->userInterface = $this->getMockBuilder(UserInterface::class)->getMock();

$outputFormatterInterface = $this->getMock('Symfony\Component\Console\Formatter\OutputFormatterInterface');
$outputFormatterInterface = $this->getMockBuilder(OutputFormatterInterface::class)->getMock();
$this->outputInterface->expects($this->any())->method('getFormatter')
->willReturn($outputFormatterInterface);

Expand Down
20 changes: 13 additions & 7 deletions tests/Core/Command/Encryption/DecryptAllTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@


use OC\Core\Command\Encryption\DecryptAll;
use OCP\App\IAppManager;
use OCP\Encryption\IManager;
use OCP\IConfig;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class DecryptAllTest extends TestCase {
Expand Down Expand Up @@ -52,22 +58,22 @@ class DecryptAllTest extends TestCase {
public function setUp() {
parent::setUp();

$this->config = $this->getMockBuilder('OCP\IConfig')
$this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->encryptionManager = $this->getMockBuilder('OCP\Encryption\IManager')
$this->encryptionManager = $this->getMockBuilder(IManager::class)
->disableOriginalConstructor()
->getMock();
$this->appManager = $this->getMockBuilder('OCP\App\IAppManager')
$this->appManager = $this->getMockBuilder(IAppManager::class)
->disableOriginalConstructor()
->getMock();
$this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
$this->questionHelper = $this->getMockBuilder(QuestionHelper::class)
->disableOriginalConstructor()
->getMock();
$this->decryptAll = $this->getMockBuilder('OC\Encryption\DecryptAll')
$this->decryptAll = $this->getMockBuilder(\OC\Encryption\DecryptAll::class)
->disableOriginalConstructor()->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

$this->config->expects($this->any())
->method('getSystemValue')
Expand Down
9 changes: 6 additions & 3 deletions tests/Core/Command/Encryption/DisableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@


use OC\Core\Command\Encryption\Disable;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class DisableTest extends TestCase {
Expand All @@ -39,11 +42,11 @@ class DisableTest extends TestCase {
protected function setUp() {
parent::setUp();

$config = $this->config = $this->getMockBuilder('OCP\IConfig')
$config = $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

/** @var \OCP\IConfig $config */
$this->command = new Disable($config);
Expand Down
12 changes: 8 additions & 4 deletions tests/Core/Command/Encryption/EnableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@


use OC\Core\Command\Encryption\Enable;
use OCP\Encryption\IManager;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class EnableTest extends TestCase {
Expand All @@ -41,14 +45,14 @@ class EnableTest extends TestCase {
protected function setUp() {
parent::setUp();

$config = $this->config = $this->getMockBuilder('OCP\IConfig')
$config = $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$manager = $this->manager = $this->getMockBuilder('OCP\Encryption\IManager')
$manager = $this->manager = $this->getMockBuilder(IManager::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

/** @var \OCP\IConfig $config */
/** @var \OCP\Encryption\IManager $manager */
Expand Down
21 changes: 14 additions & 7 deletions tests/Core/Command/Encryption/EncryptAllTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@


use OC\Core\Command\Encryption\EncryptAll;
use OCP\App\IAppManager;
use OCP\Encryption\IEncryptionModule;
use OCP\Encryption\IManager;
use OCP\IConfig;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;

class EncryptAllTest extends TestCase {
Expand Down Expand Up @@ -55,23 +62,23 @@ class EncryptAllTest extends TestCase {
protected function setUp() {
parent::setUp();

$this->config = $this->getMockBuilder('OCP\IConfig')
$this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->encryptionManager = $this->getMockBuilder('OCP\Encryption\IManager')
$this->encryptionManager = $this->getMockBuilder(IManager::class)
->disableOriginalConstructor()
->getMock();
$this->appManager = $this->getMockBuilder('OCP\App\IAppManager')
$this->appManager = $this->getMockBuilder(IAppManager::class)
->disableOriginalConstructor()
->getMock();
$this->encryptionModule = $this->getMockBuilder('\OCP\Encryption\IEncryptionModule')
$this->encryptionModule = $this->getMockBuilder(IEncryptionModule::class)
->disableOriginalConstructor()
->getMock();
$this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
$this->questionHelper = $this->getMockBuilder(QuestionHelper::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();

}

Expand Down
Loading

0 comments on commit 74fdaab

Please sign in to comment.