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>
This commit is contained in:
parent
1d290e15e8
commit
f11d72a928
|
@ -71,9 +71,7 @@ class ConfigTest extends TestCase {
|
||||||
|
|
||||||
public function testSetValue() {
|
public function testSetValue() {
|
||||||
$this->config->setValue('foo', 'moo');
|
$this->config->setValue('foo', 'moo');
|
||||||
$expectedConfig = $this->initialConfig;
|
$this->assertSame('moo', $this->config->getValue('foo'));
|
||||||
$expectedConfig['foo'] = 'moo';
|
|
||||||
$this->assertAttributeEquals($expectedConfig, 'cache', $this->config);
|
|
||||||
|
|
||||||
$content = file_get_contents($this->configFile);
|
$content = file_get_contents($this->configFile);
|
||||||
$expected = "<?php\n\$CONFIG = array (\n 'foo' => 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " .
|
$expected = "<?php\n\$CONFIG = array (\n 'foo' => 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " .
|
||||||
|
@ -82,9 +80,8 @@ class ConfigTest extends TestCase {
|
||||||
|
|
||||||
$this->config->setValue('bar', 'red');
|
$this->config->setValue('bar', 'red');
|
||||||
$this->config->setValue('apps', ['files', 'gallery']);
|
$this->config->setValue('apps', ['files', 'gallery']);
|
||||||
$expectedConfig['bar'] = 'red';
|
$this->assertSame('red', $this->config->getValue('bar'));
|
||||||
$expectedConfig['apps'] = ['files', 'gallery'];
|
$this->assertSame(['files', 'gallery'], $this->config->getValue('apps'));
|
||||||
$this->assertAttributeEquals($expectedConfig, 'cache', $this->config);
|
|
||||||
|
|
||||||
$content = file_get_contents($this->configFile);
|
$content = file_get_contents($this->configFile);
|
||||||
|
|
||||||
|
@ -105,7 +102,8 @@ class ConfigTest extends TestCase {
|
||||||
'not_exists' => null,
|
'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);
|
$content = file_get_contents($this->configFile);
|
||||||
$this->assertEquals(self::TESTCONTENT, $content);
|
$this->assertEquals(self::TESTCONTENT, $content);
|
||||||
|
|
||||||
|
@ -113,10 +111,8 @@ class ConfigTest extends TestCase {
|
||||||
'foo' => 'moo',
|
'foo' => 'moo',
|
||||||
'alcohol_free' => null,
|
'alcohol_free' => null,
|
||||||
]);
|
]);
|
||||||
$expectedConfig = $this->initialConfig;
|
$this->assertSame('moo', $this->config->getValue('foo'));
|
||||||
$expectedConfig['foo'] = 'moo';
|
$this->assertSame(null, $this->config->getValue('not_exists'));
|
||||||
unset($expectedConfig['alcohol_free']);
|
|
||||||
$this->assertAttributeEquals($expectedConfig, 'cache', $this->config);
|
|
||||||
|
|
||||||
$content = file_get_contents($this->configFile);
|
$content = file_get_contents($this->configFile);
|
||||||
$expected = "<?php\n\$CONFIG = array (\n 'foo' => 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " .
|
$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() {
|
public function testDeleteKey() {
|
||||||
$this->config->deleteKey('foo');
|
$this->config->deleteKey('foo');
|
||||||
$expectedConfig = $this->initialConfig;
|
$this->assertSame('this_was_clearly_not_set_before', $this->config->getValue('foo', 'this_was_clearly_not_set_before'));
|
||||||
unset($expectedConfig['foo']);
|
|
||||||
$this->assertAttributeEquals($expectedConfig, 'cache', $this->config);
|
|
||||||
$content = file_get_contents($this->configFile);
|
$content = file_get_contents($this->configFile);
|
||||||
|
|
||||||
$expected = "<?php\n\$CONFIG = array (\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " .
|
$expected = "<?php\n\$CONFIG = array (\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " .
|
||||||
|
|
|
@ -83,8 +83,8 @@ class DBSchemaTest extends TestCase {
|
||||||
$outfile = $this->tempManager->getTemporaryFile();
|
$outfile = $this->tempManager->getTemporaryFile();
|
||||||
OC_DB::getDbStructure($outfile);
|
OC_DB::getDbStructure($outfile);
|
||||||
$content = file_get_contents($outfile);
|
$content = file_get_contents($outfile);
|
||||||
$this->assertContains($this->table1, $content);
|
$this->assertStringContainsString($this->table1, $content);
|
||||||
$this->assertContains($this->table2, $content);
|
$this->assertStringContainsString($this->table2, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doTestSchemaRemoving() {
|
public function doTestSchemaRemoving() {
|
||||||
|
|
Loading…
Reference in New Issue