Fix wrong $this->assert...() with `self::assert...()

This commit is contained in:
Philipp 2020-10-17 14:19:57 +02:00
parent b3e5621d37
commit efaec26b1d
No known key found for this signature in database
GPG key ID: 9A28B7D4FF5667BD
63 changed files with 1192 additions and 1192 deletions

View file

@ -264,7 +264,7 @@ Installation is finished
FIN;
$this->assertEquals($finished, $txt);
self::assertEquals($finished, $txt);
}
private function assertStuckDB($txt)
@ -295,7 +295,7 @@ Could not connect to database.:
FIN;
$this->assertEquals($finished, $txt);
self::assertEquals($finished, $txt);
}
private function assertStuckURL($txt)
@ -319,7 +319,7 @@ The Friendica URL has to be set during CLI installation.
FIN;
$this->assertEquals($finished, $txt);
self::assertEquals($finished, $txt);
}
/**
@ -333,13 +333,13 @@ FIN;
public function assertConfigEntry($cat, $key, $assertion = null, $default_value = null)
{
if (!empty($assertion[$cat][$key])) {
$this->assertEquals($assertion[$cat][$key], $this->configCache->get($cat, $key));
self::assertEquals($assertion[$cat][$key], $this->configCache->get($cat, $key));
} elseif (!empty($assertion) && !is_array($assertion)) {
$this->assertEquals($assertion, $this->configCache->get($cat, $key));
self::assertEquals($assertion, $this->configCache->get($cat, $key));
} elseif (!empty($default_value)) {
$this->assertEquals($default_value, $this->configCache->get($cat, $key));
self::assertEquals($default_value, $this->configCache->get($cat, $key));
} else {
$this->assertEmpty($this->configCache->get($cat, $key), $this->configCache->get($cat, $key));
self::assertEmpty($this->configCache->get($cat, $key), $this->configCache->get($cat, $key));
}
}
@ -358,21 +358,21 @@ FIN;
$assertion['database']['hostname'] .= (!empty($assertion['database']['port']) ? ':' . $assertion['database']['port'] : '');
}
$this->assertConfigEntry('database', 'hostname', ($saveDb) ? $assertion : null, (!$saveDb || $defaultDb) ? Installer::DEFAULT_HOST : null);
$this->assertConfigEntry('database', 'username', ($saveDb) ? $assertion : null);
$this->assertConfigEntry('database', 'password', ($saveDb) ? $assertion : null);
$this->assertConfigEntry('database', 'database', ($saveDb) ? $assertion : null);
self::assertConfigEntry('database', 'hostname', ($saveDb) ? $assertion : null, (!$saveDb || $defaultDb) ? Installer::DEFAULT_HOST : null);
self::assertConfigEntry('database', 'username', ($saveDb) ? $assertion : null);
self::assertConfigEntry('database', 'password', ($saveDb) ? $assertion : null);
self::assertConfigEntry('database', 'database', ($saveDb) ? $assertion : null);
$this->assertConfigEntry('config', 'admin_email', $assertion);
$this->assertConfigEntry('config', 'php_path', trim(shell_exec('which php')));
$this->assertConfigEntry('config', 'hostname', $assertion);
self::assertConfigEntry('config', 'admin_email', $assertion);
self::assertConfigEntry('config', 'php_path', trim(shell_exec('which php')));
self::assertConfigEntry('config', 'hostname', $assertion);
$this->assertConfigEntry('system', 'default_timezone', $assertion, ($default) ? Installer::DEFAULT_TZ : null);
$this->assertConfigEntry('system', 'language', $assertion, ($default) ? Installer::DEFAULT_LANG : null);
$this->assertConfigEntry('system', 'url', $assertion);
$this->assertConfigEntry('system', 'urlpath', $assertion);
$this->assertConfigEntry('system', 'ssl_policy', $assertion, ($default) ? App\BaseURL::DEFAULT_SSL_SCHEME : null);
$this->assertConfigEntry('system', 'basepath', ($realBasepath) ? $this->root->url() : $assertion);
self::assertConfigEntry('system', 'default_timezone', $assertion, ($default) ? Installer::DEFAULT_TZ : null);
self::assertConfigEntry('system', 'language', $assertion, ($default) ? Installer::DEFAULT_LANG : null);
self::assertConfigEntry('system', 'url', $assertion);
self::assertConfigEntry('system', 'urlpath', $assertion);
self::assertConfigEntry('system', 'ssl_policy', $assertion, ($default) ? App\BaseURL::DEFAULT_SSL_SCHEME : null);
self::assertConfigEntry('system', 'basepath', ($realBasepath) ? $this->root->url() : $assertion);
}
/**
@ -385,7 +385,7 @@ FIN;
$txt = $this->dumpExecute($console);
$this->assertStuckURL($txt);
self::assertStuckURL($txt);
}
/**
@ -407,10 +407,10 @@ FIN;
$txt = $this->dumpExecute($console);
$this->assertFinished($txt, true, false);
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
self::assertFinished($txt, true, false);
self::assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
$this->assertConfig(['config' => ['hostname' => 'friendica.local'], 'system' => ['url' => 'http://friendica.local', 'ssl_policy' => 0, 'urlPath' => '']], false, true, true, true);
self::assertConfig(['config' => ['hostname' => 'friendica.local'], 'system' => ['url' => 'http://friendica.local', 'ssl_policy' => 0, 'urlPath' => '']], false, true, true, true);
}
/**
@ -481,12 +481,12 @@ CONF;
$txt = $this->dumpExecute($console);
$this->assertFinished($txt, false, true);
self::assertFinished($txt, false, true);
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
$this->assertEquals($config, file_get_contents($this->root->getChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')->url()));
self::assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
self::assertEquals($config, file_get_contents($this->root->getChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')->url()));
$this->assertConfig($data, true, false, false);
self::assertConfig($data, true, false, false);
}
/**
@ -504,27 +504,27 @@ CONF;
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
$this->assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
$this->assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
$this->assertTrue(putenv('MYSQL_DATABASE=' . $data['database']['database']));
$this->assertTrue(putenv('MYSQL_USERNAME=' . $data['database']['username']));
$this->assertTrue(putenv('MYSQL_PASSWORD=' . $data['database']['password']));
self::assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
self::assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
self::assertTrue(putenv('MYSQL_DATABASE=' . $data['database']['database']));
self::assertTrue(putenv('MYSQL_USERNAME=' . $data['database']['username']));
self::assertTrue(putenv('MYSQL_PASSWORD=' . $data['database']['password']));
$this->assertTrue(putenv('FRIENDICA_HOSTNAME=' . $data['config']['hostname']));
$this->assertTrue(putenv('FRIENDICA_BASE_PATH=' . $data['system']['basepath']));
$this->assertTrue(putenv('FRIENDICA_URL=' . $data['system']['url']));
$this->assertTrue(putenv('FRIENDICA_PHP_PATH=' . $data['config']['php_path']));
$this->assertTrue(putenv('FRIENDICA_ADMIN_MAIL=' . $data['config']['admin_email']));
$this->assertTrue(putenv('FRIENDICA_TZ=' . $data['system']['default_timezone']));
$this->assertTrue(putenv('FRIENDICA_LANG=' . $data['system']['language']));
self::assertTrue(putenv('FRIENDICA_HOSTNAME=' . $data['config']['hostname']));
self::assertTrue(putenv('FRIENDICA_BASE_PATH=' . $data['system']['basepath']));
self::assertTrue(putenv('FRIENDICA_URL=' . $data['system']['url']));
self::assertTrue(putenv('FRIENDICA_PHP_PATH=' . $data['config']['php_path']));
self::assertTrue(putenv('FRIENDICA_ADMIN_MAIL=' . $data['config']['admin_email']));
self::assertTrue(putenv('FRIENDICA_TZ=' . $data['system']['default_timezone']));
self::assertTrue(putenv('FRIENDICA_LANG=' . $data['system']['language']));
$console = new AutomaticInstallation($this->consoleArgv);
$console->setOption('savedb', true);
$txt = $this->dumpExecute($console);
$this->assertFinished($txt, true);
$this->assertConfig($data, true, true, false, true);
self::assertFinished($txt, true);
self::assertConfig($data, true, true, false, true);
}
/**
@ -542,26 +542,26 @@ CONF;
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
$this->assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
$this->assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
$this->assertTrue(putenv('MYSQL_DATABASE=' . $data['database']['database']));
$this->assertTrue(putenv('MYSQL_USERNAME=' . $data['database']['username']));
$this->assertTrue(putenv('MYSQL_PASSWORD=' . $data['database']['password']));
self::assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
self::assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
self::assertTrue(putenv('MYSQL_DATABASE=' . $data['database']['database']));
self::assertTrue(putenv('MYSQL_USERNAME=' . $data['database']['username']));
self::assertTrue(putenv('MYSQL_PASSWORD=' . $data['database']['password']));
$this->assertTrue(putenv('FRIENDICA_HOSTNAME=' . $data['config']['hostname']));
$this->assertTrue(putenv('FRIENDICA_BASE_PATH=' . $data['system']['basepath']));
$this->assertTrue(putenv('FRIENDICA_URL=' . $data['system']['url']));
$this->assertTrue(putenv('FRIENDICA_PHP_PATH=' . $data['config']['php_path']));
$this->assertTrue(putenv('FRIENDICA_ADMIN_MAIL=' . $data['config']['admin_email']));
$this->assertTrue(putenv('FRIENDICA_TZ=' . $data['system']['default_timezone']));
$this->assertTrue(putenv('FRIENDICA_LANG=' . $data['system']['language']));
self::assertTrue(putenv('FRIENDICA_HOSTNAME=' . $data['config']['hostname']));
self::assertTrue(putenv('FRIENDICA_BASE_PATH=' . $data['system']['basepath']));
self::assertTrue(putenv('FRIENDICA_URL=' . $data['system']['url']));
self::assertTrue(putenv('FRIENDICA_PHP_PATH=' . $data['config']['php_path']));
self::assertTrue(putenv('FRIENDICA_ADMIN_MAIL=' . $data['config']['admin_email']));
self::assertTrue(putenv('FRIENDICA_TZ=' . $data['system']['default_timezone']));
self::assertTrue(putenv('FRIENDICA_LANG=' . $data['system']['language']));
$console = new AutomaticInstallation($this->consoleArgv);
$txt = $this->dumpExecute($console);
$this->assertFinished($txt, true);
$this->assertConfig($data, false, true, false, true);
self::assertFinished($txt, true);
self::assertConfig($data, false, true, false, true);
}
/**
@ -599,8 +599,8 @@ CONF;
$txt = $this->dumpExecute($console);
$this->assertFinished($txt, true);
$this->assertConfig($data, true, true, true, true);
self::assertFinished($txt, true);
self::assertConfig($data, true, true, true, true);
}
/**
@ -618,10 +618,10 @@ CONF;
$txt = $this->dumpExecute($console);
$this->assertStuckDB($txt);
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
self::assertStuckDB($txt);
self::assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
$this->assertConfig(['config' => ['hostname' => 'friendica.local'], 'system' => ['url' => 'http://friendica.local', 'ssl_policy' => 0, 'urlpath' => '']], false, true, false, true);
self::assertConfig(['config' => ['hostname' => 'friendica.local'], 'system' => ['url' => 'http://friendica.local', 'ssl_policy' => 0, 'urlpath' => '']], false, true, false, true);
}
public function testGetHelp()
@ -685,6 +685,6 @@ HELP;
$txt = $this->dumpExecute($console);
$this->assertEquals($theHelp, $txt);
self::assertEquals($theHelp, $txt);
}
}

View file

@ -71,7 +71,7 @@ class ConfigConsoleTest extends ConsoleTest
$console->setArgument(1, 'test');
$console->setArgument(2, 'now');
$txt = $this->dumpExecute($console);
$this->assertEquals("config.test <= now\n", $txt);
self::assertEquals("config.test <= now\n", $txt);
$this->configMock
->shouldReceive('get')
@ -83,7 +83,7 @@ class ConfigConsoleTest extends ConsoleTest
$console->setArgument(0, 'config');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
$this->assertEquals("config.test => now\n", $txt);
self::assertEquals("config.test => now\n", $txt);
$this->configMock
->shouldReceive('get')
@ -95,7 +95,7 @@ class ConfigConsoleTest extends ConsoleTest
$console->setArgument(0, 'config');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
$this->assertEquals("config.test => \n", $txt);
self::assertEquals("config.test => \n", $txt);
}
function testSetArrayValue() {
@ -112,7 +112,7 @@ class ConfigConsoleTest extends ConsoleTest
$console->setArgument(2, 'now');
$txt = $this->dumpExecute($console);
$this->assertEquals("[Error] config.test is an array and can't be set using this command.\n", $txt);
self::assertEquals("[Error] config.test is an array and can't be set using this command.\n", $txt);
}
function testTooManyArguments() {
@ -124,7 +124,7 @@ class ConfigConsoleTest extends ConsoleTest
$txt = $this->dumpExecute($console);
$assertion = '[Warning] Too many arguments';
$firstline = substr($txt, 0, strlen($assertion));
$this->assertEquals($assertion, $firstline);
self::assertEquals($assertion, $firstline);
}
function testVerbose() {
@ -152,7 +152,7 @@ test.it => now
CONF;
$txt = $this->dumpExecute($console);
$this->assertEquals($assertion, $txt);
self::assertEquals($assertion, $txt);
}
function testUnableToSet() {
@ -171,7 +171,7 @@ CONF;
$console->setArgument(1, 'it');
$console->setArgument(2, 'now');
$txt = $this->dumpExecute($console);
$this->assertSame("Unable to set test.it\n", $txt);
self::assertSame("Unable to set test.it\n", $txt);
}
public function testGetHelp()
@ -212,6 +212,6 @@ HELP;
$txt = $this->dumpExecute($console);
$this->assertEquals($txt, $theHelp);
self::assertEquals($txt, $theHelp);
}
}

View file

@ -66,7 +66,7 @@ class LockConsoleTest extends ConsoleTest
$console = new Lock($this->appMode, $this->lockMock, $this->consoleArgv);
$console->setArgument(0, 'list');
$txt = $this->dumpExecute($console);
$this->assertEquals("Listing all Locks:\ntest\ntest2\n2 locks found\n", $txt);
self::assertEquals("Listing all Locks:\ntest\ntest2\n2 locks found\n", $txt);
}
public function testListPrefix()
@ -81,7 +81,7 @@ class LockConsoleTest extends ConsoleTest
$console->setArgument(0, 'list');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
$this->assertEquals("Listing all Locks starting with \"test\":\ntest\ntest2\n2 locks found\n", $txt);
self::assertEquals("Listing all Locks starting with \"test\":\ntest\ntest2\n2 locks found\n", $txt);
}
public function testDelLock()
@ -96,7 +96,7 @@ class LockConsoleTest extends ConsoleTest
$console->setArgument(0, 'del');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
$this->assertEquals("Lock 'test' released.\n", $txt);
self::assertEquals("Lock 'test' released.\n", $txt);
}
public function testDelUnknownLock()
@ -111,7 +111,7 @@ class LockConsoleTest extends ConsoleTest
$console->setArgument(0, 'del');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
$this->assertEquals("Couldn't release Lock 'test'\n", $txt);
self::assertEquals("Couldn't release Lock 'test'\n", $txt);
}
public function testSetLock()
@ -131,7 +131,7 @@ class LockConsoleTest extends ConsoleTest
$console->setArgument(0, 'set');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
$this->assertEquals("Lock 'test' acquired.\n", $txt);
self::assertEquals("Lock 'test' acquired.\n", $txt);
}
public function testSetLockIsLocked()
@ -146,7 +146,7 @@ class LockConsoleTest extends ConsoleTest
$console->setArgument(0, 'set');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
$this->assertEquals("[Error] 'test' is already set.\n", $txt);
self::assertEquals("[Error] 'test' is already set.\n", $txt);
}
public function testSetLockNotWorking()
@ -166,7 +166,7 @@ class LockConsoleTest extends ConsoleTest
$console->setArgument(0, 'set');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
$this->assertEquals("[Error] Unable to lock 'test'.\n", $txt);
self::assertEquals("[Error] Unable to lock 'test'.\n", $txt);
}
public function testReleaseAll()
@ -179,7 +179,7 @@ class LockConsoleTest extends ConsoleTest
$console = new Lock($this->appMode, $this->lockMock, $this->consoleArgv);
$console->setArgument(0, 'clear');
$txt = $this->dumpExecute($console);
$this->assertEquals("Locks successfully cleared.\n", $txt);
self::assertEquals("Locks successfully cleared.\n", $txt);
}
public function testReleaseAllFailed()
@ -192,7 +192,7 @@ class LockConsoleTest extends ConsoleTest
$console = new Lock($this->appMode, $this->lockMock, $this->consoleArgv);
$console->setArgument(0, 'clear');
$txt = $this->dumpExecute($console);
$this->assertEquals("[Error] Unable to clear the locks.\n", $txt);
self::assertEquals("[Error] Unable to clear the locks.\n", $txt);
}
public function testGetHelp()
@ -229,6 +229,6 @@ HELP;
$txt = $this->dumpExecute($console);
$this->assertEquals($txt, $theHelp);
self::assertEquals($txt, $theHelp);
}
}

View file

@ -69,7 +69,7 @@ class ServerBlockConsoleTest extends ConsoleTest
CONS;
$this->assertEquals($output, $txt);
self::assertEquals($output, $txt);
}
/**
@ -101,7 +101,7 @@ CONS;
$console->setArgument(2, 'I like it!');
$txt = $this->dumpExecute($console);
$this->assertEquals('The domain \'testme.now\' is now blocked. (Reason: \'I like it!\')' . PHP_EOL, $txt);
self::assertEquals('The domain \'testme.now\' is now blocked. (Reason: \'I like it!\')' . PHP_EOL, $txt);
}
/**
@ -132,7 +132,7 @@ CONS;
$console->setArgument(1, 'testme.now');
$txt = $this->dumpExecute($console);
$this->assertEquals('The domain \'testme.now\' is now blocked. (Reason: \'' . ServerBlock::DEFAULT_REASON . '\')' . PHP_EOL, $txt);
self::assertEquals('The domain \'testme.now\' is now blocked. (Reason: \'' . ServerBlock::DEFAULT_REASON . '\')' . PHP_EOL, $txt);
}
/**
@ -169,7 +169,7 @@ CONS;
$console->setArgument(2, 'Other reason');
$txt = $this->dumpExecute($console);
$this->assertEquals('The domain \'pod.ordoevangelistarum.com\' is now updated. (Reason: \'Other reason\')' . PHP_EOL, $txt);
self::assertEquals('The domain \'pod.ordoevangelistarum.com\' is now updated. (Reason: \'Other reason\')' . PHP_EOL, $txt);
}
/**
@ -201,7 +201,7 @@ CONS;
$console->setArgument(1, 'pod.ordoevangelistarum.com');
$txt = $this->dumpExecute($console);
$this->assertEquals('The domain \'pod.ordoevangelistarum.com\' is not more blocked' . PHP_EOL, $txt);
self::assertEquals('The domain \'pod.ordoevangelistarum.com\' is not more blocked' . PHP_EOL, $txt);
}
/**
@ -213,7 +213,7 @@ CONS;
$console->setArgument(0, 'wrongcommand');
$txt = $this->dumpExecute($console);
$this->assertStringStartsWith('[Warning] Unknown command', $txt);
self::assertStringStartsWith('[Warning] Unknown command', $txt);
}
/**
@ -232,7 +232,7 @@ CONS;
$console->setArgument(1, 'not.exiting');
$txt = $this->dumpExecute($console);
$this->assertEquals('The domain \'not.exiting\' is not blocked.' . PHP_EOL, $txt);
self::assertEquals('The domain \'not.exiting\' is not blocked.' . PHP_EOL, $txt);
}
/**
@ -244,7 +244,7 @@ CONS;
$console->setArgument(0, 'add');
$txt = $this->dumpExecute($console);
$this->assertStringStartsWith('[Warning] Add needs a domain and optional a reason.', $txt);
self::assertStringStartsWith('[Warning] Add needs a domain and optional a reason.', $txt);
}
/**
@ -275,7 +275,7 @@ CONS;
$console->setArgument(1, 'testme.now');
$txt = $this->dumpExecute($console);
$this->assertEquals('Couldn\'t save \'testme.now\' as blocked server' . PHP_EOL, $txt);
self::assertEquals('Couldn\'t save \'testme.now\' as blocked server' . PHP_EOL, $txt);
}
/**
@ -307,7 +307,7 @@ CONS;
$console->setArgument(1, 'pod.ordoevangelistarum.com');
$txt = $this->dumpExecute($console);
$this->assertEquals('Couldn\'t remove \'pod.ordoevangelistarum.com\' from blocked servers' . PHP_EOL, $txt);
self::assertEquals('Couldn\'t remove \'pod.ordoevangelistarum.com\' from blocked servers' . PHP_EOL, $txt);
}
/**
@ -319,7 +319,7 @@ CONS;
$console->setArgument(0, 'remove');
$txt = $this->dumpExecute($console);
$this->assertStringStartsWith('[Warning] Remove needs a second parameter.', $txt);
self::assertStringStartsWith('[Warning] Remove needs a second parameter.', $txt);
}
/**
@ -357,6 +357,6 @@ Options
HELP;
$this->assertEquals($help, $txt);
self::assertEquals($help, $txt);
}
}