Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-07-23 14:36:49 +0300
committerMorris Jobke <hey@morrisjobke.de>2020-07-30 14:18:14 +0300
commit7a49d0fbeadd6825cf45031e9bb9ab0e308039d5 (patch)
tree6ae1c0beb073973e7ec9b3abfab58a8b57404218 /tests
parent3904acfe932be26be71daf2ae047a144ac8b48c9 (diff)
Remove deprecated test of internal attributes via assertAttributeEquals
See https://github.com/sebastianbergmann/phpunit/issues/3339#issuecomment-428843322 It is seen as bad practice to test internal stuff of objects instead of the actual input and output of mathod calls. Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/ConfigTest.php24
-rw-r--r--tests/lib/DB/DBSchemaTest.php4
2 files changed, 11 insertions, 17 deletions
diff --git a/tests/lib/ConfigTest.php b/tests/lib/ConfigTest.php
index 109f7471e96..1d2440d6635 100644
--- a/tests/lib/ConfigTest.php
+++ b/tests/lib/ConfigTest.php
@@ -71,9 +71,7 @@ class ConfigTest extends TestCase {
public function testSetValue() {
$this->config->setValue('foo', 'moo');
- $expectedConfig = $this->initialConfig;
- $expectedConfig['foo'] = 'moo';
- $this->assertAttributeEquals($expectedConfig, 'cache', $this->config);
+ $this->assertSame('moo', $this->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 " .
@@ -81,10 +79,9 @@ class ConfigTest extends TestCase {
$this->assertEquals($expected, $content);
$this->config->setValue('bar', 'red');
- $this->config->setValue('apps', array('files', 'gallery'));
- $expectedConfig['bar'] = 'red';
- $expectedConfig['apps'] = array('files', 'gallery');
- $this->assertAttributeEquals($expectedConfig, 'cache', $this->config);
+ $this->config->setValue('apps', ['files', 'gallery']);
+ $this->assertSame('red', $this->config->getValue('bar'));
+ $this->assertSame(['files', 'gallery'], $this->config->getValue('apps'));
$content = file_get_contents($this->configFile);
@@ -105,7 +102,8 @@ class ConfigTest extends TestCase {
'not_exists' => null,
]);
- $this->assertAttributeEquals($this->initialConfig, 'cache', $this->config);
+ $this->assertSame('bar', $this->config->getValue('foo'));
+ $this->assertSame(null, $this->config->getValue('not_exists'));
$content = file_get_contents($this->configFile);
$this->assertEquals(self::TESTCONTENT, $content);
@@ -113,10 +111,8 @@ class ConfigTest extends TestCase {
'foo' => 'moo',
'alcohol_free' => null,
]);
- $expectedConfig = $this->initialConfig;
- $expectedConfig['foo'] = 'moo';
- unset($expectedConfig['alcohol_free']);
- $this->assertAttributeEquals($expectedConfig, 'cache', $this->config);
+ $this->assertSame('moo', $this->config->getValue('foo'));
+ $this->assertSame(null, $this->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 " .
@@ -126,9 +122,7 @@ class ConfigTest extends TestCase {
public function testDeleteKey() {
$this->config->deleteKey('foo');
- $expectedConfig = $this->initialConfig;
- unset($expectedConfig['foo']);
- $this->assertAttributeEquals($expectedConfig, 'cache', $this->config);
+ $this->assertSame('this_was_clearly_not_set_before', $this->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 " .
diff --git a/tests/lib/DB/DBSchemaTest.php b/tests/lib/DB/DBSchemaTest.php
index 5fb68fdf258..d185f73e62c 100644
--- a/tests/lib/DB/DBSchemaTest.php
+++ b/tests/lib/DB/DBSchemaTest.php
@@ -83,8 +83,8 @@ class DBSchemaTest extends TestCase {
$outfile = $this->tempManager->getTemporaryFile();
OC_DB::getDbStructure($outfile);
$content = file_get_contents($outfile);
- $this->assertContains($this->table1, $content);
- $this->assertContains($this->table2, $content);
+ $this->assertStringContainsString($this->table1, $content);
+ $this->assertStringContainsString($this->table2, $content);
}
public function doTestSchemaRemoving() {