diff options
Diffstat (limited to 'tests/core/command/maintenance')
-rw-r--r-- | tests/core/command/maintenance/mimetype/updatedbtest.php | 184 | ||||
-rw-r--r-- | tests/core/command/maintenance/singleusertest.php | 129 |
2 files changed, 0 insertions, 313 deletions
diff --git a/tests/core/command/maintenance/mimetype/updatedbtest.php b/tests/core/command/maintenance/mimetype/updatedbtest.php deleted file mode 100644 index 217301102c5..00000000000 --- a/tests/core/command/maintenance/mimetype/updatedbtest.php +++ /dev/null @@ -1,184 +0,0 @@ -<?php -/** - * @author Robin McCorkell <rmccorkell@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace Tests\Core\Command\Maintenance\Mimetype; - -use OC\Core\Command\Maintenance\Mimetype\UpdateDB; -use Test\TestCase; -use OCP\Files\IMimeTypeDetector; -use OCP\Files\IMimeTypeLoader; - -class UpdateDBTest extends TestCase { - /** @var IMimeTypeDetector */ - protected $detector; - /** @var IMimeTypeLoader */ - protected $loader; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $consoleInput; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $consoleOutput; - - /** @var \Symfony\Component\Console\Command\Command */ - protected $command; - - protected function setUp() { - parent::setUp(); - - $this->detector = $this->getMockBuilder('OC\Files\Type\Detection') - ->disableOriginalConstructor() - ->getMock(); - $this->loader = $this->getMockBuilder('OC\Files\Type\Loader') - ->disableOriginalConstructor() - ->getMock(); - - $this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - - $this->command = new UpdateDB($this->detector, $this->loader); - } - - public function testNoop() { - $this->consoleInput->method('getOption') - ->with('repair-filecache') - ->willReturn(false); - - $this->detector->expects($this->once()) - ->method('getAllMappings') - ->willReturn([ - 'ext' => ['testing/existingmimetype'] - ]); - $this->loader->expects($this->once()) - ->method('exists') - ->with('testing/existingmimetype') - ->willReturn(true); - - $this->loader->expects($this->never()) - ->method('updateFilecache'); - - $this->consoleOutput->expects($this->at(0)) - ->method('writeln') - ->with('Added 0 new mimetypes'); - $this->consoleOutput->expects($this->at(1)) - ->method('writeln') - ->with('Updated 0 filecache rows'); - - self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); - } - - public function testAddMimetype() { - $this->consoleInput->method('getOption') - ->with('repair-filecache') - ->willReturn(false); - - $this->detector->expects($this->once()) - ->method('getAllMappings') - ->willReturn([ - 'ext' => ['testing/existingmimetype'], - 'new' => ['testing/newmimetype'] - ]); - $this->loader->expects($this->exactly(2)) - ->method('exists') - ->will($this->returnValueMap([ - ['testing/existingmimetype', true], - ['testing/newmimetype', false], - ])); - $this->loader->expects($this->exactly(2)) - ->method('getId') - ->will($this->returnValueMap([ - ['testing/existingmimetype', 1], - ['testing/newmimetype', 2], - ])); - - $this->loader->expects($this->once()) - ->method('updateFilecache') - ->with('new', 2) - ->willReturn(3); - - $this->consoleOutput->expects($this->at(0)) - ->method('writeln') - ->with('Added mimetype "testing/newmimetype" to database'); - $this->consoleOutput->expects($this->at(1)) - ->method('writeln') - ->with('Updated 3 filecache rows for mimetype "testing/newmimetype"'); - - $this->consoleOutput->expects($this->at(2)) - ->method('writeln') - ->with('Added 1 new mimetypes'); - $this->consoleOutput->expects($this->at(3)) - ->method('writeln') - ->with('Updated 3 filecache rows'); - - self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); - } - - public function testSkipComments() { - $this->detector->expects($this->once()) - ->method('getAllMappings') - ->willReturn([ - '_comment' => 'some comment in the JSON' - ]); - $this->loader->expects($this->never()) - ->method('exists'); - - self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); - } - - public function testRepairFilecache() { - $this->consoleInput->method('getOption') - ->with('repair-filecache') - ->willReturn(true); - - $this->detector->expects($this->once()) - ->method('getAllMappings') - ->willReturn([ - 'ext' => ['testing/existingmimetype'], - ]); - $this->loader->expects($this->exactly(1)) - ->method('exists') - ->will($this->returnValueMap([ - ['testing/existingmimetype', true], - ])); - $this->loader->expects($this->exactly(1)) - ->method('getId') - ->will($this->returnValueMap([ - ['testing/existingmimetype', 1], - ])); - - $this->loader->expects($this->once()) - ->method('updateFilecache') - ->with('ext', 1) - ->willReturn(3); - - $this->consoleOutput->expects($this->at(0)) - ->method('writeln') - ->with('Updated 3 filecache rows for mimetype "testing/existingmimetype"'); - - $this->consoleOutput->expects($this->at(1)) - ->method('writeln') - ->with('Added 0 new mimetypes'); - $this->consoleOutput->expects($this->at(2)) - ->method('writeln') - ->with('Updated 3 filecache rows'); - - self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); - } -} diff --git a/tests/core/command/maintenance/singleusertest.php b/tests/core/command/maintenance/singleusertest.php deleted file mode 100644 index 6629f39564f..00000000000 --- a/tests/core/command/maintenance/singleusertest.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php -/** - * @author Morris Jobke <hey@morrisjobke.de> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace Tests\Core\Command\Maintenance; - - -use OC\Core\Command\Maintenance\SingleUser; -use Test\TestCase; - -class SingleUserTest extends TestCase { - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $config; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $consoleInput; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $consoleOutput; - - /** @var \Symfony\Component\Console\Command\Command */ - protected $command; - - protected function setUp() { - parent::setUp(); - - $config = $this->config = $this->getMockBuilder('OCP\IConfig') - ->disableOriginalConstructor() - ->getMock(); - $this->consoleInput = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $this->consoleOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - - /** @var \OCP\IConfig $config */ - $this->command = new SingleUser($config); - } - - public function testChangeStateToOn() { - - $this->consoleInput->expects($this->once()) - ->method('getOption') - ->with('on') - ->willReturn(true); - - $this->config->expects($this->once()) - ->method('setSystemValue') - ->with('singleuser', true); - - $this->consoleOutput->expects($this->once()) - ->method('writeln') - ->with('Single user mode enabled'); - - self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); - } - - public function testChangeStateToOff() { - - $this->consoleInput->expects($this->at(0)) - ->method('getOption') - ->with('on') - ->willReturn(false); - - $this->consoleInput->expects($this->at(1)) - ->method('getOption') - ->with('off') - ->willReturn(true); - - $this->config->expects($this->once()) - ->method('setSystemValue') - ->with('singleuser', false); - - $this->consoleOutput->expects($this->once()) - ->method('writeln') - ->with('Single user mode disabled'); - - self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); - } - - public function stateData() { - return [ - [ true, 'Single user mode is currently enabled' ], - [ false, 'Single user mode is currently disabled' ], - ]; - } - - /** - * @dataProvider stateData - * - * @param $state - * @param $expectedOutput - */ - public function testState($state, $expectedOutput) { - - $this->consoleInput->expects($this->at(0)) - ->method('getOption') - ->with('on') - ->willReturn(false); - - $this->consoleInput->expects($this->at(1)) - ->method('getOption') - ->with('off') - ->willReturn(false); - - $this->config->expects($this->once()) - ->method('getSystemValue') - ->with('singleuser', false) - ->willReturn($state); - - $this->consoleOutput->expects($this->once()) - ->method('writeln') - ->with($expectedOutput); - - self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); - } -} |