summaryrefslogtreecommitdiffstats
path: root/tests/lib/Repair/NC12/UpdateLanguageCodesTest.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2017-03-03 13:51:32 +0100
committerGitHub <noreply@github.com>2017-03-03 13:51:32 +0100
commit8e27b8197d8b869e8fb0d55105f9bfc2f854b381 (patch)
tree782d563a2f1e5c682da34c5de69ff43cb8ce5eb7 /tests/lib/Repair/NC12/UpdateLanguageCodesTest.php
parentf8c459f1a4ab918193d5f65c0ad1732875426d8b (diff)
parent0beb78517fa06a27509161f5b77d1bf8fec91054 (diff)
downloadnextcloud-server-8e27b8197d8b869e8fb0d55105f9bfc2f854b381.tar.gz
nextcloud-server-8e27b8197d8b869e8fb0d55105f9bfc2f854b381.zip
Merge pull request #3684 from nextcloud/run-lang-update-only-once
Execute UpdateLanguageCode only once
Diffstat (limited to 'tests/lib/Repair/NC12/UpdateLanguageCodesTest.php')
-rw-r--r--tests/lib/Repair/NC12/UpdateLanguageCodesTest.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/lib/Repair/NC12/UpdateLanguageCodesTest.php b/tests/lib/Repair/NC12/UpdateLanguageCodesTest.php
index 95ccd0935a1..4379d1ba589 100644
--- a/tests/lib/Repair/NC12/UpdateLanguageCodesTest.php
+++ b/tests/lib/Repair/NC12/UpdateLanguageCodesTest.php
@@ -24,6 +24,7 @@
namespace Test\Repair\NC12;
use OC\Repair\NC12\UpdateLanguageCodes;
+use OCP\IConfig;
use OCP\Migration\IOutput;
use Test\TestCase;
@@ -38,10 +39,14 @@ class UpdateLanguageCodesTest extends TestCase {
/** @var \OCP\IDBConnection */
protected $connection;
+ /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
+ private $config;
+
protected function setUp() {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
+ $this->config = $this->createMock(IConfig::class);
}
public function testRun() {
@@ -112,8 +117,13 @@ class UpdateLanguageCodesTest extends TestCase {
->method('info')
->with('Changed 2 setting(s) from "th_TH" to "th" in preferences table.');
+ $this->config->expects($this->once())
+ ->method('getSystemValue')
+ ->with('version', '0.0.0')
+ ->willReturn('12.0.0.13');
+
// run repair step
- $repair = new UpdateLanguageCodes($this->connection);
+ $repair = new UpdateLanguageCodes($this->connection, $this->config);
$repair->run($outputMock);
// check if test data is correctly modified in DB
@@ -147,4 +157,20 @@ class UpdateLanguageCodesTest extends TestCase {
}
}
+ public function testSecondRun() {
+ /** @var IOutput|\PHPUnit_Framework_MockObject_MockObject $outputMock */
+ $outputMock = $this->createMock(IOutput::class);
+ $outputMock->expects($this->never())
+ ->method('info');
+
+ $this->config->expects($this->once())
+ ->method('getSystemValue')
+ ->with('version', '0.0.0')
+ ->willReturn('12.0.0.14');
+
+ // run repair step
+ $repair = new UpdateLanguageCodes($this->connection, $this->config);
+ $repair->run($outputMock);
+ }
+
}