aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/effects
Commit message (Collapse)AuthorAgeFilesLines
* Updating jQuery to 1.10.2.Bruno M. Custódio2013-07-051-1/+1
| | | | | Adding jQuery 1.10.0, 1.10.1, 1.10.2, 2.0.0, 2.0.1, 2.0.2 and 2.0.3 to the tests directory.
* Test: Update effects_core test, since puff-effect and size-effect now have ↵Rafael Xavier de Souza2013-06-222-4/+3
| | | | its own files
* Effects: Handle the .hide/show/toggle( options ) signatures from core ↵Scott González2013-02-282-0/+20
| | | | properly. Fixes #9126 - .show()/.hide() do not support all of core's options.
* Effects: Delegate to core show/hide when the element is already in the ↵Scott González2013-02-262-1/+11
| | | | correct final state. This forces the element to go through the olddisplay tracking and forces styles on elements even if they're hidden via an ancestor. Fixes #9120 - Effects: .hide() inconsistent with core with a hidden parent.
* Updating 'jQuery' to 1.9.1.Bruno M. Custódio2013-02-051-1/+1
|
* Effects Core: make removeClass work correctly with changes jQuery 1.9.0. ↵David Petersen2013-01-291-0/+11
| | | | Fixed #9015 - Inclusion of jQuery UI breaks removeClass
* Updating to jQuery 1.9.0Kris Borchers2013-01-171-1/+1
|
* Upgrade jQuery to 1.8.3.Scott González2012-11-141-1/+1
|
* Effects: Remove deprecated $.effects[]. Fixes #7115 - Effects: Remove ↵Jörn Zaefferer2012-10-251-3/+0
| | | | support for effects in $.effects[].
* Build: Enable "unused" option in jshint - Remove unused variables from ↵Mike Sherov2012-10-231-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | codebase. - Closes gh-788 Squashed commit of the following: commit 7f19f92c646f180bc067bb24123175251a64a9d6 Author: Mike Sherov <mike.sherov@gmail.com> Date: Tue Oct 23 10:34:28 2012 -0400 put back in fake args for signatures that we want to keep commit 257505a9e69da0c53e3a989dab87a13112045a29 Author: Mike Sherov <mike.sherov@gmail.com> Date: Tue Oct 23 08:10:20 2012 -0400 changes per @scott_gonzalez commit 12725480cb58e70865e5aa6e735009b6b035c8f3 Author: Mike Sherov <mike.sherov@gmail.com> Date: Mon Oct 22 22:54:05 2012 -0400 clean up unused vars in ui directory commit 563595e7aee5d4a5c096b2d1de655abdf920aacd Author: Mike Sherov <mike.sherov@gmail.com> Date: Mon Oct 22 22:37:42 2012 -0400 clean up unused vars in grunt and tests
* Effects: Allow 'null' for options - Fixes #8670 - null reference when using ↵Corey Frang2012-10-211-0/+11
| | | | effects - Closes gh-783
* Upgrade jQuery to 1.8.2.Scott González2012-09-201-1/+1
|
* Upgrade jQuery to 1.8.0.Scott González2012-08-131-1/+1
|
* Tests: Enable QUnit.config.requireExpects.Scott González2012-06-272-0/+2
|
* Effects tests: Convert step callback to a no-op after first call in ↵Scott González2012-06-251-6/+6
| | | | animateClass test.
* Effects tests: Don't use internal jQuery properties to detect support for ↵Scott González2012-06-161-7/+7
| | | | fixed positioning.
* Tests: Remove the need to include the 'ui.' prefix in testJshint() now that ↵Scott González2012-06-151-1/+1
| | | | effects use 'ui.'.
* Effects tests: Fixed JSHint references.Scott González2012-06-151-1/+1
|
* Effects: Renamed all files.Scott González2012-06-151-14/+14
|
* Effects tests: Added TODO for disabled test.Scott González2012-04-301-1/+1
|
* Effects Tests: Disabling focus based test - need some help here @scottgonzalezCorey Frang2012-04-301-1/+2
|
* Effects: Updating unit tests to use some more stable logic hopefullyCorey Frang2012-04-301-26/+67
|
* Tests: Run JSHint.Scott González2012-04-291-1/+7
|
* Tests: Moved loadResources to TestHelpers.Scott González2012-04-231-6/+5
|
* Update to official qunit composite addonJörn Zaefferer2012-04-211-2/+2
|
* Tests: LintScott González2012-04-192-19/+17
|
* Upgrade jQuery to 1.7.2.Scott González2012-03-221-1/+1
|
* Upgrade jQuery to 1.7.1.Scott González2011-11-221-1/+1
|
* Effects tests: Proper detection of fixed position support in jQuery 1.7.Scott González2011-11-091-2/+7
|
* Upgrade jQuery to 1.7.Scott González2011-11-091-1/+1
|
* Tests: Change the input in the effects test to a text input. This fixes ↵kborchers2011-11-021-1/+1
| | | | failing tests in IE8 that could not focus the input.
* Tests: Added ability to run tests against minified files via ?min=1Scott González2011-10-281-14/+21
|
* Effects Core: Do not overwrite css or class changes that aren't animated ↵ddstreet2011-10-252-59/+87
| | | | during class animation. Fixed #7106 - animateClass: css and class changes during animation are lost
* Upgraded jQuery to 1.6.4.Scott González2011-10-181-1/+1
|
* Scale: We can't detect this reliably currently, so assume all elements are ↵Corey Frang2011-10-141-0/+2
| | | | positioned with left and top
* Effects tests: Ignore leading/trailing whitespace when comparing style ↵Scott González2011-09-281-2/+2
| | | | properties.
* Tests: Cleanup.Scott González2011-08-031-14/+11
|
* Tests: Added test suites to run individual widget tests against all ↵Scott González2011-08-022-2/+32
| | | | supported jQuery versions.
* Effects: Adding a check to retain focused elements after wrapping and ↵Corey Frang2011-08-021-0/+11
| | | | unwrapping in animations - Fixes #7595 - Wrapper-creating jquery-ui animations will discard any focus state during the animation - Thanks @rubyruy
* Tests: Added ability to run tests suites against different versions of ↵Scott González2011-07-281-1/+1
| | | | jQuery core.
* Merge branch 'master' into core-1.6.1Scott González2011-07-253-23/+153
|\ | | | | | | | | | | | | | | | | Conflicts: demos/menubar/default.html tests/unit/autocomplete/autocomplete.html tests/visual/effects/effects.all.html ui/jquery.ui.menu.js ui/jquery.ui.popup.js
| * Unit Tests: Fixing a typo in the new test for hide/show on hidden/shownCorey Frang2011-06-231-1/+1
| |
| * Effects.core: Check Visibility vs 'hide' and 'show' modes, finish ↵Corey Frang2011-06-231-0/+12
| | | | | | | | immediately if neccessary - Fixes #6715 - Hide and Show try to affect hidden and showing elements
| * Unit Tests: Adding a unit test to make sure .stop( true, true ) clears the ↵Corey Frang2011-06-231-0/+15
| | | | | | | | inline styles when using animateClass - Fixed #3928 - Class-Animation: Please add a clearInlineStyle-Option
| * Tests: Adding visual/unit tests for scale effect.gnarf2011-06-142-30/+107
| |
| * effects.core: Convert elements height/width to px and restore after ↵tomykaira2011-06-092-0/+26
| | | | | | | | animation in all effects. Fixed #5245 - Relative width elements break when wrapped for effects
* | Upgrade jQuery to 1.6.2.Scott González2011-07-251-1/+1
|/
* Unit Tests & effects.scale: Fixing bugs in effects unit tests - Particularly ↵gnarf2011-05-182-6/+10
| | | | IE, found a bug in scale.js in the meantime. Fixes #7395 - Size based effects are breaking unit tests in IE - also leaking a global var
* Unit Tests: Cleaning up some code in effects unit tests, removing magic ↵gnarf2011-05-161-15/+22
| | | | numbers used for animation durations
* Unit Tests: adding unit test for #7356gnarf2011-05-121-0/+20
|
stable30 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/ConfigTest.php
blob: 7c289472abd4ecd7ace8ddef2a9d51e016c6cd9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
/**
 * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace Test;

use OC\Config;

class ConfigTest extends TestCase {
	public const TESTCONTENT = '<?php $CONFIG=array("foo"=>"bar", "beers" => array("Appenzeller", "Guinness", "Kölsch"), "alcohol_free" => false);';

	/** @var array */
	private $initialConfig = ['foo' => 'bar', 'beers' => ['Appenzeller', 'Guinness', 'Kölsch'], 'alcohol_free' => false];
	/** @var string */
	private $configFile;
	/** @var string */
	private $randomTmpDir;

	protected function setUp(): void {
		parent::setUp();

		$this->randomTmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
		$this->configFile = $this->randomTmpDir.'testconfig.php';
		file_put_contents($this->configFile, self::TESTCONTENT);
	}

	protected function tearDown(): void {
		unlink($this->configFile);
		parent::tearDown();
	}

	private function getConfig(): Config {
		return new \OC\Config($this->randomTmpDir, 'testconfig.php');
	}

	public function testGetKeys() {
		$expectedConfig = ['foo', 'beers', 'alcohol_free'];
		$this->assertSame($expectedConfig, $this->getConfig()->getKeys());
	}

	public function testGetValue() {
		$config = $this->getConfig();
		$this->assertSame('bar', $config->getValue('foo'));
		$this->assertSame(null, $config->getValue('bar'));
		$this->assertSame('moo', $config->getValue('bar', 'moo'));
		$this->assertSame(false, $config->getValue('alcohol_free', 'someBogusValue'));
		$this->assertSame(['Appenzeller', 'Guinness', 'Kölsch'], $config->getValue('beers', 'someBogusValue'));
		$this->assertSame(['Appenzeller', 'Guinness', 'Kölsch'], $config->getValue('beers'));
	}

	public function testGetValueReturnsEnvironmentValueIfSet() {
		$config = $this->getConfig();
		$this->assertEquals('bar', $config->getValue('foo'));

		putenv('NC_foo=baz');
		$config = $this->getConfig();
		$this->assertEquals('baz', $config->getValue('foo'));
		putenv('NC_foo'); // unset the env variable
	}

	public function testGetValueReturnsEnvironmentValueIfSetToZero() {
		$config = $this->getConfig();
		$this->assertEquals('bar', $config->getValue('foo'));

		putenv('NC_foo=0');
		$config = $this->getConfig();
		$this->assertEquals('0', $config->getValue('foo'));
		putenv('NC_foo'); // unset the env variable
	}

	public function testGetValueReturnsEnvironmentValueIfSetToFalse() {
		$config = $this->getConfig();
		$this->assertEquals('bar', $config->getValue('foo'));

		putenv('NC_foo=false');
		$config = $this->getConfig();
		$this->assertEquals('false', $config->getValue('foo'));
		putenv('NC_foo'); // unset the env variable
	}

	public function testSetValue() {
		$config = $this->getConfig();
		$config->setValue('foo', 'moo');
		$this->assertSame('moo', $config->getValue('foo'));

		$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  'alcohol_free' => false,\n);\n";
		$this->assertEquals($expected, $content);

		$config->setValue('bar', 'red');
		$config->setValue('apps', ['files', 'gallery']);
		$this->assertSame('red', $config->getValue('bar'));
		$this->assertSame(['files', 'gallery'], $config->getValue('apps'));

		$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  'alcohol_free' => false,\n  'bar' => 'red',\n  'apps' => \n " .
			" array (\n    0 => 'files',\n    1 => 'gallery',\n  ),\n);\n";
		$this->assertEquals($expected, $content);
	}

	public function testSetValues() {
		$config = $this->getConfig();
		$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
		$config->setValues([
			'foo' => 'bar',
			'not_exists' => null,
		]);

		$this->assertSame('bar', $config->getValue('foo'));
		$this->assertSame(null, $config->getValue('not_exists'));
		$content = file_get_contents($this->configFile);
		$this->assertEquals(self::TESTCONTENT, $content);

		$config->setValues([
			'foo' => 'moo',
			'alcohol_free' => null,
		]);
		$this->assertSame('moo', $config->getValue('foo'));
		$this->assertSame(null, $config->getValue('not_exists'));

		$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() {
		$config = $this->getConfig();
		$config->deleteKey('foo');
		$this->assertSame('this_was_clearly_not_set_before', $config->getValue('foo', 'this_was_clearly_not_set_before'));
		$content = file_get_contents($this->configFile);

		$expected = "<?php\n\$CONFIG = array (\n  'beers' => \n  array (\n    0 => 'Appenzeller',\n  " .
			"  1 => 'Guinness',\n    2 => 'Kölsch',\n  ),\n  'alcohol_free' => false,\n);\n";
		$this->assertEquals($expected, $content);
	}

	public function testConfigMerge() {
		// Create additional config
		$additionalConfig = '<?php $CONFIG=array("php53"=>"totallyOutdated");';
		$additionalConfigPath = $this->randomTmpDir.'additionalConfig.testconfig.php';
		file_put_contents($additionalConfigPath, $additionalConfig);

		// Reinstantiate the config to force a read-in of the additional configs
		$config = new \OC\Config($this->randomTmpDir, 'testconfig.php');

		// Ensure that the config value can be read and the config has not been modified
		$this->assertSame('totallyOutdated', $config->getValue('php53', 'bogusValue'));
		$this->assertEquals(self::TESTCONTENT, file_get_contents($this->configFile));

		// Write a new value to the config
		$config->setValue('CoolWebsites', ['demo.owncloud.org', 'owncloud.org', 'owncloud.com']);
		$expected = "<?php\n\$CONFIG = array (\n  'foo' => 'bar',\n  'beers' => \n  array (\n    0 => 'Appenzeller',\n  " .
			"  1 => 'Guinness',\n    2 => 'Kölsch',\n  ),\n  'alcohol_free' => false,\n  'php53' => 'totallyOutdated',\n  'CoolWebsites' => \n  array (\n  " .
			"  0 => 'demo.owncloud.org',\n    1 => 'owncloud.org',\n    2 => 'owncloud.com',\n  ),\n);\n";
		$this->assertEquals($expected, file_get_contents($this->configFile));

		// Cleanup
		unlink($additionalConfigPath);
	}
}