diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-02-28 22:39:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-28 22:39:35 +0100 |
commit | 48804619c99660a0c2485c658d4514a34c2501ea (patch) | |
tree | 0b2e998c1f609ef8f00c3eca3cf091cc9ea8d4e4 /tests | |
parent | fb48abc35ab9d36c6d9eef5fa0ac1fe92bba0f73 (diff) | |
parent | 6c7ccbecbf6af5037a6c7bf2046bbf4d3bf91e2f (diff) | |
download | nextcloud-server-48804619c99660a0c2485c658d4514a34c2501ea.tar.gz nextcloud-server-48804619c99660a0c2485c658d4514a34c2501ea.zip |
Merge pull request #14398 from nextcloud/feature/14394/add-setup-check-for-mysql-utf8mb4
Add setup check for missing UTF8MB4 on mysql
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 b1b451aa9e2..dd13b29697d 100644 --- a/tests/Settings/Controller/CheckSetupControllerTest.php +++ b/tests/Settings/Controller/CheckSetupControllerTest.php @@ -159,6 +159,7 @@ class CheckSetupControllerTest extends TestCase { 'getAppDirsWithDifferentOwner', 'hasRecommendedPHPModules', 'hasBigIntConversionPendingColumns', + 'isMysqlUsedWithoutUTF8MB4', ])->getMock(); } @@ -520,6 +521,11 @@ class CheckSetupControllerTest extends TestCase { ->method('hasBigIntConversionPendingColumns') ->willReturn([]); + $this->checkSetupController + ->expects($this->once()) + ->method('isMysqlUsedWithoutUTF8MB4') + ->willReturn(false); + $expected = new DataResponse( [ 'isGetenvServerWorking' => true, @@ -563,6 +569,7 @@ class CheckSetupControllerTest extends TestCase { 'appDirsWithDifferentOwner' => [], 'recommendedPHPModules' => [], 'pendingBigIntConversionColumns' => [], + 'isMysqlUsedWithoutUTF8MB4' => false, ] ); $this->assertEquals($expected, $this->checkSetupController->check()); @@ -1344,4 +1351,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')); + } } |