diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/config.php | 30 | ||||
-rw-r--r-- | tests/settings/controller/mailsettingscontrollertest.php | 63 |
2 files changed, 63 insertions, 30 deletions
diff --git a/tests/lib/config.php b/tests/lib/config.php index 6adba356a1c..91154579ab5 100644 --- a/tests/lib/config.php +++ b/tests/lib/config.php @@ -71,6 +71,36 @@ class Test_Config extends \Test\TestCase { $this->assertEquals($expected, $content); } + public function testSetValues() { + $content = file_get_contents($this->configFile); + $this->assertEquals(self::TESTCONTENT, $content); + + // Changing configs to existing values and deleting non-existing once + // should not rewrite the config.php + $this->config->setValues([ + 'foo' => 'bar', + 'not_exists' => null, + ]); + + $this->assertAttributeEquals($this->initialConfig, 'cache', $this->config); + $content = file_get_contents($this->configFile); + $this->assertEquals(self::TESTCONTENT, $content); + + $this->config->setValues([ + 'foo' => 'moo', + 'alcohol_free' => null, + ]); + $expectedConfig = $this->initialConfig; + $expectedConfig['foo'] = 'moo'; + unset($expectedConfig['alcohol_free']); + $this->assertAttributeEquals($expectedConfig, 'cache', $this->config); + + $content = file_get_contents($this->configFile); + $expected = "<?php\n\$CONFIG = array (\n 'foo' => 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . + " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n);\n"; + $this->assertEquals($expected, $content); + } + public function testDeleteKey() { $this->config->deleteKey('foo'); $expectedConfig = $this->initialConfig; diff --git a/tests/settings/controller/mailsettingscontrollertest.php b/tests/settings/controller/mailsettingscontrollertest.php index f6ebade7b17..ed33d7fbe49 100644 --- a/tests/settings/controller/mailsettingscontrollertest.php +++ b/tests/settings/controller/mailsettingscontrollertest.php @@ -69,26 +69,37 @@ class MailSettingsControllerTest extends \Test\TestCase { ); */ - $this->container['Config'] - ->expects($this->exactly(15)) - ->method('setSystemValue'); - + /** @var \PHPUnit_Framework_MockObject_MockObject $config */ + $config = $this->container['Config']; + $config->expects($this->exactly(2)) + ->method('setSystemValues'); /** * FIXME: Use the following block once Jenkins uses PHPUnit >= 4.1 - */ - /* - $this->container['Config'] - ->expects($this->exactly(3)) - ->method('deleteSystemValue') ->withConsecutive( - array($this->equalTo('mail_smtpauth')), - array($this->equalTo('mail_smtpname')), - array($this->equalTo('mail_smtppassword')) + [[ + 'mail_domain' => 'owncloud.com', + 'mail_from_address' => 'demo@owncloud.com', + 'mail_smtpmode' => 'smtp', + 'mail_smtpsecure' => 'ssl', + 'mail_smtphost' => 'mx.owncloud.org', + 'mail_smtpauthtype' => 'NTLM', + 'mail_smtpauth' => 1, + 'mail_smtpport' => '25', + ]], + [[ + 'mail_domain' => 'owncloud.com', + 'mail_from_address' => 'demo@owncloud.com', + 'mail_smtpmode' => 'smtp', + 'mail_smtpsecure' => 'ssl', + 'mail_smtphost' => 'mx.owncloud.org', + 'mail_smtpauthtype' => 'NTLM', + 'mail_smtpauth' => null, + 'mail_smtpport' => '25', + 'mail_smtpname' => null, + 'mail_smtppassword' => null, + ]] ); - */ - $this->container['Config'] - ->expects($this->exactly(3)) - ->method('deleteSystemValue'); + */ // With authentication $response = $this->container['MailSettingsController']->setMailSettings( @@ -126,21 +137,13 @@ class MailSettingsControllerTest extends \Test\TestCase { ->method('t') ->will($this->returnValue('Saved')); - /** - * FIXME: Use this block once Jenkins uses PHPUnit >= 4.1 - */ - /* $this->container['Config'] - ->expects($this->exactly(2)) - ->method('setSystemValue') - ->withConsecutive( - array($this->equalTo('mail_smtpname'), $this->equalTo('UsernameToStore')), - array($this->equalTo('mail_smtppassword'), $this->equalTo('PasswordToStore')) - ); - */ - $this->container['Config'] - ->expects($this->exactly(2)) - ->method('setSystemValue'); + ->expects($this->once()) + ->method('setSystemValues') + ->with([ + 'mail_smtpname' => 'UsernameToStore', + 'mail_smtppassword' => 'PasswordToStore', + ]); $response = $this->container['MailSettingsController']->storeCredentials('UsernameToStore', 'PasswordToStore'); $expectedResponse = array('data' => array('message' =>'Saved'), 'status' => 'success'); |