Browse Source

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

pull/9436/head
Philipp 1 year ago
parent
commit
efaec26b1d
No known key found for this signature in database GPG Key ID: 9A28B7D4FF5667BD
  1. 42
      tests/functional/DependencyCheckTest.php
  2. 600
      tests/legacy/ApiTest.php
  3. 28
      tests/src/App/ArgumentsTest.php
  4. 72
      tests/src/App/ModeTest.php
  5. 14
      tests/src/App/ModuleTest.php
  6. 48
      tests/src/App/RouterTest.php
  7. 128
      tests/src/Console/AutomaticInstallationConsoleTest.php
  8. 16
      tests/src/Console/ConfigConsoleTest.php
  9. 20
      tests/src/Console/LockConsoleTest.php
  10. 24
      tests/src/Console/ServerBlockConsoleTest.php
  11. 4
      tests/src/Content/PageInfoTest.php
  12. 2
      tests/src/Content/SmiliesTest.php
  13. 2
      tests/src/Content/Text/BBCode/VideoTest.php
  14. 8
      tests/src/Content/Text/BBCodeTest.php
  15. 4
      tests/src/Content/Text/HTMLTest.php
  16. 4
      tests/src/Content/Text/MarkdownTest.php
  17. 52
      tests/src/Core/Cache/CacheTest.php
  18. 38
      tests/src/Core/Cache/MemoryCacheTest.php
  19. 70
      tests/src/Core/Config/CacheTest.php
  20. 92
      tests/src/Core/Config/ConfigTest.php
  21. 2
      tests/src/Core/Config/JitConfigTest.php
  22. 4
      tests/src/Core/Config/PreloadConfigTest.php
  23. 66
      tests/src/Core/InstallerTest.php
  24. 2
      tests/src/Core/L10nTest.php
  25. 140
      tests/src/Core/Lock/LockTest.php
  26. 20
      tests/src/Core/Lock/SemaphoreLockTest.php
  27. 52
      tests/src/Core/PConfig/CacheTest.php
  28. 2
      tests/src/Core/PConfig/JitPConfigTest.php
  29. 108
      tests/src/Core/PConfig/PConfigTest.php
  30. 4
      tests/src/Core/PConfig/PreloadPConfigTest.php
  31. 50
      tests/src/Core/StorageManagerTest.php
  32. 10
      tests/src/Core/SystemTest.php
  33. 12
      tests/src/Database/DBATest.php
  34. 26
      tests/src/Database/DBStructureTest.php
  35. 4
      tests/src/Model/FileTagTest.php
  36. 12
      tests/src/Model/ProcessTest.php
  37. 2
      tests/src/Model/Storage/DatabaseStorageTest.php
  38. 12
      tests/src/Model/Storage/FilesystemStorageTest.php
  39. 22
      tests/src/Model/Storage/StorageTest.php
  40. 66
      tests/src/Model/User/CookieTest.php
  41. 6
      tests/src/Model/UserTest.php
  42. 54
      tests/src/Module/Api/Twitter/ContactEndpointTest.php
  43. 76
      tests/src/Network/CurlResultTest.php
  44. 4
      tests/src/Network/ProbeTest.php
  45. 6
      tests/src/Protocol/ActivityTest.php
  46. 20
      tests/src/Util/ACLFormaterTest.php
  47. 22
      tests/src/Util/ArraysTest.php
  48. 2
      tests/src/Util/BasePathTest.php
  49. 28
      tests/src/Util/BaseURLTest.php
  50. 76
      tests/src/Util/Config/ConfigFileLoaderTest.php
  51. 20
      tests/src/Util/CryptoTest.php
  52. 2
      tests/src/Util/DateTimeFormatTest.php
  53. 32
      tests/src/Util/EMailerTest.php
  54. 26
      tests/src/Util/Emailer/MailBuilderTest.php
  55. 4
      tests/src/Util/Emailer/SystemMailBuilderTest.php
  56. 2
      tests/src/Util/HTTPSignatureTest.php
  57. 34
      tests/src/Util/JsonLDTest.php
  58. 24
      tests/src/Util/Logger/AbstractLoggerTest.php
  59. 4
      tests/src/Util/Logger/StreamLoggerTest.php
  60. 8
      tests/src/Util/Logger/WorkerLoggerTest.php
  61. 20
      tests/src/Util/ProfilerTest.php
  62. 28
      tests/src/Util/StringsTest.php
  63. 8
      tests/src/Util/XmlTest.php

42
tests/functional/DependencyCheckTest.php

@ -19,7 +19,7 @@
*
*/
namespace functional;
namespace Friendica\Test\functional;
use Dice\Dice;
use Friendica\App;
@ -63,8 +63,8 @@ class dependencyCheck extends TestCase
/** @var BasePath $basePath */
$basePath = $this->dice->create(BasePath::class, [$this->root->url()]);
$this->assertInstanceOf(BasePath::class, $basePath);
$this->assertEquals($this->root->url(), $basePath->getPath());
self::assertInstanceOf(BasePath::class, $basePath);
self::assertEquals($this->root->url(), $basePath->getPath());
}
/**
@ -76,14 +76,14 @@ class dependencyCheck extends TestCase
/** @var ConfigFileLoader $configFileLoader */
$configFileLoader = $this->dice->create(ConfigFileLoader::class);
$this->assertInstanceOf(ConfigFileLoader::class, $configFileLoader);
self::assertInstanceOf(ConfigFileLoader::class, $configFileLoader);
$configCache = new Cache();
$configFileLoader->setupCache($configCache);
$this->assertNotEmpty($configCache->getAll());
$this->assertArrayHasKey('database', $configCache->getAll());
$this->assertArrayHasKey('system', $configCache->getAll());
self::assertNotEmpty($configCache->getAll());
self::assertArrayHasKey('database', $configCache->getAll());
self::assertArrayHasKey('system', $configCache->getAll());
}
/**
@ -94,7 +94,7 @@ class dependencyCheck extends TestCase
/** @var Profiler $profiler */
$profiler = $this->dice->create(Profiler::class);
$this->assertInstanceOf(Profiler::class, $profiler);
self::assertInstanceOf(Profiler::class, $profiler);
$configCache = new Cache([
'system' => [
@ -109,8 +109,8 @@ class dependencyCheck extends TestCase
$this->dice = new Dice();
$profiler = $this->dice->create(Profiler::class, [$configCache]);
$this->assertInstanceOf(Profiler::class, $profiler);
$this->assertTrue($profiler->isRendertime());
self::assertInstanceOf(Profiler::class, $profiler);
self::assertTrue($profiler->isRendertime());
}
public function testDatabase()
@ -118,8 +118,8 @@ class dependencyCheck extends TestCase
/** @var Database $database */
$database = $this->dice->create(Database::class);
$this->assertInstanceOf(Database::class, $database);
$this->assertTrue($database->connected());
self::assertInstanceOf(Database::class, $database);
self::assertTrue($database->connected());
}
public function testAppMode()
@ -127,9 +127,9 @@ class dependencyCheck extends TestCase
/** @var App\Mode $mode */
$mode = $this->dice->create(App\Mode::class);
$this->assertInstanceOf(App\Mode::class, $mode);
self::assertInstanceOf(App\Mode::class, $mode);
$this->assertTrue($mode->isNormal());
self::assertTrue($mode->isNormal());
}
public function testConfiguration()
@ -137,9 +137,9 @@ class dependencyCheck extends TestCase
/** @var IConfig $config */
$config = $this->dice->create(IConfig::class);
$this->assertInstanceOf(IConfig::class, $config);
self::assertInstanceOf(IConfig::class, $config);
$this->assertNotEmpty($config->get('database', 'username'));
self::assertNotEmpty($config->get('database', 'username'));
}
public function testLogger()
@ -147,7 +147,7 @@ class dependencyCheck extends TestCase
/** @var LoggerInterface $logger */
$logger = $this->dice->create(LoggerInterface::class, ['test']);
$this->assertInstanceOf(LoggerInterface::class, $logger);
self::assertInstanceOf(LoggerInterface::class, $logger);
}
public function testDevLogger()
@ -159,7 +159,7 @@ class dependencyCheck extends TestCase
/** @var LoggerInterface $logger */
$logger = $this->dice->create('$devLogger', ['dev']);
$this->assertInstanceOf(LoggerInterface::class, $logger);
self::assertInstanceOf(LoggerInterface::class, $logger);
}
public function testCache()
@ -167,7 +167,7 @@ class dependencyCheck extends TestCase
/** @var ICache $cache */
$cache = $this->dice->create(ICache::class);
$this->assertInstanceOf(ICache::class, $cache);
self::assertInstanceOf(ICache::class, $cache);
}
public function testMemoryCache()
@ -176,7 +176,7 @@ class dependencyCheck extends TestCase
$cache = $this->dice->create(IMemoryCache::class);
// We need to check "just" ICache, because the default Cache is DB-Cache, which isn't a memorycache
$this->assertInstanceOf(ICache::class, $cache);
self::assertInstanceOf(ICache::class, $cache);
}
public function testLock()
@ -184,6 +184,6 @@ class dependencyCheck extends TestCase
/** @var ILock $cache */
$lock = $this->dice->create(ILock::class);
$this->assertInstanceOf(ILock::class, $lock);
self::assertInstanceOf(ILock::class, $lock);
}
}

600
tests/legacy/ApiTest.php

File diff suppressed because it is too large

28
tests/src/App/ArgumentsTest.php

@ -28,11 +28,11 @@ class ArgumentsTest extends TestCase
{
private function assertArguments(array $assert, App\Arguments $arguments)
{
$this->assertEquals($assert['queryString'], $arguments->getQueryString());
$this->assertEquals($assert['command'], $arguments->getCommand());
$this->assertEquals($assert['argv'], $arguments->getArgv());
$this->assertEquals($assert['argc'], $arguments->getArgc());
$this->assertCount($assert['argc'], $arguments->getArgv());
self::assertEquals($assert['queryString'], $arguments->getQueryString());
self::assertEquals($assert['command'], $arguments->getCommand());
self::assertEquals($assert['argv'], $arguments->getArgv());
self::assertEquals($assert['argc'], $arguments->getArgc());
self::assertCount($assert['argc'], $arguments->getArgv());
}
/**
@ -42,7 +42,7 @@ class ArgumentsTest extends TestCase
{
$arguments = new App\Arguments();
$this->assertArguments([
self::assertArguments([
'queryString' => '',
'command' => '',
'argv' => [],
@ -177,7 +177,7 @@ class ArgumentsTest extends TestCase
$arguments = (new App\Arguments())
->determine($server, $get);
$this->assertArguments($assert, $arguments);
self::assertArguments($assert, $arguments);
}
/**
@ -191,13 +191,13 @@ class ArgumentsTest extends TestCase
->determine($server, $get);
for ($i = 0; $i < $arguments->getArgc(); $i++) {
$this->assertTrue($arguments->has($i));
$this->assertEquals($assert['argv'][$i], $arguments->get($i));
self::assertTrue($arguments->has($i));
self::assertEquals($assert['argv'][$i], $arguments->get($i));
}
$this->assertFalse($arguments->has($arguments->getArgc()));
$this->assertEmpty($arguments->get($arguments->getArgc()));
$this->assertEquals('default', $arguments->get($arguments->getArgc(), 'default'));
self::assertFalse($arguments->has($arguments->getArgc()));
self::assertEmpty($arguments->get($arguments->getArgc()));
self::assertEquals('default', $arguments->get($arguments->getArgc(), 'default'));
}
public function dataStripped()
@ -242,7 +242,7 @@ class ArgumentsTest extends TestCase
$arguments = (new App\Arguments())
->determine(['QUERY_STRING' => 'pagename=' . $command . $input,], ['pagename' => $command]);
$this->assertEquals($command . $assert, $arguments->getQueryString());
self::assertEquals($command . $assert, $arguments->getQueryString());
}
/**
@ -254,6 +254,6 @@ class ArgumentsTest extends TestCase
$argNew = $argument->determine([], []);
$this->assertNotSame($argument, $argNew);
self::assertNotSame($argument, $argNew);
}
}

72
tests/src/App/ModeTest.php

@ -66,26 +66,26 @@ class ModeTest extends MockedTest
public function testItEmpty()
{
$mode = new Mode();
$this->assertTrue($mode->isInstall());
$this->assertFalse($mode->isNormal());
self::assertTrue($mode->isInstall());
self::assertFalse($mode->isNormal());
}
public function testWithoutConfig()
{
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
$this->assertTrue($this->root->hasChild('config/local.config.php'));
self::assertTrue($this->root->hasChild('config/local.config.php'));
$this->delConfigFile('local.config.php');
$this->assertFalse($this->root->hasChild('config/local.config.php'));
self::assertFalse($this->root->hasChild('config/local.config.php'));
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
$this->assertTrue($mode->isInstall());
$this->assertFalse($mode->isNormal());
self::assertTrue($mode->isInstall());
self::assertFalse($mode->isNormal());
$this->assertFalse($mode->has(Mode::LOCALCONFIGPRESENT));
self::assertFalse($mode->has(Mode::LOCALCONFIGPRESENT));
}
public function testWithoutDatabase()
@ -96,11 +96,11 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
$this->assertFalse($mode->isNormal());
$this->assertTrue($mode->isInstall());
self::assertFalse($mode->isNormal());
self::assertTrue($mode->isInstall());
$this->assertTrue($mode->has(Mode::LOCALCONFIGPRESENT));
$this->assertFalse($mode->has(Mode::DBAVAILABLE));
self::assertTrue($mode->has(Mode::LOCALCONFIGPRESENT));
self::assertFalse($mode->has(Mode::DBAVAILABLE));
}
public function testWithoutDatabaseSetup()
@ -113,10 +113,10 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
$this->assertFalse($mode->isNormal());
$this->assertTrue($mode->isInstall());
self::assertFalse($mode->isNormal());
self::assertTrue($mode->isInstall());
$this->assertTrue($mode->has(Mode::LOCALCONFIGPRESENT));
self::assertTrue($mode->has(Mode::LOCALCONFIGPRESENT));
}
public function testWithMaintenanceMode()
@ -131,11 +131,11 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
$this->assertFalse($mode->isNormal());
$this->assertFalse($mode->isInstall());
self::assertFalse($mode->isNormal());
self::assertFalse($mode->isInstall());
$this->assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
$this->assertFalse($mode->has(Mode::MAINTENANCEDISABLED));
self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
self::assertFalse($mode->has(Mode::MAINTENANCEDISABLED));
}
public function testNormalMode()
@ -153,11 +153,11 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
$this->assertTrue($mode->isNormal());
$this->assertFalse($mode->isInstall());
self::assertTrue($mode->isNormal());
self::assertFalse($mode->isInstall());
$this->assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
$this->assertTrue($mode->has(Mode::MAINTENANCEDISABLED));
self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
self::assertTrue($mode->has(Mode::MAINTENANCEDISABLED));
}
/**
@ -178,11 +178,11 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
$this->assertTrue($mode->isNormal());
$this->assertFalse($mode->isInstall());
self::assertTrue($mode->isNormal());
self::assertFalse($mode->isInstall());
$this->assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
$this->assertTrue($mode->has(Mode::MAINTENANCEDISABLED));
self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
self::assertTrue($mode->has(Mode::MAINTENANCEDISABLED));
}
/**
@ -196,7 +196,7 @@ class ModeTest extends MockedTest
$modeNew = $mode->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
$this->assertNotSame($modeNew, $mode);
self::assertNotSame($modeNew, $mode);
}
/**
@ -210,7 +210,7 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
$this->assertTrue($mode->isBackend());
self::assertTrue($mode->isBackend());
}
/**
@ -224,7 +224,7 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect);
$this->assertTrue($mode->isBackend());
self::assertTrue($mode->isBackend());
}
/**
@ -238,7 +238,7 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect);
$this->assertFalse($mode->isBackend());
self::assertFalse($mode->isBackend());
}
/**
@ -256,7 +256,7 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
$this->assertTrue($mode->isAjax());
self::assertTrue($mode->isAjax());
}
/**
@ -270,7 +270,7 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
$this->assertFalse($mode->isAjax());
self::assertFalse($mode->isAjax());
}
/**
@ -286,8 +286,8 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
$this->assertTrue($mode->isMobile());
$this->assertTrue($mode->isTablet());
self::assertTrue($mode->isMobile());
self::assertTrue($mode->isTablet());
}
@ -304,7 +304,7 @@ class ModeTest extends MockedTest
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
$this->assertFalse($mode->isMobile());
$this->assertFalse($mode->isTablet());
self::assertFalse($mode->isMobile());
self::assertFalse($mode->isTablet());
}
}

14
tests/src/App/ModuleTest.php

@ -34,9 +34,9 @@ class ModuleTest extends DatabaseTest
{
private function assertModule(array $assert, App\Module $module)
{
$this->assertEquals($assert['isBackend'], $module->isBackend());
$this->assertEquals($assert['name'], $module->getName());
$this->assertEquals($assert['class'], $module->getClassName());
self::assertEquals($assert['isBackend'], $module->isBackend());
self::assertEquals($assert['name'], $module->getName());
self::assertEquals($assert['class'], $module->getClassName());
}
/**
@ -46,7 +46,7 @@ class ModuleTest extends DatabaseTest
{
$module = new App\Module();
$this->assertModule([
self::assertModule([
'isBackend' => false,
'name' => App\Module::DEFAULT,
'class' => App\Module::DEFAULT_CLASS,
@ -128,7 +128,7 @@ class ModuleTest extends DatabaseTest
{
$module = (new App\Module())->determineModule($args);
$this->assertModule($assert, $module);
self::assertModule($assert, $module);
}
public function dataModuleClass()
@ -185,7 +185,7 @@ class ModuleTest extends DatabaseTest
$module = (new App\Module($name))->determineClass(new App\Arguments('', $command), $router, $config);
$this->assertEquals($assert, $module->getClassName());
self::assertEquals($assert, $module->getClassName());
}
/**
@ -197,6 +197,6 @@ class ModuleTest extends DatabaseTest
$moduleNew = $module->determineModule(new App\Arguments());
$this->assertNotSame($moduleNew, $module);
self::assertNotSame($moduleNew, $module);
}
}

48
tests/src/App/RouterTest.php

@ -64,15 +64,15 @@ class RouterTest extends TestCase
$routeCollector->addRoute([Router::GET], '/variable/{var}', 'VariableModuleClassName');
$routeCollector->addRoute([Router::GET], '/optionalvariable[/{option}]', 'OptionalVariableModuleClassName');
$this->assertEquals('IndexModuleClassName', $router->getModuleClass('/'));
$this->assertEquals('TestModuleClassName', $router->getModuleClass('/test'));
$this->assertEquals('TestGetPostModuleClassName', $router->getModuleClass('/testgetpost'));
$this->assertEquals('TestSubModuleClassName', $router->getModuleClass('/test/sub'));
$this->assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional'));
$this->assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional/option'));
$this->assertEquals('VariableModuleClassName', $router->getModuleClass('/variable/123abc'));
$this->assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable'));
$this->assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable/123abc'));
self::assertEquals('IndexModuleClassName', $router->getModuleClass('/'));
self::assertEquals('TestModuleClassName', $router->getModuleClass('/test'));
self::assertEquals('TestGetPostModuleClassName', $router->getModuleClass('/testgetpost'));
self::assertEquals('TestSubModuleClassName', $router->getModuleClass('/test/sub'));
self::assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional'));
self::assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional/option'));
self::assertEquals('VariableModuleClassName', $router->getModuleClass('/variable/123abc'));
self::assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable'));
self::assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable/123abc'));
}
public function testPostModuleClass()
@ -88,15 +88,15 @@ class RouterTest extends TestCase
$routeCollector->addRoute([Router::POST], '/variable/{var}', 'VariableModuleClassName');
$routeCollector->addRoute([Router::POST], '/optionalvariable[/{option}]', 'OptionalVariableModuleClassName');
$this->assertEquals('IndexModuleClassName', $router->getModuleClass('/'));
$this->assertEquals('TestModuleClassName', $router->getModuleClass('/test'));
$this->assertEquals('TestGetPostModuleClassName', $router->getModuleClass('/testgetpost'));
$this->assertEquals('TestSubModuleClassName', $router->getModuleClass('/test/sub'));
$this->assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional'));
$this->assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional/option'));
$this->assertEquals('VariableModuleClassName', $router->getModuleClass('/variable/123abc'));
$this->assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable'));
$this->assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable/123abc'));
self::assertEquals('IndexModuleClassName', $router->getModuleClass('/'));
self::assertEquals('TestModuleClassName', $router->getModuleClass('/test'));
self::assertEquals('TestGetPostModuleClassName', $router->getModuleClass('/testgetpost'));
self::assertEquals('TestSubModuleClassName', $router->getModuleClass('/test/sub'));
self::assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional'));
self::assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional/option'));
self::assertEquals('VariableModuleClassName', $router->getModuleClass('/variable/123abc'));
self::assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable'));
self::assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable/123abc'));
}
public function testGetModuleClassNotFound()
@ -205,10 +205,10 @@ class RouterTest extends TestCase
$this->cache
))->loadRoutes($routes);
$this->assertEquals(Module\Home::class, $router->getModuleClass('/'));
$this->assertEquals(Module\Friendica::class, $router->getModuleClass('/group/route'));
$this->assertEquals(Module\Xrd::class, $router->getModuleClass('/group2/group3/route'));
$this->assertEquals(Module\Profile\Index::class, $router->getModuleClass('/double'));
self::assertEquals(Module\Home::class, $router->getModuleClass('/'));
self::assertEquals(Module\Friendica::class, $router->getModuleClass('/group/route'));
self::assertEquals(Module\Xrd::class, $router->getModuleClass('/group2/group3/route'));
self::assertEquals(Module\Profile\Index::class, $router->getModuleClass('/double'));
}
/**
@ -221,7 +221,7 @@ class RouterTest extends TestCase
], '', $this->l10n, $this->cache))->loadRoutes($routes);
// Don't find GET
$this->assertEquals(Module\WellKnown\NodeInfo::class, $router->getModuleClass('/post/it'));
$this->assertEquals(Module\Profile\Index::class, $router->getModuleClass('/double'));
self::assertEquals(Module\WellKnown\NodeInfo::class, $router->getModuleClass('/post/it'));
self::assertEquals(Module\Profile\Index::class, $router->getModuleClass('/double'));
}
}

128
tests/src/Console/AutomaticInstallationConsoleTest.php

@ -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);
$this->assertConfigEntry('config', 'admin_email', $assertion);
$this->assertConfigEntry('config', 'php_path', trim(shell_exec('which php')));
$this->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('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);
self::assertConfigEntry('config', 'admin_email', $assertion);
self::assertConfigEntry('config', 'php_path', trim(shell_exec('which php')));
self::assertConfigEntry('config', 'hostname', $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);
}
}

16
tests/src/Console/ConfigConsoleTest.php

@ -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);
}
}

20
tests/src/Console/LockConsoleTest.php

@ -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);
}
}

24
tests/src/Console/ServerBlockConsoleTest.php

@ -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);
}
}

4
tests/src/Content/PageInfoTest.php

@ -87,7 +87,7 @@ class PageInfoTest extends MockedTest
*/
public function testGetRelevantUrlFromBody($expected, string $body, bool $searchNakedUrls = false)
{
$this->assertSame($expected, PageInfoMock::getRelevantUrlFromBody($body, $searchNakedUrls));
self::assertSame($expected, PageInfoMock::getRelevantUrlFromBody($body, $searchNakedUrls));
}
public function dataStripTrailingUrlFromBody()
@ -135,6 +135,6 @@ class PageInfoTest extends MockedTest
*/
public function testStripTrailingUrlFromBody(string $expected, string $body, string $url)
{
$this->assertSame($expected, PageInfoMock::stripTrailingUrlFromBody($body, $url));
self::assertSame($expected, PageInfoMock::stripTrailingUrlFromBody($body, $url));
}
}

2
tests/src/Content/SmiliesTest.php

@ -62,6 +62,6 @@ class SmiliesTest extends MockedTest
public function testReplaceFromArray($text, $smilies, $expected)
{
$output = Smilies::replaceFromArray($text, $smilies);
$this->assertEquals($expected, $output);
self::assertEquals($expected, $output);
}
}

2
tests/src/Content/Text/BBCode/VideoTest.php

@ -57,6 +57,6 @@ class VideoTest extends MockedTest
{
$bbCodeVideo = new Video();
$this->assertEquals($assert, $bbCodeVideo->transform($input));
self::assertEquals($assert, $bbCodeVideo->transform($input));
}
}

8
tests/src/Content/Text/BBCodeTest.php

@ -169,9 +169,9 @@ class BBCodeTest extends MockedTest
$output = BBCode::convert($data);
$assert = '<a href="' . $data . '" target="_blank" rel="noopener noreferrer">' . $data . '</a>';
if ($assertHTML) {
$this->assertEquals($assert, $output);
self::assertEquals($assert, $output);
} else {
$this->assertNotEquals($assert, $output);
self::assertNotEquals($assert, $output);
}
}
@ -264,7 +264,7 @@ class BBCodeTest extends MockedTest
{
$actual = BBCode::convert($text, $try_oembed, $simpleHtml, $forPlaintext);
$this->assertEquals($expectedHtml, $actual);
self::assertEquals($expectedHtml, $actual);
}
public function dataBBCodesToMarkdown()
@ -299,6 +299,6 @@ class BBCodeTest extends MockedTest
{
$actual = BBCode::toMarkdown($text, $for_diaspora);
$this->assertEquals($expected, $actual);
self::assertEquals($expected, $actual);
}
}

4
tests/src/Content/Text/HTMLTest.php

@ -67,7 +67,7 @@ class HTMLTest extends MockedTest
{
$output = HTML::toPlaintext($input, 0);
$this->assertEquals($expected, $output);
self::assertEquals($expected, $output);
}
public function dataHTMLText()
@ -97,6 +97,6 @@ class HTMLTest extends MockedTest
{
$actual = HTML::toBBCode($html);
$this->assertEquals($expectedBBCode, $actual);
self::assertEquals($expectedBBCode, $actual);
}
}

4
tests/src/Content/Text/MarkdownTest.php

@ -67,7 +67,7 @@ class MarkdownTest extends MockedTest
{
$output = Markdown::convert($input);
$this->assertEquals($expected, $output);
self::assertEquals($expected, $output);
}
public function dataMarkdownText()
@ -93,6 +93,6 @@ class MarkdownTest extends MockedTest
{
$actual = Markdown::toBBCode($html);
$this->assertEquals($expectedBBCode, $actual);
self::assertEquals($expectedBBCode, $actual);
}
}

52
tests/src/Core/Cache/CacheTest.php

@ -97,25 +97,25 @@ abstract class CacheTest extends MockedTest
*/
function testSimple($value1, $value2)
{
$this->assertNull($this->instance->get('value1'));
self::assertNull($this->instance->get('value1'));
$this->instance->set('value1', $value1);
$received = $this->instance->get('value1');
$this->assertEquals($value1, $received, 'Value received from cache not equal to the original');
self::assertEquals($value1, $received, 'Value received from cache not equal to the original');
$this->instance->set('value1', $value2);
$received = $this->instance->get('value1');
$this->assertEquals($value2, $received, 'Value not overwritten by second set');
self::assertEquals($value2, $received, 'Value not overwritten by second set');
$this->instance->set('value2', $value1);
$received2 = $this->instance->get('value2');
$this->assertEquals($value2, $received, 'Value changed while setting other variable');
$this->assertEquals($value1, $received2, 'Second value not equal to original');
self::assertEquals($value2, $received, 'Value changed while setting other variable');
self::assertEquals($value1, $received2, 'Second value not equal to original');
$this->assertNull($this->instance->get('not_set'), 'Unset value not equal to null');
self::assertNull($this->instance->get('not_set'), 'Unset value not equal to null');
$this->assertTrue($this->instance->delete('value1'));
$this->assertNull($this->instance->get('value1'));
self::assertTrue($this->instance->delete('value1'));
self::assertNull($this->instance->get('value1'));
}
/**
@ -135,7 +135,7 @@ abstract class CacheTest extends MockedTest
$this->instance->set('2_value1', $value3);
$this->instance->set('3_value1', $value4);
$this->assertEquals([
self::assertEquals([
'1_value1' => $value1,
'1_value2' => $value2,
'2_value1' => $value3,
@ -147,9 +147,9 @@ abstract class CacheTest extends MockedTest
'3_value1' => $this->instance->get('3_value1'),
]);
$this->assertTrue($this->instance->clear());
self::assertTrue($this->instance->clear());
$this->assertEquals([
self::assertEquals([
'1_value1' => $value1,
'1_value2' => $value2,
'2_value1' => $value3,
@ -161,9 +161,9 @@ abstract class CacheTest extends MockedTest
'3_value1' => $this->instance->get('3_value1'),
]);
$this->assertTrue($this->instance->clear(false));
self::assertTrue($this->instance->clear(false));
$this->assertEquals([
self::assertEquals([
'1_value1' => null,
'1_value2' => null,
'2_value3' => null,
@ -183,16 +183,16 @@ abstract class CacheTest extends MockedTest
{
$this->markTestSkipped('taking too much time without mocking');
$this->assertNull($this->instance->get('value1'));
self::assertNull($this->instance->get('value1'));
$value = 'foobar';
$this->instance->set('value1', $value, 1);
$received = $this->instance->get('value1');
$this->assertEquals($value, $received, 'Value received from cache not equal to the original');
self::assertEquals($value, $received, 'Value received from cache not equal to the original');
sleep(2);
$this->assertNull($this->instance->get('value1'));
self::assertNull($this->instance->get('value1'));
}
/**
@ -206,7 +206,7 @@ abstract class CacheTest extends MockedTest
{
$this->instance->set('val', $data);
$received = $this->instance->get('val');
$this->assertEquals($data, $received, 'Value type changed from ' . gettype($data) . ' to ' . gettype($received));
self::assertEquals($data, $received, 'Value type changed from ' . gettype($data) . ' to ' . gettype($received));
}
/**
@ -220,20 +220,20 @@ abstract class CacheTest extends MockedTest
*/
public function testGetAllKeys($value1, $value2, $value3)
{
$this->assertTrue($this->instance->set('value1', $value1));
$this->assertTrue($this->instance->set('value2', $value2));
$this->assertTrue($this->instance->set('test_value3', $value3));
self::assertTrue($this->instance->set('value1', $value1));
self::assertTrue($this->instance->set('value2', $value2));
self::assertTrue($this->instance->set('test_value3', $value3));
$list = $this->instance->getAllKeys();
$this->assertContains('value1', $list);
$this->assertContains('value2', $list);
$this->assertContains('test_value3', $list);
self::assertContains('value1', $list);
self::assertContains('value2', $list);
self::assertContains('test_value3', $list);
$list = $this->instance->getAllKeys('test');
$this->assertContains('test_value3', $list);
$this->assertNotContains('value1', $list);
$this->assertNotContains('value2', $list);
self::assertContains('test_value3', $list);
self::assertNotContains('value1', $list);
self::assertNotContains('value2', $list);
}
}

38
tests/src/Core/Cache/MemoryCacheTest.php

@ -45,15 +45,15 @@ abstract class MemoryCacheTest extends CacheTest
*/
function testCompareSet($value1, $value2)
{
$this->assertNull($this->instance->get('value1'));
self::assertNull($this->instance->get('value1'));
$this->instance->add('value1', $value1);
$received = $this->instance->get('value1');
$this->assertEquals($value1, $received, 'Value received from cache not equal to the original');
self::assertEquals($value1, $received, 'Value received from cache not equal to the original');
$this->instance->compareSet('value1', $value1, $value2);
$received = $this->instance->get('value1');
$this->assertEquals($value2, $received, 'Value not overwritten by compareSet');
self::assertEquals($value2, $received, 'Value not overwritten by compareSet');
}
/**
@ -62,16 +62,16 @@ abstract class MemoryCacheTest extends CacheTest
*/
function testNegativeCompareSet($value1, $value2)
{
$this->assertNull($this->instance->get('value1'));
self::assertNull($this->instance->get('value1'));
$this->instance->add('value1', $value1);
$received = $this->instance->get('value1');
$this->assertEquals($value1, $received, 'Value received from cache not equal to the original');
self::assertEquals($value1, $received, 'Value received from cache not equal to the original');
$this->instance->compareSet('value1', 'wrong', $value2);
$received = $this->instance->get('value1');
$this->assertNotEquals($value2, $received, 'Value was wrongly overwritten by compareSet');
$this->assertEquals($value1, $received, 'Value was wrongly overwritten by any other value');
self::assertNotEquals($value2, $received, 'Value was wrongly overwritten by compareSet');
self::assertEquals($value1, $received, 'Value was wrongly overwritten by any other value');
}
/**
@ -80,13 +80,13 @@ abstract class MemoryCacheTest extends CacheTest
*/
function testCompareDelete($data)
{
$this->assertNull($this->instance->get('value1'));
self::assertNull($this->instance->get('value1'));
$this->instance->add('value1', $data);
$received = $this->instance->get('value1');
$this->assertEquals($data, $received, 'Value received from cache not equal to the original');
self::assertEquals($data, $received, 'Value received from cache not equal to the original');
$this->instance->compareDelete('value1', $data);
$this->assertNull($this->instance->get('value1'), 'Value was not deleted by compareDelete');
self::assertNull($this->instance->get('value1'), 'Value was not deleted by compareDelete');
}
/**
@ -95,16 +95,16 @@ abstract class MemoryCacheTest extends CacheTest
*/
function testNegativeCompareDelete($data)
{
$this->assertNull($this->instance->get('value1'));
self::assertNull($this->instance->get('value1'));
$this->instance->add('value1', $data);
$received = $this->instance->get('value1');
$this->assertEquals($data, $received, 'Value received from cache not equal to the original');
self::assertEquals($data, $received, 'Value received from cache not equal to the original');
$this->instance->compareDelete('value1', 'wrong');
$this->assertNotNull($this->instance->get('value1'), 'Value was wrongly compareDeleted');
self::assertNotNull($this->instance->get('value1'), 'Value was wrongly compareDeleted');
$this->instance->compareDelete('value1', $data);
$this->assertNull($this->instance->get('value1'), 'Value was wrongly NOT deleted by compareDelete');
self::assertNull($this->instance->get('value1'), 'Value was wrongly NOT deleted by compareDelete');
}
/**
@ -113,19 +113,19 @@ abstract class MemoryCacheTest extends CacheTest
*/
function testAdd($value1, $value2)
{
$this->assertNull($this->instance->get('value1'));
self::assertNull($this->instance->get('value1'));
$this->instance->add('value1', $value1);
$this->instance->add('value1', $value2);
$received = $this->instance->get('value1');
$this->assertNotEquals($value2, $received, 'Value was wrongly overwritten by add');
$this->assertEquals($value1, $received, 'Value was wrongly overwritten by any other value');
self::assertNotEquals($value2, $received, 'Value was wrongly overwritten by add');
self::assertEquals($value1, $received, 'Value was wrongly overwritten by any other value');
$this->instance->delete('value1');
$this->instance->add('value1', $value2);
$received = $this->instance->get('value1');
$this->assertEquals($value2, $received, 'Value was not overwritten by add');
$this->assertNotEquals($value1, $received, 'Value was not overwritten by any other value');
self::assertEquals($value2, $received, 'Value was not overwritten by add');
self::assertNotEquals($value1, $received, 'Value was not overwritten by any other value');
}
}

70
tests/src/Core/Config/CacheTest.php

@ -52,7 +52,7 @@ class CacheTest extends MockedTest
{
foreach ($data as $cat => $values) {
foreach ($values as $key => $value) {
$this->assertEquals($data[$cat][$key], $configCache->get($cat, $key));
self::assertEquals($data[$cat][$key], $configCache->get($cat, $key));
}
}
}
@ -66,7 +66,7 @@ class CacheTest extends MockedTest
$configCache = new Cache();
$configCache->load($data);
$this->assertConfigValues($data, $configCache);
self::assertConfigValues($data, $configCache);
}
/**
@ -87,26 +87,26 @@ class CacheTest extends MockedTest
// doesn't override - Low Priority due Config file
$configCache->load($override, Cache::SOURCE_FILE);
$this->assertConfigValues($data, $configCache);
self::assertConfigValues($data, $configCache);
// override the value - High Prio due Server Env
$configCache->load($override, Cache::SOURCE_ENV);
$this->assertEquals($override['system']['test'], $configCache->get('system', 'test'));
$this->assertEquals($override['system']['boolTrue'], $configCache->get('system', 'boolTrue'));
self::assertEquals($override['system']['test'], $configCache->get('system', 'test'));
self::assertEquals($override['system']['boolTrue'], $configCache->get('system', 'boolTrue'));
// Don't overwrite server ENV variables - even in load mode
$configCache->load($data, Cache::SOURCE_DB);
$this->assertEquals($override['system']['test'], $configCache->get('system', 'test'));
$this->assertEquals($override['system']['boolTrue'], $configCache->get('system', 'boolTrue'));
self::assertEquals($override['system']['test'], $configCache->get('system', 'test'));
self::assertEquals($override['system']['boolTrue'], $configCache->get('system', 'boolTrue'));
// Overwrite ENV variables with ENV variables
$configCache->load($data, Cache::SOURCE_ENV);
$this->assertConfigValues($data, $configCache);
$this->assertNotEquals($override['system']['test'], $configCache->get('system', 'test'));
$this->assertNotEquals($override['system']['boolTrue'], $configCache->get('system', 'boolTrue'));
self::assertConfigValues($data, $configCache);
self::assertNotEquals($override['system']['test'], $configCache->get('system', 'test'));
self::assertNotEquals($override['system']['boolTrue'], $configCache->get('system', 'boolTrue'));
}
/**
@ -118,15 +118,15 @@ class CacheTest extends MockedTest
// empty dataset
$configCache->load([]);
$this->assertEmpty($configCache->getAll());
self::assertEmpty($configCache->getAll());
// wrong dataset
$configCache->load(['system' => 'not_array']);
$this->assertEmpty($configCache->getAll());
self::assertEmpty($configCache->getAll());
// incomplete dataset (key is integer ID of the array)
$configCache->load(['system' => ['value']]);
$this->assertEquals('value', $configCache->get('system', 0));
self::assertEquals('value', $configCache->get('system', 0));
}
/**
@ -140,8 +140,8 @@ class CacheTest extends MockedTest
$all = $configCache->getAll();
$this->assertContains($data['system'], $all);
$this->assertContains($data['config'], $all);
self::assertContains($data['system'], $all);
self::assertContains($data['config'], $all);
}
/**
@ -158,7 +158,7 @@ class CacheTest extends MockedTest
}
}
$this->assertConfigValues($data, $configCache);
self::assertConfigValues($data, $configCache);
}
/**
@ -168,7 +168,7 @@ class CacheTest extends MockedTest
{
$configCache = new Cache();
$this->assertNull($configCache->get('something', 'value'));
self::assertNull($configCache->get('something', 'value'));
}
/**
@ -186,13 +186,13 @@ class CacheTest extends MockedTest
],
]);
$this->assertEquals([
self::assertEquals([
'key1' => 'value1',
'key2' => 'value2',
], $configCache->get('system'));
// explicit null as key
$this->assertEquals([
self::assertEquals([
'key1' => 'value1',
'key2' => 'value2',
], $configCache->get('system', null));
@ -212,7 +212,7 @@ class CacheTest extends MockedTest