diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-02-27 10:47:57 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2019-03-26 14:56:24 +0100 |
commit | 31fb0896a0881c34fa4d3989248e42d3bb806ab5 (patch) | |
tree | 12d6e63e90fed17b950fd5d61943a7bb23c49f28 /tests | |
parent | bca4a9ecbba4b544a7ad40df3df76272553f5a6f (diff) | |
download | nextcloud-server-31fb0896a0881c34fa4d3989248e42d3bb806ab5.tar.gz nextcloud-server-31fb0896a0881c34fa4d3989248e42d3bb806ab5.zip |
Add setup check for missing UTF8MB4 on mysql
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Settings/Controller/CheckSetupControllerTest.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php index 01d2178fd7f..8a491d0d047 100644 --- a/tests/Settings/Controller/CheckSetupControllerTest.php +++ b/tests/Settings/Controller/CheckSetupControllerTest.php @@ -160,6 +160,7 @@ class CheckSetupControllerTest extends TestCase { 'getAppDirsWithDifferentOwner', 'hasRecommendedPHPModules', 'hasBigIntConversionPendingColumns', + 'isMysqlUsedWithoutUTF8MB4', ])->getMock(); } @@ -499,6 +500,11 @@ class CheckSetupControllerTest extends TestCase { ->method('hasBigIntConversionPendingColumns') ->willReturn([]); + $this->checkSetupController + ->expects($this->once()) + ->method('isMysqlUsedWithoutUTF8MB4') + ->willReturn(false); + $expected = new DataResponse( [ 'isGetenvServerWorking' => true, @@ -543,6 +549,7 @@ class CheckSetupControllerTest extends TestCase { 'appDirsWithDifferentOwner' => [], 'recommendedPHPModules' => [], 'pendingBigIntConversionColumns' => [], + 'isMysqlUsedWithoutUTF8MB4' => false, ] ); $this->assertEquals($expected, $this->checkSetupController->check()); @@ -1324,4 +1331,53 @@ Array ); $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles()); } + + public function dataForIsMysqlUsedWithoutUTF8MB4() { + return [ + ['sqlite', false, false], + ['sqlite', true, false], + ['postgres', false, false], + ['postgres', true, false], + ['oci', false, false], + ['oci', true, false], + ['mysql', false, true], + ['mysql', true, false], + ]; + } + + /** + * @dataProvider dataForIsMysqlUsedWithoutUTF8MB4 + */ + public function testIsMysqlUsedWithoutUTF8MB4(string $db, bool $useUTF8MB4, bool $expected) { + $this->config->method('getSystemValue') + ->will($this->returnCallback(function($key, $default) use ($db, $useUTF8MB4) { + if ($key === 'dbtype') { + return $db; + } + if ($key === 'mysql.utf8mb4') { + return $useUTF8MB4; + } + return $default; + })); + + $checkSetupController = new CheckSetupController( + 'settings', + $this->request, + $this->config, + $this->clientService, + $this->urlGenerator, + $this->util, + $this->l10n, + $this->checker, + $this->logger, + $this->dispatcher, + $this->db, + $this->lockingProvider, + $this->dateTimeFormatter, + $this->memoryInfo, + $this->secureRandom + ); + + $this->assertSame($expected, $this->invokePrivate($checkSetupController, 'isMysqlUsedWithoutUTF8MB4')); + } } |