*
*/
-namespace functional;
+namespace Friendica\Test\functional;
use Dice\Dice;
use Friendica\App;
/** @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());
}
/**
/** @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());
}
/**
/** @var Profiler $profiler */
$profiler = $this->dice->create(Profiler::class);
- $this->assertInstanceOf(Profiler::class, $profiler);
+ self::assertInstanceOf(Profiler::class, $profiler);
$configCache = new Cache([
'system' => [
$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()
/** @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()
/** @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()
/** @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()
/** @var LoggerInterface $logger */
$logger = $this->dice->create(LoggerInterface::class, ['test']);
- $this->assertInstanceOf(LoggerInterface::class, $logger);
+ self::assertInstanceOf(LoggerInterface::class, $logger);
}
public function testDevLogger()
/** @var LoggerInterface $logger */
$logger = $this->dice->create('$devLogger', ['dev']);
- $this->assertInstanceOf(LoggerInterface::class, $logger);
+ self::assertInstanceOf(LoggerInterface::class, $logger);
}
public function testCache()
/** @var ICache $cache */
$cache = $this->dice->create(ICache::class);
- $this->assertInstanceOf(ICache::class, $cache);
+ self::assertInstanceOf(ICache::class, $cache);
}
public function testMemoryCache()
$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()
/** @var ILock $cache */
$lock = $this->dice->create(ILock::class);
- $this->assertInstanceOf(ILock::class, $lock);
+ self::assertInstanceOf(ILock::class, $lock);
}
}
*/
private function assertSelfUser(array $user)
{
- $this->assertEquals($this->selfUser['id'], $user['uid']);
- $this->assertEquals($this->selfUser['id'], $user['cid']);
- $this->assertEquals(1, $user['self']);
- $this->assertEquals('DFRN', $user['location']);
- $this->assertEquals($this->selfUser['name'], $user['name']);
- $this->assertEquals($this->selfUser['nick'], $user['screen_name']);
- $this->assertEquals('dfrn', $user['network']);
- $this->assertTrue($user['verified']);
+ self::assertEquals($this->selfUser['id'], $user['uid']);
+ self::assertEquals($this->selfUser['id'], $user['cid']);
+ self::assertEquals(1, $user['self']);
+ self::assertEquals('DFRN', $user['location']);
+ self::assertEquals($this->selfUser['name'], $user['name']);
+ self::assertEquals($this->selfUser['nick'], $user['screen_name']);
+ self::assertEquals('dfrn', $user['network']);
+ self::assertTrue($user['verified']);
}
/**
*/
private function assertOtherUser(array $user)
{
- $this->assertEquals($this->otherUser['id'], $user['id']);
- $this->assertEquals($this->otherUser['id'], $user['id_str']);
- $this->assertEquals(0, $user['self']);
- $this->assertEquals($this->otherUser['name'], $user['name']);
- $this->assertEquals($this->otherUser['nick'], $user['screen_name']);
- $this->assertFalse($user['verified']);
+ self::assertEquals($this->otherUser['id'], $user['id']);
+ self::assertEquals($this->otherUser['id'], $user['id_str']);
+ self::assertEquals(0, $user['self']);
+ self::assertEquals($this->otherUser['name'], $user['name']);
+ self::assertEquals($this->otherUser['nick'], $user['screen_name']);
+ self::assertFalse($user['verified']);
}
/**
*/
private function assertStatus(array $status)
{
- $this->assertInternalType('string', $status['text']);
- $this->assertInternalType('int', $status['id']);
+ self::assertInternalType('string', $status['text']);
+ self::assertInternalType('int', $status['id']);
// We could probably do more checks here.
}
*/
private function assertList(array $list)
{
- $this->assertInternalType('string', $list['name']);
- $this->assertInternalType('int', $list['id']);
- $this->assertInternalType('string', $list['id_str']);
- $this->assertContains($list['mode'], ['public', 'private']);
+ self::assertInternalType('string', $list['name']);
+ self::assertInternalType('int', $list['id']);
+ self::assertInternalType('string', $list['id_str']);
+ self::assertContains($list['mode'], ['public', 'private']);
// We could probably do more checks here.
}
*/
private function assertXml($result, $root_element)
{
- $this->assertStringStartsWith('<?xml version="1.0"?>', $result);
- $this->assertContains('<' . $root_element, $result);
+ self::assertStringStartsWith('<?xml version="1.0"?>', $result);
+ self::assertContains('<' . $root_element, $result);
// We could probably do more checks here.
}
*/
public function testApiUser()
{
- $this->assertEquals($this->selfUser['id'], api_user());
+ self::assertEquals($this->selfUser['id'], api_user());
}
/**
public function testApiUserWithUnallowedUser()
{
$_SESSION = ['allow_api' => false];
- $this->assertEquals(false, api_user());
+ self::assertEquals(false, api_user());
}
/**
*/
public function testApiSource()
{
- $this->assertEquals('api', api_source());
+ self::assertEquals('api', api_source());
}
/**
public function testApiSourceWithTwidere()
{
$_SERVER['HTTP_USER_AGENT'] = 'Twidere';
- $this->assertEquals('Twidere', api_source());
+ self::assertEquals('Twidere', api_source());
}
/**
public function testApiSourceWithGet()
{
$_GET['source'] = 'source_name';
- $this->assertEquals('source_name', api_source());
+ self::assertEquals('source_name', api_source());
}
/**
*/
public function testApiDate()
{
- $this->assertEquals('Wed Oct 10 00:00:00 +0000 1990', api_date('1990-10-10'));
+ self::assertEquals('Wed Oct 10 00:00:00 +0000 1990', api_date('1990-10-10'));
}
/**
public function testApiRegisterFunc()
{
global $API;
- $this->assertNull(
+ self::assertNull(
api_register_func(
'api_path',
function () {
'method'
)
);
- $this->assertTrue($API['api_path']['auth']);
- $this->assertEquals('method', $API['api_path']['method']);
- $this->assertTrue(is_callable($API['api_path']['func']));
+ self::assertTrue($API['api_path']['auth']);
+ self::assertEquals('method', $API['api_path']['method']);
+ self::assertTrue(is_callable($API['api_path']['func']));
}
/**
*/
public function testApiCheckMethod()
{
- $this->assertFalse(api_check_method('method'));
+ self::assertFalse(api_check_method('method'));
}
/**
public function testApiCheckMethodWithCorrectMethod()
{
$_SERVER['REQUEST_METHOD'] = 'method';
- $this->assertTrue(api_check_method('method'));
+ self::assertTrue(api_check_method('method'));
}
/**
*/
public function testApiCheckMethodWithWildcard()
{
- $this->assertTrue(api_check_method('*'));
+ self::assertTrue(api_check_method('*'));
}
/**
$args = DI::args()->determine($_SERVER, $_GET);
- $this->assertEquals(
+ self::assertEquals(
'callback_name(["some_data"])',
api_call($this->app, $args)
);
'network' => ['some_function' => 200]
];
- $this->assertEquals(
+ self::assertEquals(
'["some_data"]',
api_call($this->app, $args)
);
$args = DI::args()->determine($_SERVER, $_GET);
- $this->assertEquals(
+ self::assertEquals(
'{"status":{"error":"Internal Server Error","code":"500 Internal Server Error","request":"api_path"}}',
api_call($this->app, $args)
);
*/
public function testApiCallWithUninplementedApi()
{
- $this->assertEquals(
+ self::assertEquals(
'{"status":{"error":"Not Implemented","code":"501 Not Implemented","request":""}}',
api_call($this->app)
);
$args = DI::args()->determine($_SERVER, $_GET);
- $this->assertEquals(
+ self::assertEquals(
'["some_data"]',
api_call($this->app, $args)
);
$args = DI::args()->determine($_SERVER, $_GET);
- $this->assertEquals(
+ self::assertEquals(
'some_data',
api_call($this->app, $args)
);
$args = DI::args()->determine($_SERVER, $_GET);
- $this->assertEquals(
+ self::assertEquals(
'<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
'some_data',
api_call($this->app, $args)
$args = DI::args()->determine($_SERVER, $_GET);
- $this->assertEquals(
+ self::assertEquals(
'<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
'some_data',
api_call($this->app, $args)
$args = DI::args()->determine($_SERVER, $_GET);
- $this->assertEquals(
+ self::assertEquals(
'{"status":{"error":"Method Not Allowed","code":"405 Method Not Allowed","request":"api_path"}}',
api_call($this->app, $args)
);
$args = DI::args()->determine($_SERVER, $_GET);
- $this->assertEquals(
+ self::assertEquals(
'{"status":{"error":"This API requires login","code":"401 Unauthorized","request":"api_path"}}',
api_call($this->app, $args)
);
*/
public function testApiErrorWithJson()
{
- $this->assertEquals(
+ self::assertEquals(
'{"status":{"error":"error_message","code":"200 OK","request":""}}',
api_error('json', new HTTPException\OKException('error_message'), DI::args())
);
*/
public function testApiErrorWithXml()
{
- $this->assertEquals(
+ self::assertEquals(
'<?xml version="1.0"?>' . "\n" .
'<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
*/
public function testApiErrorWithRss()
{
- $this->assertEquals(
+ self::assertEquals(
'<?xml version="1.0"?>' . "\n" .
'<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
*/
public function testApiErrorWithAtom()
{
- $this->assertEquals(
+ self::assertEquals(
'<?xml version="1.0"?>' . "\n" .
'<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
{
$user_info = ['url' => 'user_url', 'lang' => 'en'];
$result = api_rss_extra($this->app, [], $user_info);
- $this->assertEquals($user_info, $result['$user']);
- $this->assertEquals($user_info['url'], $result['$rss']['alternate']);
- $this->assertArrayHasKey('self', $result['$rss']);
- $this->assertArrayHasKey('base', $result['$rss']);
- $this->assertArrayHasKey('updated', $result['$rss']);
- $this->assertArrayHasKey('atom_updated', $result['$rss']);
- $this->assertArrayHasKey('language', $result['$rss']);
- $this->assertArrayHasKey('logo', $result['$rss']);
+ self::assertEquals($user_info, $result['$user']);
+ self::assertEquals($user_info['url'], $result['$rss']['alternate']);
+ self::assertArrayHasKey('self', $result['$rss']);
+ self::assertArrayHasKey('base', $result['$rss']);
+ self::assertArrayHasKey('updated', $result['$rss']);
+ self::assertArrayHasKey('atom_updated', $result['$rss']);
+ self::assertArrayHasKey('language', $result['$rss']);
+ self::assertArrayHasKey('logo', $result['$rss']);
}
/**
public function testApiRssExtraWithoutUserInfo()
{
$result = api_rss_extra($this->app, [], null);
- $this->assertInternalType('array', $result['$user']);
- $this->assertArrayHasKey('alternate', $result['$rss']);
- $this->assertArrayHasKey('self', $result['$rss']);
- $this->assertArrayHasKey('base', $result['$rss']);
- $this->assertArrayHasKey('updated', $result['$rss']);
- $this->assertArrayHasKey('atom_updated', $result['$rss']);
- $this->assertArrayHasKey('language', $result['$rss']);
- $this->assertArrayHasKey('logo', $result['$rss']);
+ self::assertInternalType('array', $result['$user']);
+ self::assertArrayHasKey('alternate', $result['$rss']);
+ self::assertArrayHasKey('self', $result['$rss']);
+ self::assertArrayHasKey('base', $result['$rss']);
+ self::assertArrayHasKey('updated', $result['$rss']);
+ self::assertArrayHasKey('atom_updated', $result['$rss']);
+ self::assertArrayHasKey('language', $result['$rss']);
+ self::assertArrayHasKey('logo', $result['$rss']);
}
/**
*/
public function testApiUniqueIdToNurl()
{
- $this->assertFalse(api_unique_id_to_nurl($this->wrongUserId));
+ self::assertFalse(api_unique_id_to_nurl($this->wrongUserId));
}
/**
*/
public function testApiUniqueIdToNurlWithCorrectId()
{
- $this->assertEquals($this->otherUser['nurl'], api_unique_id_to_nurl($this->otherUser['id']));
+ self::assertEquals($this->otherUser['nurl'], api_unique_id_to_nurl($this->otherUser['id']));
}
/**
public function testApiGetUser()
{
$user = api_get_user($this->app);
- $this->assertSelfUser($user);
- $this->assertEquals('708fa0', $user['profile_sidebar_fill_color']);
- $this->assertEquals('6fdbe8', $user['profile_link_color']);
- $this->assertEquals('ededed', $user['profile_background_color']);
+ self::assertSelfUser($user);
+ self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
+ self::assertEquals('6fdbe8', $user['profile_link_color']);
+ self::assertEquals('ededed', $user['profile_background_color']);
}
/**
$pConfig = $this->dice->create(IPConfig::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
$user = api_get_user($this->app);
- $this->assertSelfUser($user);
- $this->assertEquals('708fa0', $user['profile_sidebar_fill_color']);
- $this->assertEquals('6fdbe8', $user['profile_link_color']);
- $this->assertEquals('ededed', $user['profile_background_color']);
+ self::assertSelfUser($user);
+ self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
+ self::assertEquals('6fdbe8', $user['profile_link_color']);
+ self::assertEquals('ededed', $user['profile_background_color']);
}
/**
$pConfig = $this->dice->create(IPConfig::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
$user = api_get_user($this->app);
- $this->assertSelfUser($user);
- $this->assertEquals('708fa0', $user['profile_sidebar_fill_color']);
- $this->assertEquals('6fdbe8', $user['profile_link_color']);
- $this->assertEquals('ededed', $user['profile_background_color']);
+ self::assertSelfUser($user);
+ self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
+ self::assertEquals('6fdbe8', $user['profile_link_color']);
+ self::assertEquals('ededed', $user['profile_background_color']);
}
/**
$pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
$pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
$user = api_get_user($this->app);
- $this->assertSelfUser($user);
- $this->assertEquals('123456', $user['profile_sidebar_fill_color']);
- $this->assertEquals('123456', $user['profile_link_color']);
- $this->assertEquals('123456', $user['profile_background_color']);
+ self::assertSelfUser($user);
+ self::assertEquals('123456', $user['profile_sidebar_fill_color']);
+ self::assertEquals('123456', $user['profile_link_color']);
+ self::assertEquals('123456', $user['profile_background_color']);
}
/**
$_SERVER['PHP_AUTH_USER'] = 'Test user';
$_SERVER['PHP_AUTH_PW'] = 'password';
$_SESSION['allow_api'] = false;
- $this->assertFalse(api_get_user($this->app));
+ self::assertFalse(api_get_user($this->app));
}
/**
public function testApiGetUserWithGetId()
{
$_GET['user_id'] = $this->otherUser['id'];
- $this->assertOtherUser(api_get_user($this->app));
+ self::assertOtherUser(api_get_user($this->app));
}
/**
public function testApiGetUserWithWrongGetId()
{
$_GET['user_id'] = $this->wrongUserId;
- $this->assertOtherUser(api_get_user($this->app));
+ self::assertOtherUser(api_get_user($this->app));
}
/**
public function testApiGetUserWithGetName()
{
$_GET['screen_name'] = $this->selfUser['nick'];
- $this->assertSelfUser(api_get_user($this->app));
+ self::assertSelfUser(api_get_user($this->app));
}
/**
public function testApiGetUserWithGetUrl()
{
$_GET['profileurl'] = $this->selfUser['nurl'];
- $this->assertSelfUser(api_get_user($this->app));
+ self::assertSelfUser(api_get_user($this->app));
}
/**
global $called_api;
$called_api = ['api_path'];
$this->app->argv[1] = $this->otherUser['id'] . '.json';
- $this->assertOtherUser(api_get_user($this->app));
+ self::assertOtherUser(api_get_user($this->app));
}
/**
{
global $called_api;
$called_api = ['api', 'api_path'];
- $this->assertSelfUser(api_get_user($this->app));
+ self::assertSelfUser(api_get_user($this->app));
}
/**
*/
public function testApiGetUserWithCorrectUser()
{
- $this->assertOtherUser(api_get_user($this->app, $this->otherUser['id']));
+ self::assertOtherUser(api_get_user($this->app, $this->otherUser['id']));
}
/**
*/
public function testApiGetUserWithWrongUser()
{
- $this->assertOtherUser(api_get_user($this->app, $this->wrongUserId));
+ self::assertOtherUser(api_get_user($this->app, $this->wrongUserId));
}
/**
*/
public function testApiGetUserWithZeroUser()
{
- $this->assertSelfUser(api_get_user($this->app, 0));
+ self::assertSelfUser(api_get_user($this->app, 0));
}
/**
public function testApiItemGetUser()
{
$users = api_item_get_user($this->app, []);
- $this->assertSelfUser($users[0]);
+ self::assertSelfUser($users[0]);
}
/**
public function testApiItemGetUserWithDifferentParent()
{
$users = api_item_get_user($this->app, ['thr-parent' => 'item_parent', 'uri' => 'item_uri']);
- $this->assertSelfUser($users[0]);
- $this->assertEquals($users[0], $users[1]);
+ self::assertSelfUser($users[0]);
+ self::assertEquals($users[0], $users[1]);
}
/**
public function testApiWalkRecursive()
{
$array = ['item1'];
- $this->assertEquals(
+ self::assertEquals(
$array,
api_walk_recursive(
$array,
public function testApiWalkRecursiveWithArray()
{
$array = [['item1'], ['item2']];
- $this->assertEquals(
+ self::assertEquals(
$array,
api_walk_recursive(
$array,
{
$item = true;
$key = '';
- $this->assertTrue(api_reformat_xml($item, $key));
- $this->assertEquals('true', $item);
+ self::assertTrue(api_reformat_xml($item, $key));
+ self::assertEquals('true', $item);
}
/**
{
$item = '';
$key = 'statusnet_api';
- $this->assertTrue(api_reformat_xml($item, $key));
- $this->assertEquals('statusnet:api', $key);
+ self::assertTrue(api_reformat_xml($item, $key));
+ self::assertEquals('statusnet:api', $key);
}
/**
{
$item = '';
$key = 'friendica_api';
- $this->assertTrue(api_reformat_xml($item, $key));
- $this->assertEquals('friendica:api', $key);
+ self::assertTrue(api_reformat_xml($item, $key));
+ self::assertEquals('friendica:api', $key);
}
/**
*/
public function testApiCreateXml()
{
- $this->assertEquals(
+ self::assertEquals(
'<?xml version="1.0"?>' . "\n" .
'<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
*/
public function testApiCreateXmlWithoutNamespaces()
{
- $this->assertEquals(
+ self::assertEquals(
'<?xml version="1.0"?>' . "\n" .
'<ok>' . "\n" .
' <data>some_data</data>' . "\n" .
public function testApiFormatData()
{
$data = ['some_data'];
- $this->assertEquals($data, api_format_data('root_element', 'json', $data));
+ self::assertEquals($data, api_format_data('root_element', 'json', $data));
}
/**
*/
public function testApiFormatDataWithXml()
{
- $this->assertEquals(
+ self::assertEquals(
'<?xml version="1.0"?>' . "\n" .
'<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
*/
public function testApiAccountVerifyCredentials()
{
- $this->assertArrayHasKey('user', api_account_verify_credentials('json'));
+ self::assertArrayHasKey('user', api_account_verify_credentials('json'));
}
/**
*/
public function testRequestdata()
{
- $this->assertNull(requestdata('variable_name'));
+ self::assertNull(requestdata('variable_name'));
}
/**
public function testRequestdataWithPost()
{
$_POST['variable_name'] = 'variable_value';
- $this->assertEquals('variable_value', requestdata('variable_name'));
+ self::assertEquals('variable_value', requestdata('variable_name'));
}
/**
public function testRequestdataWithGet()
{
$_GET['variable_name'] = 'variable_value';
- $this->assertEquals('variable_value', requestdata('variable_name'));
+ self::assertEquals('variable_value', requestdata('variable_name'));
}
/**
$_GET['status'] = '<b>Status content</b>';
$result = api_statuses_mediap('json');
- $this->assertStatus($result['status']);
+ self::assertStatus($result['status']);
}
/**
];
$result = api_statuses_update('json');
- $this->assertStatus($result['status']);
+ self::assertStatus($result['status']);
}
/**
$_GET['htmlstatus'] = '<b>Status content</b>';
$result = api_statuses_update('json');
- $this->assertStatus($result['status']);
+ self::assertStatus($result['status']);
}
/**
$app->argc = 2;
$result = api_media_upload();
- $this->assertEquals('image/png', $result['media']['image']['image_type']);
- $this->assertEquals(1, $result['media']['image']['w']);
- $this->assertEquals(1, $result['media']['image']['h']);
- $this->assertNotEmpty($result['media']['image']['friendica_preview_url']);
+ self::assertEquals('image/png', $result['media']['image']['image_type']);
+ self::assertEquals(1, $result['media']['image']['w']);
+ self::assertEquals(1, $result['media']['image']['h']);
+ self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
}
/**
public function testApiStatusShowWithJson()
{
$result = api_status_show('json', 1);
- $this->assertStatus($result['status']);
+ self::assertStatus($result['status']);
}
/**
public function testApiStatusShowWithXml()
{
$result = api_status_show('xml', 1);
- $this->assertXml($result, 'statuses');
+ self::assertXml($result, 'statuses');
}
/**
{
$item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
- $this->assertNotNull($item);
+ self::assertNotNull($item);
}
/**
{
$result = api_users_show('json');
// We can't use assertSelfUser() here because the user object is missing some properties.
- $this->assertEquals($this->selfUser['id'], $result['user']['cid']);
- $this->assertEquals('DFRN', $result['user']['location']);
- $this->assertEquals($this->selfUser['name'], $result['user']['name']);
- $this->assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
- $this->assertEquals('dfrn', $result['user']['network']);
- $this->assertTrue($result['user']['verified']);
+ self::assertEquals($this->selfUser['id'], $result['user']['cid']);
+ self::assertEquals('DFRN', $result['user']['location']);
+ self::assertEquals($this->selfUser['name'], $result['user']['name']);
+ self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
+ self::assertEquals('dfrn', $result['user']['network']);
+ self::assertTrue($result['user']['verified']);
}
/**
public function testApiUsersShowWithXml()
{
$result = api_users_show('xml');
- $this->assertXml($result, 'statuses');
+ self::assertXml($result, 'statuses');
}
/**
{
$_GET['q'] = 'othercontact';
$result = api_users_search('json');
- $this->assertOtherUser($result['users'][0]);
+ self::assertOtherUser($result['users'][0]);
}
/**
{
$_GET['q'] = 'othercontact';
$result = api_users_search('xml');
- $this->assertXml($result, 'users');
+ self::assertXml($result, 'users');
}
/**
{
$_REQUEST['user_id'] = $this->otherUser['id'];
$result = api_users_lookup('json');
- $this->assertOtherUser($result['users'][0]);
+ self::assertOtherUser($result['users'][0]);
}
/**
$_REQUEST['max_id'] = 10;
$result = api_search('json');
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
- $this->assertContains('reply', $status['text'], null, true);
+ self::assertStatus($status);
+ self::assertContains('reply', $status['text'], null, true);
}
}
$_REQUEST['count'] = 20;
$result = api_search('json');
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
- $this->assertContains('reply', $status['text'], null, true);
+ self::assertStatus($status);
+ self::assertContains('reply', $status['text'], null, true);
}
}
$_REQUEST['rpp'] = 20;
$result = api_search('json');
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
- $this->assertContains('reply', $status['text'], null, true);
+ self::assertStatus($status);
+ self::assertContains('reply', $status['text'], null, true);
}
}
$_REQUEST['q'] = '%23friendica';
$result = api_search('json');
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
- $this->assertContains('#friendica', $status['text'], null, true);
+ self::assertStatus($status);
+ self::assertContains('#friendica', $status['text'], null, true);
}
}
$_REQUEST['q'] = 'friendica';
$result = api_search('json');
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
$_REQUEST['exclude_replies'] = true;
$_REQUEST['conversation_id'] = 1;
$result = api_statuses_home_timeline('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
{
$_REQUEST['page'] = -2;
$result = api_statuses_home_timeline('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
public function testApiStatusesHomeTimelineWithRss()
{
$result = api_statuses_home_timeline('rss');
- $this->assertXml($result, 'statuses');
+ self::assertXml($result, 'statuses');
}
/**
$_REQUEST['max_id'] = 10;
$_REQUEST['conversation_id'] = 1;
$result = api_statuses_public_timeline('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
$_REQUEST['max_id'] = 10;
$_REQUEST['exclude_replies'] = true;
$result = api_statuses_public_timeline('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
{
$_REQUEST['page'] = -2;
$result = api_statuses_public_timeline('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
public function testApiStatusesPublicTimelineWithRss()
{
$result = api_statuses_public_timeline('rss');
- $this->assertXml($result, 'statuses');
+ self::assertXml($result, 'statuses');
}
/**
{
$_REQUEST['max_id'] = 10;
$result = api_statuses_networkpublic_timeline('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
{
$_REQUEST['page'] = -2;
$result = api_statuses_networkpublic_timeline('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
public function testApiStatusesNetworkpublicTimelineWithRss()
{
$result = api_statuses_networkpublic_timeline('rss');
- $this->assertXml($result, 'statuses');
+ self::assertXml($result, 'statuses');
}
/**
{
$this->app->argv[3] = 1;
$result = api_statuses_show('json');
- $this->assertStatus($result['status']);
+ self::assertStatus($result['status']);
}
/**
$this->app->argv[3] = 1;
$_REQUEST['conversation'] = 1;
$result = api_statuses_show('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
$_REQUEST['max_id'] = 10;
$_REQUEST['page'] = -2;
$result = api_conversation_show('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
{
$this->app->argv[3] = 1;
$result = api_statuses_repeat('json');
- $this->assertStatus($result['status']);
+ self::assertStatus($result['status']);
// Also test with a shared status
$this->app->argv[3] = 5;
$result = api_statuses_repeat('json');
- $this->assertStatus($result['status']);
+ self::assertStatus($result['status']);
}
/**
{
$this->app->argv[3] = 1;
$result = api_statuses_destroy('json');
- $this->assertStatus($result['status']);
+ self::assertStatus($result['status']);
}
/**
$this->app->user = ['nickname' => $this->selfUser['nick']];
$_REQUEST['max_id'] = 10;
$result = api_statuses_mentions('json');
- $this->assertEmpty($result['status']);
+ self::assertEmpty($result['status']);
// We should test with mentions in the database.
}
{
$_REQUEST['page'] = -2;
$result = api_statuses_mentions('json');
- $this->assertEmpty($result['status']);
+ self::assertEmpty($result['status']);
}
/**
public function testApiStatusesMentionsWithRss()
{
$result = api_statuses_mentions('rss');
- $this->assertXml($result, 'statuses');
+ self::assertXml($result, 'statuses');
}
/**
$_REQUEST['exclude_replies'] = true;
$_REQUEST['conversation_id'] = 1;
$result = api_statuses_user_timeline('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
{
$_REQUEST['page'] = -2;
$result = api_statuses_user_timeline('json');
- $this->assertNotEmpty($result['status']);
+ self::assertNotEmpty($result['status']);
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
public function testApiStatusesUserTimelineWithRss()
{
$result = api_statuses_user_timeline('rss');
- $this->assertXml($result, 'statuses');
+ self::assertXml($result, 'statuses');
}
/**
$this->app->argc = count($this->app->argv);
$_REQUEST['id'] = 3;
$result = api_favorites_create_destroy('json');
- $this->assertStatus($result['status']);
+ self::assertStatus($result['status']);
}
/**
$this->app->argc = count($this->app->argv);
$_REQUEST['id'] = 3;
$result = api_favorites_create_destroy('rss');
- $this->assertXml($result, 'status');
+ self::assertXml($result, 'status');
}
/**
$this->app->argc = count($this->app->argv);
$_REQUEST['id'] = 3;
$result = api_favorites_create_destroy('json');
- $this->assertStatus($result['status']);
+ self::assertStatus($result['status']);
}
/**
$_REQUEST['max_id'] = 10;
$result = api_favorites('json');
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
public function testApiFavoritesWithRss()
{
$result = api_favorites('rss');
- $this->assertXml($result, 'statuses');
+ self::assertXml($result, 'statuses');
}
/**
['id' => 2, 'screen_name' => 'recipient_name'],
['id' => 3, 'screen_name' => 'sender_name']
);
- $this->assertEquals('item_title' . "\n" . 'item_body', $result['text']);
- $this->assertEquals(1, $result['id']);
- $this->assertEquals(2, $result['recipient_id']);
- $this->assertEquals(3, $result['sender_id']);
- $this->assertEquals('recipient_name', $result['recipient_screen_name']);
- $this->assertEquals('sender_name', $result['sender_screen_name']);
+ self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
+ self::assertEquals(1, $result['id']);
+ self::assertEquals(2, $result['recipient_id']);
+ self::assertEquals(3, $result['sender_id']);
+ self::assertEquals('recipient_name', $result['recipient_screen_name']);
+ self::assertEquals('sender_name', $result['sender_screen_name']);
}
/**
['id' => 2, 'screen_name' => 'recipient_name'],
['id' => 3, 'screen_name' => 'sender_name']
);
- $this->assertEquals('item_title', $result['title']);
- $this->assertEquals('<strong>item_body</strong>', $result['text']);
+ self::assertEquals('item_title', $result['title']);
+ self::assertEquals('<strong>item_body</strong>', $result['text']);
}
/**
['id' => 2, 'screen_name' => 'recipient_name'],
['id' => 3, 'screen_name' => 'sender_name']
);
- $this->assertEquals('item_title', $result['title']);
- $this->assertEquals('item_body', $result['text']);
+ self::assertEquals('item_title', $result['title']);
+ self::assertEquals('item_body', $result['text']);
}
/**
['id' => 2, 'screen_name' => 'recipient_name'],
['id' => 3, 'screen_name' => 'sender_name']
);
- $this->assertTrue(!isset($result['sender']));
- $this->assertTrue(!isset($result['recipient']));
+ self::assertTrue(!isset($result['sender']));
+ self::assertTrue(!isset($result['recipient']));
}
/**
'plink' => 'item_plink'
]
);
- $this->assertStringStartsWith('item_title', $result['text']);
- $this->assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
+ self::assertStringStartsWith('item_title', $result['text']);
+ self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
}
/**
'plink' => 'item_plink'
]
);
- $this->assertEquals('item_title', $result['text']);
- $this->assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
+ self::assertEquals('item_title', $result['text']);
+ self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
}
/**
'body' => 'item_title item_body'
]
);
- $this->assertEquals('item_title item_body', $result['text']);
- $this->assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
+ self::assertEquals('item_title item_body', $result['text']);
+ self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
}
/**
public function testApiGetAttachments()
{
$body = 'body';
- $this->assertEmpty(api_get_attachments($body));
+ self::assertEmpty(api_get_attachments($body));
}
/**
public function testApiGetAttachmentsWithImage()
{
$body = '[img]http://via.placeholder.com/1x1.png[/img]';
- $this->assertInternalType('array', api_get_attachments($body));
+ self::assertInternalType('array', api_get_attachments($body));
}
/**
{
$_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
$body = '[img]http://via.placeholder.com/1x1.png[/img]';
- $this->assertInternalType('array', api_get_attachments($body));
+ self::assertInternalType('array', api_get_attachments($body));
}
/**
public function testApiGetEntitities()
{
$text = 'text';
- $this->assertInternalType('array', api_get_entitities($text, 'bbcode'));
+ self::assertInternalType('array', api_get_entitities($text, 'bbcode'));
}
/**
$_REQUEST['include_entities'] = 'true';
$text = 'text';
$result = api_get_entitities($text, 'bbcode');
- $this->assertInternalType('array', $result['hashtags']);
- $this->assertInternalType('array', $result['symbols']);
- $this->assertInternalType('array', $result['urls']);
- $this->assertInternalType('array', $result['user_mentions']);
+ self::assertInternalType('array', $result['hashtags']);
+ self::assertInternalType('array', $result['symbols']);
+ self::assertInternalType('array', $result['urls']);
+ self::assertInternalType('array', $result['user_mentions']);
}
/**
*/
public function testApiFormatItemsEmbededImages()
{
- $this->assertEquals(
+ self::assertEquals(
'text ' . DI::baseUrl() . '/display/item_guid',
api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
);
*/
public function testApiContactlinkToArray()
{
- $this->assertEquals(
+ self::assertEquals(
[
'name' => 'text',
'url' => '',
*/
public function testApiContactlinkToArrayWithUrl()
{
- $this->assertEquals(
+ self::assertEquals(
[
'name' => ['link_text'],
'url' => ['url'],
{
$item = ['uid' => 0, 'uri' => ''];
$result = api_format_items_activities($item);
- $this->assertArrayHasKey('like', $result);
- $this->assertArrayHasKey('dislike', $result);
- $this->assertArrayHasKey('attendyes', $result);
- $this->assertArrayHasKey('attendno', $result);
- $this->assertArrayHasKey('attendmaybe', $result);
+ self::assertArrayHasKey('like', $result);
+ self::assertArrayHasKey('dislike', $result);
+ self::assertArrayHasKey('attendyes', $result);
+ self::assertArrayHasKey('attendno', $result);
+ self::assertArrayHasKey('attendmaybe', $result);
}
/**
{
$item = ['uid' => 0, 'uri' => ''];
$result = api_format_items_activities($item, 'xml');
- $this->assertArrayHasKey('friendica:like', $result);
- $this->assertArrayHasKey('friendica:dislike', $result);
- $this->assertArrayHasKey('friendica:attendyes', $result);
- $this->assertArrayHasKey('friendica:attendno', $result);
- $this->assertArrayHasKey('friendica:attendmaybe', $result);
+ self::assertArrayHasKey('friendica:like', $result);
+ self::assertArrayHasKey('friendica:dislike', $result);
+ self::assertArrayHasKey('friendica:attendyes', $result);
+ self::assertArrayHasKey('friendica:attendno', $result);
+ self::assertArrayHasKey('friendica:attendmaybe', $result);
}
/**
];
$result = api_format_items($items, ['id' => 0], true);
foreach ($result as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
];
$result = api_format_items($items, ['id' => 0], true, 'xml');
foreach ($result as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
public function testApiAccountRateLimitStatus()
{
$result = api_account_rate_limit_status('json');
- $this->assertEquals(150, $result['hash']['remaining_hits']);
- $this->assertEquals(150, $result['hash']['hourly_limit']);
- $this->assertInternalType('int', $result['hash']['reset_time_in_seconds']);
+ self::assertEquals(150, $result['hash']['remaining_hits']);
+ self::assertEquals(150, $result['hash']['hourly_limit']);
+ self::assertInternalType('int', $result['hash']['reset_time_in_seconds']);
}
/**
public function testApiAccountRateLimitStatusWithXml()
{
$result = api_account_rate_limit_status('xml');
- $this->assertXml($result, 'hash');
+ self::assertXml($result, 'hash');
}
/**
public function testApiHelpTest()
{
$result = api_help_test('json');
- $this->assertEquals(['ok' => 'ok'], $result);
+ self::assertEquals(['ok' => 'ok'], $result);
}
/**
public function testApiHelpTestWithXml()
{
$result = api_help_test('xml');
- $this->assertXml($result, 'ok');
+ self::assertXml($result, 'ok');
}
/**
public function testApiListsList()
{
$result = api_lists_list('json');
- $this->assertEquals(['lists_list' => []], $result);
+ self::assertEquals(['lists_list' => []], $result);
}
/**
{
$result = api_lists_ownerships('json');
foreach ($result['lists']['lists'] as $list) {
- $this->assertList($list);
+ self::assertList($list);
}
}
$_REQUEST['max_id'] = 10;
$result = api_lists_statuses('json');
foreach ($result['status'] as $status) {
- $this->assertStatus($status);
+ self::assertStatus($status);
}
}
{
$_REQUEST['list_id'] = 1;
$result = api_lists_statuses('rss');
- $this->assertXml($result, 'statuses');
+ self::assertXml($result, 'statuses');
}
/**
{
$_GET['page'] = -1;
$result = api_statuses_f('friends');
- $this->assertArrayHasKey('user', $result);
+ self::assertArrayHasKey('user', $result);
}
/**
public function testApiStatusesFWithFollowers()
{
$result = api_statuses_f('followers');
- $this->assertArrayHasKey('user', $result);
+ self::assertArrayHasKey('user', $result);
}
/**
public function testApiStatusesFWithBlocks()
{
$result = api_statuses_f('blocks');
- $this->assertArrayHasKey('user', $result);
+ self::assertArrayHasKey('user', $result);
}
/**
public function testApiStatusesFWithIncoming()
{
$result = api_statuses_f('incoming');
- $this->assertArrayHasKey('user', $result);
+ self::assertArrayHasKey('user', $result);
}
/**
public function testApiStatusesFWithUndefinedCursor()
{
$_GET['cursor'] = 'undefined';
- $this->assertFalse(api_statuses_f('friends'));
+ self::assertFalse(api_statuses_f('friends'));
}
/**
public function testApiStatusesFriends()
{
$result = api_statuses_friends('json');
- $this->assertArrayHasKey('user', $result);
+ self::assertArrayHasKey('user', $result);
}
/**
public function testApiStatusesFriendsWithUndefinedCursor()
{
$_GET['cursor'] = 'undefined';
- $this->assertFalse(api_statuses_friends('json'));
+ self::assertFalse(api_statuses_friends('json'));
}
/**
public function testApiStatusesFollowers()
{
$result = api_statuses_followers('json');
- $this->assertArrayHasKey('user', $result);
+ self::assertArrayHasKey('user', $result);
}
/**
public function testApiStatusesFollowersWithUndefinedCursor()
{
$_GET['cursor'] = 'undefined';
- $this->assertFalse(api_statuses_followers('json'));
+ self::assertFalse(api_statuses_followers('json'));
}
/**
public function testApiBlocksList()
{
$result = api_blocks_list('json');
- $this->assertArrayHasKey('user', $result);
+ self::assertArrayHasKey('user', $result);
}
/**
public function testApiBlocksListWithUndefinedCursor()
{
$_GET['cursor'] = 'undefined';
- $this->assertFalse(api_blocks_list('json'));
+ self::assertFalse(api_blocks_list('json'));
}
/**
public function testApiFriendshipsIncoming()
{
$result = api_friendships_incoming('json');
- $this->assertArrayHasKey('id', $result);
+ self::assertArrayHasKey('id', $result);
}
/**
public function testApiFriendshipsIncomingWithUndefinedCursor()
{
$_GET['cursor'] = 'undefined';
- $this->assertFalse(api_friendships_incoming('json'));
+ self::assertFalse(api_friendships_incoming('json'));
}
/**
public function testApiStatusnetConfig()
{
$result = api_statusnet_config('json');
- $this->assertEquals('localhost', $result['config']['site']['server']);
- $this->assertEquals('default', $result['config']['site']['theme']);
- $this->assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
- $this->assertTrue($result['config']['site']['fancy']);
- $this->assertEquals('en', $result['config']['site']['language']);
- $this->assertEquals('UTC', $result['config']['site']['timezone']);
- $this->assertEquals(200000, $result['config']['site']['textlimit']);
- $this->assertEquals('false', $result['config']['site']['private']);
- $this->assertEquals('false', $result['config']['site']['ssl']);
- $this->assertEquals(30, $result['config']['site']['shorturllength']);
+ self::assertEquals('localhost', $result['config']['site']['server']);
+ self::assertEquals('default', $result['config']['site']['theme']);
+ self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
+ self::assertTrue($result['config']['site']['fancy']);
+ self::assertEquals('en', $result['config']['site']['language']);
+ self::assertEquals('UTC', $result['config']['site']['timezone']);
+ self::assertEquals(200000, $result['config']['site']['textlimit']);
+ self::assertEquals('false', $result['config']['site']['private']);
+ self::assertEquals('false', $result['config']['site']['ssl']);
+ self::assertEquals(30, $result['config']['site']['shorturllength']);
}
/**
public function testApiStatusnetVersion()
{
$result = api_statusnet_version('json');
- $this->assertEquals('0.9.7', $result['version']);
+ self::assertEquals('0.9.7', $result['version']);
}
/**
public function testApiDirectMessagesNew()
{
$result = api_direct_messages_new('json');
- $this->assertNull($result);
+ self::assertNull($result);
}
/**
$_POST['text'] = 'message_text';
$_POST['user_id'] = $this->otherUser['id'];
$result = api_direct_messages_new('json');
- $this->assertEquals(['direct_message' => ['error' => -1]], $result);
+ self::assertEquals(['direct_message' => ['error' => -1]], $result);
}
/**
$_POST['text'] = 'message_text';
$_POST['screen_name'] = $this->friendUser['nick'];
$result = api_direct_messages_new('json');
- $this->assertContains('message_text', $result['direct_message']['text']);
- $this->assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
- $this->assertEquals(1, $result['direct_message']['friendica_seen']);
+ self::assertContains('message_text', $result['direct_message']['text']);
+ self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
+ self::assertEquals(1, $result['direct_message']['friendica_seen']);
}
/**
$_POST['screen_name'] = $this->friendUser['nick'];
$_REQUEST['title'] = 'message_title';
$result = api_direct_messages_new('json');
- $this->assertContains('message_text', $result['direct_message']['text']);
- $this->assertContains('message_title', $result['direct_message']['text']);
- $this->assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
- $this->assertEquals(1, $result['direct_message']['friendica_seen']);
+ self::assertContains('message_text', $result['direct_message']['text']);
+ self::assertContains('message_title', $result['direct_message']['text']);
+ self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
+ self::assertEquals(1, $result['direct_message']['friendica_seen']);
}
/**
$_POST['text'] = 'message_text';
$_POST['screen_name'] = $this->friendUser['nick'];
$result = api_direct_messages_new('rss');
- $this->assertXml($result, 'direct-messages');
+ self::assertXml($result, 'direct-messages');
}
/**
{
$_GET['friendica_verbose'] = 'true';
$result = api_direct_messages_destroy('json');
- $this->assertEquals(
+ self::assertEquals(
[
'$result' => [
'result' => 'error',
$_REQUEST['friendica_parenturi'] = 'parent_uri';
$_GET['friendica_verbose'] = 'true';
$result = api_direct_messages_destroy('json');
- $this->assertEquals(
+ self::assertEquals(
[
'$result' => [
'result' => 'error',
$_REQUEST['page'] = -1;
$_REQUEST['max_id'] = 10;
$result = api_direct_messages_box('json', 'sentbox', 'false');
- $this->assertArrayHasKey('direct_message', $result);
+ self::assertArrayHasKey('direct_message', $result);
}
/**
public function testApiDirectMessagesBoxWithConversation()
{
$result = api_direct_messages_box('json', 'conversation', 'false');
- $this->assertArrayHasKey('direct_message', $result);
+ self::assertArrayHasKey('direct_message', $result);
}
/**
public function testApiDirectMessagesBoxWithAll()
{
$result = api_direct_messages_box('json', 'all', 'false');
- $this->assertArrayHasKey('direct_message', $result);
+ self::assertArrayHasKey('direct_message', $result);
}
/**
public function testApiDirectMessagesBoxWithInbox()
{
$result = api_direct_messages_box('json', 'inbox', 'false');
- $this->assertArrayHasKey('direct_message', $result);
+ self::assertArrayHasKey('direct_message', $result);
}
/**
public function testApiDirectMessagesBoxWithVerbose()
{
$result = api_direct_messages_box('json', 'sentbox', 'true');
- $this->assertEquals(
+ self::assertEquals(
[
'$result' => [
'result' => 'error',
public function testApiDirectMessagesBoxWithRss()
{
$result = api_direct_messages_box('rss', 'sentbox', 'false');
- $this->assertXml($result, 'direct-messages');
+ self::assertXml($result, 'direct-messages');
}
/**
public function testApiDirectMessagesSentbox()
{
$result = api_direct_messages_sentbox('json');
- $this->assertArrayHasKey('direct_message', $result);
+ self::assertArrayHasKey('direct_message', $result);
}
/**
public function testApiDirectMessagesInbox()
{
$result = api_direct_messages_inbox('json');
- $this->assertArrayHasKey('direct_message', $result);
+ self::assertArrayHasKey('direct_message', $result);
}
/**
public function testApiDirectMessagesAll()
{
$result = api_direct_messages_all('json');
- $this->assertArrayHasKey('direct_message', $result);
+ self::assertArrayHasKey('direct_message', $result);
}
/**
public function testApiDirectMessagesConversation()
{
$result = api_direct_messages_conversation('json');
- $this->assertArrayHasKey('direct_message', $result);
+ self::assertArrayHasKey('direct_message', $result);
}
/**
public function testApiFrPhotosList()
{
$result = api_fr_photos_list('json');
- $this->assertArrayHasKey('photo', $result);
+ self::assertArrayHasKey('photo', $result);
}
/**
$_POST['description'] = 'new_description';
$result = api_account_update_profile('json');
// We can't use assertSelfUser() here because the user object is missing some properties.
- $this->assertEquals($this->selfUser['id'], $result['user']['cid']);
- $this->assertEquals('DFRN', $result['user']['location']);
- $this->assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
- $this->assertEquals('dfrn', $result['user']['network']);
- $this->assertEquals('new_name', $result['user']['name']);
- $this->assertEquals('new_description', $result['user']['description']);
+ self::assertEquals($this->selfUser['id'], $result['user']['cid']);
+ self::assertEquals('DFRN', $result['user']['location']);
+ self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
+ self::assertEquals('dfrn', $result['user']['network']);
+ self::assertEquals('new_name', $result['user']['name']);
+ self::assertEquals('new_description', $result['user']['description']);
}
/**
{
$result = check_acl_input('<aclstring>');
// Where does this result come from?
- $this->assertEquals(1, $result);
+ self::assertEquals(1, $result);
}
/**
public function testCheckAclInputWithEmptyAclString()
{
$result = check_acl_input(' ');
- $this->assertFalse($result);
+ self::assertFalse($result);
}
/**
{
$item = ['body' => '', 'author-id' => 1, 'owner-id' => 1];
$result = api_share_as_retweet($item);
- $this->assertFalse($result);
+ self::assertFalse($result);
}
/**
public function testApiInReplyTo()
{
$result = api_in_reply_to(['id' => 0, 'parent' => 0, 'uri' => '', 'thr-parent' => '']);
- $this->assertArrayHasKey('status_id', $result);
- $this->assertArrayHasKey('user_id', $result);
- $this->assertArrayHasKey('status_id_str', $result);
- $this->assertArrayHasKey('user_id_str', $result);
- $this->assertArrayHasKey('screen_name', $result);
+ self::assertArrayHasKey('status_id', $result);
+ self::assertArrayHasKey('user_id', $result);
+ self::assertArrayHasKey('status_id_str', $result);
+ self::assertArrayHasKey('user_id_str', $result);
+ self::assertArrayHasKey('screen_name', $result);
}
/**
{
$_REQUEST['include_entities'] = 'true';
$result = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
- $this->assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
+ self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
}
/**
{
$contacts = [];
$result = api_best_nickname($contacts);
- $this->assertNull($result);
+ self::assertNull($result);
}
/**
$this->app->argc = count($this->app->argv);
$_SESSION['uid'] = 41;
$result = api_friendica_notification('json');
- $this->assertEquals(['note' => false], $result);
+ self::assertEquals(['note' => false], $result);
}
/**
<note id="1" hash="" type="8" name="Reply to" url="http://localhost/display/1" photo="http://localhost/" date="2020-01-01 12:12:02" msg="A test reply from an item" uid="42" uri-id="" link="http://localhost/notification/1" iid="4" parent="0" parent-uri-id="" seen="0" verb="" otype="item" name_cache="Reply to" msg_cache="A test reply from an item" timestamp="1577880722" date_rel="{$dateRel}" msg_html="A test reply from an item" msg_plain="A test reply from an item"/>
</notes>
XML;
- $this->assertXmlStringEqualsXmlString($assertXml, $result);
+ self::assertXmlStringEqualsXmlString($assertXml, $result);
}
/**
$this->app->argv = ['api', 'friendica', 'notification'];
$this->app->argc = count($this->app->argv);
$result = json_encode(api_friendica_notification('json'));
- $this->assertJson($result);
+ self::assertJson($result);
}
/**
public function testApiSavedSearchesList()
{
$result = api_saved_searches_list('json');
- $this->assertEquals(1, $result['terms'][0]['id']);
- $this->assertEquals(1, $result['terms'][0]['id_str']);
- $this->assertEquals('Saved search', $result['terms'][0]['name']);
- $this->assertEquals('Saved search', $result['terms'][0]['query']);
+ self::assertEquals(1, $result['terms'][0]['id']);
+ self::assertEquals(1, $result['terms'][0]['id_str']);
+ self::assertEquals('Saved search', $result['terms'][0]['name']);
+ self::assertEquals('Saved search', $result['terms'][0]['query']);
}
}
{
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());
}
/**
{
$arguments = new App\Arguments();
- $this->assertArguments([
+ self::assertArguments([
'queryString' => '',
'command' => '',
'argv' => [],
$arguments = (new App\Arguments())
->determine($server, $get);
- $this->assertArguments($assert, $arguments);
+ self::assertArguments($assert, $arguments);
}
/**
->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()
$arguments = (new App\Arguments())
->determine(['QUERY_STRING' => 'pagename=' . $command . $input,], ['pagename' => $command]);
- $this->assertEquals($command . $assert, $arguments->getQueryString());
+ self::assertEquals($command . $assert, $arguments->getQueryString());
}
/**
$argNew = $argument->determine([], []);
- $this->assertNotSame($argument, $argNew);
+ self::assertNotSame($argument, $argNew);
}
}
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()
$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()
$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()
$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()
$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));
}
/**
$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));
}
/**
$modeNew = $mode->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
- $this->assertNotSame($modeNew, $mode);
+ self::assertNotSame($modeNew, $mode);
}
/**
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
- $this->assertTrue($mode->isBackend());
+ self::assertTrue($mode->isBackend());
}
/**
$mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect);
- $this->assertTrue($mode->isBackend());
+ self::assertTrue($mode->isBackend());
}
/**
$mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect);
- $this->assertFalse($mode->isBackend());
+ self::assertFalse($mode->isBackend());
}
/**
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
- $this->assertTrue($mode->isAjax());
+ self::assertTrue($mode->isAjax());
}
/**
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
- $this->assertFalse($mode->isAjax());
+ self::assertFalse($mode->isAjax());
}
/**
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
- $this->assertTrue($mode->isMobile());
- $this->assertTrue($mode->isTablet());
+ self::assertTrue($mode->isMobile());
+ self::assertTrue($mode->isTablet());
}
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
- $this->assertFalse($mode->isMobile());
- $this->assertFalse($mode->isTablet());
+ self::assertFalse($mode->isMobile());
+ self::assertFalse($mode->isTablet());
}
}
{
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());
}
/**
{
$module = new App\Module();
- $this->assertModule([
+ self::assertModule([
'isBackend' => false,
'name' => App\Module::DEFAULT,
'class' => App\Module::DEFAULT_CLASS,
{
$module = (new App\Module())->determineModule($args);
- $this->assertModule($assert, $module);
+ self::assertModule($assert, $module);
}
public function dataModuleClass()
$module = (new App\Module($name))->determineClass(new App\Arguments('', $command), $router, $config);
- $this->assertEquals($assert, $module->getClassName());
+ self::assertEquals($assert, $module->getClassName());
}
/**
$moduleNew = $module->determineModule(new App\Arguments());
- $this->assertNotSame($moduleNew, $module);
+ self::assertNotSame($moduleNew, $module);
}
}
$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()
$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()
$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'));
}
/**
], '', $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'));
}
}
FIN;
- $this->assertEquals($finished, $txt);
+ self::assertEquals($finished, $txt);
}
private function assertStuckDB($txt)
FIN;
- $this->assertEquals($finished, $txt);
+ self::assertEquals($finished, $txt);
}
private function assertStuckURL($txt)
FIN;
- $this->assertEquals($finished, $txt);
+ self::assertEquals($finished, $txt);
}
/**
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));
}
}
$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);
}
/**
$txt = $this->dumpExecute($console);
- $this->assertStuckURL($txt);
+ self::assertStuckURL($txt);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
$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()
$txt = $this->dumpExecute($console);
- $this->assertEquals($theHelp, $txt);
+ self::assertEquals($theHelp, $txt);
}
}
$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')
$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')
$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() {
$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() {
$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() {
CONF;
$txt = $this->dumpExecute($console);
- $this->assertEquals($assertion, $txt);
+ self::assertEquals($assertion, $txt);
}
function testUnableToSet() {
$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()
$txt = $this->dumpExecute($console);
- $this->assertEquals($txt, $theHelp);
+ self::assertEquals($txt, $theHelp);
}
}
$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()
$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()
$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()
$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()
$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()
$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()
$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()
$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()
$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()
$txt = $this->dumpExecute($console);
- $this->assertEquals($txt, $theHelp);
+ self::assertEquals($txt, $theHelp);
}
}
CONS;
- $this->assertEquals($output, $txt);
+ self::assertEquals($output, $txt);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
$console->setArgument(0, 'wrongcommand');
$txt = $this->dumpExecute($console);
- $this->assertStringStartsWith('[Warning] Unknown command', $txt);
+ self::assertStringStartsWith('[Warning] Unknown command', $txt);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
HELP;
- $this->assertEquals($help, $txt);
+ self::assertEquals($help, $txt);
}
}
*/
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()
*/
public function testStripTrailingUrlFromBody(string $expected, string $body, string $url)
{
- $this->assertSame($expected, PageInfoMock::stripTrailingUrlFromBody($body, $url));
+ self::assertSame($expected, PageInfoMock::stripTrailingUrlFromBody($body, $url));
}
}
public function testReplaceFromArray($text, $smilies, $expected)
{
$output = Smilies::replaceFromArray($text, $smilies);
- $this->assertEquals($expected, $output);
+ self::assertEquals($expected, $output);
}
}
{
$bbCodeVideo = new Video();
- $this->assertEquals($assert, $bbCodeVideo->transform($input));
+ self::assertEquals($assert, $bbCodeVideo->transform($input));
}
}
$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);
}
}
{
$actual = BBCode::convert($text, $try_oembed, $simpleHtml, $forPlaintext);
- $this->assertEquals($expectedHtml, $actual);
+ self::assertEquals($expectedHtml, $actual);
}
public function dataBBCodesToMarkdown()
{
$actual = BBCode::toMarkdown($text, $for_diaspora);
- $this->assertEquals($expected, $actual);
+ self::assertEquals($expected, $actual);
}
}
{
$output = HTML::toPlaintext($input, 0);
- $this->assertEquals($expected, $output);
+ self::assertEquals($expected, $output);
}
public function dataHTMLText()
{
$actual = HTML::toBBCode($html);
- $this->assertEquals($expectedBBCode, $actual);
+ self::assertEquals($expectedBBCode, $actual);
}
}
{
$output = Markdown::convert($input);
- $this->assertEquals($expected, $output);
+ self::assertEquals($expected, $output);
}
public function dataMarkdownText()
{
$actual = Markdown::toBBCode($html);
- $this->assertEquals($expectedBBCode, $actual);
+ self::assertEquals($expectedBBCode, $actual);
}
}
*/
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'));
}
/**
$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,
'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,
'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,
{
$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'));
}
/**
{
$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));
}
/**
*/
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);
}
}
*/
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');
}
/**
*/
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');
}
/**
*/
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');
}
/**
*/
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');
}
/**
*/
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');
}
}
{
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));
}
}
}
$configCache = new Cache();
$configCache->load($data);
- $this->assertConfigValues($data, $configCache);
+ self::assertConfigValues($data, $configCache);
}
/**
// 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'));
}
/**
// 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));
}
/**
$all = $configCache->getAll();
- $this->assertContains($data['system'], $all);
- $this->assertContains($data['config'], $all);
+ self::assertContains($data['system'], $all);
+ self::assertContains($data['config'], $all);
}
/**
}
}
- $this->assertConfigValues($data, $configCache);
+ self::assertConfigValues($data, $configCache);
}
/**
{
$configCache = new Cache();
- $this->assertNull($configCache->get('something', 'value'));
+ self::assertNull($configCache->get('something', 'value'));
}
/**
],
]);
- $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));
}
}
- $this->assertEmpty($configCache->getAll());
+ self::assertEmpty($configCache->getAll());
}
/**
]
];
- $this->assertEquals($diffConfig, $configCache->keyDiff($diffConfig));
+ self::assertEquals($diffConfig, $configCache->keyDiff($diffConfig));
}
/**
$diffConfig = $configCache->getAll();
- $this->assertEmpty($configCache->keyDiff($diffConfig));
+ self::assertEmpty($configCache->keyDiff($diffConfig));
}
/**
],
]);
- $this->assertEquals('supersecure', $configCache->get('database', 'password'));
- $this->assertNotEquals('supersecure', print_r($configCache->get('database', 'password'), true));
- $this->assertEquals('notsecured', print_r($configCache->get('database', 'username'), true));
+ self::assertEquals('supersecure', $configCache->get('database', 'password'));
+ self::assertNotEquals('supersecure', print_r($configCache->get('database', 'password'), true));
+ self::assertEquals('notsecured', print_r($configCache->get('database', 'username'), true));
}
/**
],
], false);
- $this->assertEquals('supersecure', $configCache->get('database', 'password'));
- $this->assertEquals('supersecure', print_r($configCache->get('database', 'password'), true));
- $this->assertEquals('notsecured', print_r($configCache->get('database', 'username'), true));
+ self::assertEquals('supersecure', $configCache->get('database', 'password'));
+ self::assertEquals('supersecure', print_r($configCache->get('database', 'password'), true));
+ self::assertEquals('notsecured', print_r($configCache->get('database', 'username'), true));
}
/**
]
]);
- $this->assertNotEmpty($configCache->get('database', 'password'));
- $this->assertInstanceOf(HiddenString::class, $configCache->get('database', 'password'));
- $this->assertEmpty($configCache->get('database', 'username'));
+ self::assertNotEmpty($configCache->get('database', 'password'));
+ self::assertInstanceOf(HiddenString::class, $configCache->get('database', 'password'));
+ self::assertEmpty($configCache->get('database', 'username'));
}
public function testWrongTypePassword()
]
]);
- $this->assertNotEmpty($configCache->get('database', 'password'));
- $this->assertEmpty($configCache->get('database', 'username'));
+ self::assertNotEmpty($configCache->get('database', 'password'));
+ self::assertEmpty($configCache->get('database', 'username'));
$configCache = new Cache([
'database' => [
]
]);
- $this->assertEquals(23, $configCache->get('database', 'password'));
- $this->assertEmpty($configCache->get('database', 'username'));
+ self::assertEquals(23, $configCache->get('database', 'password'));
+ self::assertEmpty($configCache->get('database', 'username'));
}
}
{
$result = $this->testedConfig->getCache()->getAll();
- $this->assertNotEmpty($result);
- $this->assertArrayHasKey($cat, $result);
- $this->assertArraySubset($data, $result[$cat]);
+ self::assertNotEmpty($result);
+ self::assertArrayHasKey($cat, $result);
+ self::assertArraySubset($data, $result[$cat]);
}
->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// assert config is loaded everytime
- $this->assertConfig('config', $data['config']);
+ self::assertConfig('config', $data['config']);
}
/**
public function testLoad(array $data, array $possibleCats, array $load)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
foreach ($load as $loadedCats) {
$this->testedConfig->load($loadedCats);
// Assert at least loaded cats are loaded
foreach ($load as $loadedCats) {
- $this->assertConfig($loadedCats, $data[$loadedCats]);
+ self::assertConfig($loadedCats, $data[$loadedCats]);
}
}
public function testCacheLoadDouble(array $data1, array $data2, array $expect)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
foreach ($data1 as $cat => $data) {
$this->testedConfig->load($cat);
// Assert at least loaded cats are loaded
foreach ($data1 as $cat => $data) {
- $this->assertConfig($cat, $data);
+ self::assertConfig($cat, $data);
}
foreach ($data2 as $cat => $data) {
$this->configModel->shouldReceive('load')->withAnyArgs()->andReturn([])->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
- $this->assertEmpty($this->testedConfig->getCache()->getAll());
+ self::assertEmpty($this->testedConfig->getCache()->getAll());
}
/**
->times(3);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
- $this->assertTrue($this->testedConfig->set('test', 'it', $data));
+ self::assertTrue($this->testedConfig->set('test', 'it', $data));
- $this->assertEquals($data, $this->testedConfig->get('test', 'it'));
- $this->assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
+ self::assertEquals($data, $this->testedConfig->get('test', 'it'));
+ self::assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
}
/**
$this->configModel->shouldReceive('set')->with('test', 'it', $data)->andReturn(true)->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
- $this->assertTrue($this->testedConfig->set('test', 'it', $data));
+ self::assertTrue($this->testedConfig->set('test', 'it', $data));
- $this->assertEquals($data, $this->testedConfig->get('test', 'it'));
- $this->assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
+ self::assertEquals($data, $this->testedConfig->get('test', 'it'));
+ self::assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
}
/**
public function testGetWrongWithoutDB()
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// without refresh
- $this->assertNull($this->testedConfig->get('test', 'it'));
+ self::assertNull($this->testedConfig->get('test', 'it'));
/// beware that the cache returns '!<unset>!' and not null for a non existing value
- $this->assertNull($this->testedConfig->getCache()->get('test', 'it'));
+ self::assertNull($this->testedConfig->getCache()->get('test', 'it'));
// with default value
- $this->assertEquals('default', $this->testedConfig->get('test', 'it', 'default'));
+ self::assertEquals('default', $this->testedConfig->get('test', 'it', 'default'));
// with default value and refresh
- $this->assertEquals('default', $this->testedConfig->get('test', 'it', 'default', true));
+ self::assertEquals('default', $this->testedConfig->get('test', 'it', 'default', true));
}
/**
$this->configCache->load(['test' => ['it' => 'now']], Cache::SOURCE_FILE);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// without refresh
- $this->assertEquals('now', $this->testedConfig->get('test', 'it'));
- $this->assertEquals('now', $this->testedConfig->getCache()->get('test', 'it'));
+ self::assertEquals('now', $this->testedConfig->get('test', 'it'));
+ self::assertEquals('now', $this->testedConfig->getCache()->get('test', 'it'));
// with refresh
- $this->assertEquals($data, $this->testedConfig->get('test', 'it', null, true));
- $this->assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
+ self::assertEquals($data, $this->testedConfig->get('test', 'it', null, true));
+ self::assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
// without refresh and wrong value and default
- $this->assertEquals('default', $this->testedConfig->get('test', 'not', 'default'));
- $this->assertNull($this->testedConfig->getCache()->get('test', 'not'));
+ self::assertEquals('default', $this->testedConfig->get('test', 'not', 'default'));
+ self::assertNull($this->testedConfig->getCache()->get('test', 'not'));
}
/**
$this->configCache->load(['test' => ['it' => $data]], Cache::SOURCE_FILE);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
- $this->assertEquals($data, $this->testedConfig->get('test', 'it'));
- $this->assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
+ self::assertEquals($data, $this->testedConfig->get('test', 'it'));
+ self::assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
- $this->assertTrue($this->testedConfig->delete('test', 'it'));
- $this->assertNull($this->testedConfig->get('test', 'it'));
- $this->assertNull($this->testedConfig->getCache()->get('test', 'it'));
+ self::assertTrue($this->testedConfig->delete('test', 'it'));
+ self::assertNull($this->testedConfig->get('test', 'it'));
+ self::assertNull($this->testedConfig->getCache()->get('test', 'it'));
- $this->assertEmpty($this->testedConfig->getCache()->getAll());
+ self::assertEmpty($this->testedConfig->getCache()->getAll());
}
/**
->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// directly set the value to the cache
$this->testedConfig->getCache()->set('test', 'it', 'now');
- $this->assertEquals('now', $this->testedConfig->get('test', 'it'));
- $this->assertEquals('now', $this->testedConfig->getCache()->get('test', 'it'));
+ self::assertEquals('now', $this->testedConfig->get('test', 'it'));
+ self::assertEquals('now', $this->testedConfig->getCache()->get('test', 'it'));
// delete from cache only
- $this->assertTrue($this->testedConfig->delete('test', 'it'));
+ self::assertTrue($this->testedConfig->delete('test', 'it'));
// delete from db only
- $this->assertTrue($this->testedConfig->delete('test', 'second'));
+ self::assertTrue($this->testedConfig->delete('test', 'second'));
// no delete
- $this->assertFalse($this->testedConfig->delete('test', 'third'));
+ self::assertFalse($this->testedConfig->delete('test', 'third'));
// delete both
- $this->assertTrue($this->testedConfig->delete('test', 'quarter'));
+ self::assertTrue($this->testedConfig->delete('test', 'quarter'));
- $this->assertEmpty($this->testedConfig->getCache()->getAll());
+ self::assertEmpty($this->testedConfig->getCache()->getAll());
}
}
// Assert the expected categories
foreach ($data2 as $cat => $data) {
- $this->assertConfig($cat, $expect[$cat]);
+ self::assertConfig($cat, $expect[$cat]);
}
}
// Assert that every category is loaded everytime
foreach ($data as $cat => $values) {
- $this->assertConfig($cat, $values);
+ self::assertConfig($cat, $values);
}
}
// Assert that every category is loaded everytime and is NOT overwritten
foreach ($data1 as $cat => $values) {
- $this->assertConfig($cat, $values);
+ self::assertConfig($cat, $values);
}
}
'help' => $help]
];
- $this->assertArraySubset($subSet, $assertionArray, false, "expected subset: " . PHP_EOL . print_r($subSet, true) . PHP_EOL . "current subset: " . print_r($assertionArray, true));
+ self::assertArraySubset($subSet, $assertionArray, false, "expected subset: " . PHP_EOL . print_r($subSet, true) . PHP_EOL . "current subset: " . print_r($assertionArray, true));
}
/**
$this->setFunctions(['openssl_pkey_new' => false]);
$install = new Installer();
- $this->assertFalse($install->checkKeys());
+ self::assertFalse($install->checkKeys());
$this->setFunctions(['openssl_pkey_new' => true]);
$install = new Installer();
- $this->assertTrue($install->checkKeys());
+ self::assertTrue($install->checkKeys());
}
/**
$this->mockFunctionL10TCalls();
$this->setFunctions(['curl_init' => false, 'imagecreatefromjpeg' => true]);
$install = new Installer();
- $this->assertFalse($install->checkFunctions());
- $this->assertCheckExist(3,
+ self::assertFalse($install->checkFunctions());
+ self::assertCheckExist(3,
'libCurl PHP module',
'Error: libCURL PHP module required but not installed.',
false,
$this->mockFunctionL10TCalls();
$this->setFunctions(['imagecreatefromjpeg' => false]);
$install = new Installer();
- $this->assertFalse($install->checkFunctions());
- $this->assertCheckExist(4,
+ self::assertFalse($install->checkFunctions());
+ self::assertCheckExist(4,
'GD graphics PHP module',
'Error: GD graphics PHP module with JPEG support required but not installed.',
false,
$this->mockFunctionL10TCalls();
$this->setFunctions(['openssl_public_encrypt' => false]);
$install = new Installer();
- $this->assertFalse($install->checkFunctions());
- $this->assertCheckExist(5,
+ self::assertFalse($install->checkFunctions());
+ self::assertCheckExist(5,
'OpenSSL PHP module',
'Error: openssl PHP module required but not installed.',
false,
$this->mockFunctionL10TCalls();
$this->setFunctions(['mb_strlen' => false]);
$install = new Installer();
- $this->assertFalse($install->checkFunctions());
- $this->assertCheckExist(6,
+ self::assertFalse($install->checkFunctions());
+ self::assertCheckExist(6,
'mb_string PHP module',
'Error: mb_string PHP module required but not installed.',
false,
$this->mockFunctionL10TCalls();
$this->setFunctions(['iconv_strlen' => false]);
$install = new Installer();
- $this->assertFalse($install->checkFunctions());
- $this->assertCheckExist(7,
+ self::assertFalse($install->checkFunctions());
+ self::assertCheckExist(7,
'iconv PHP module',
'Error: iconv PHP module required but not installed.',
false,
$this->mockFunctionL10TCalls();
$this->setFunctions(['posix_kill' => false]);
$install = new Installer();
- $this->assertFalse($install->checkFunctions());
- $this->assertCheckExist(8,
+ self::assertFalse($install->checkFunctions());
+ self::assertCheckExist(8,
'POSIX PHP module',
'Error: POSIX PHP module required but not installed.',
false,
$this->mockFunctionL10TCalls();
$this->setFunctions(['json_encode' => false]);
$install = new Installer();
- $this->assertFalse($install->checkFunctions());
- $this->assertCheckExist(9,
+ self::assertFalse($install->checkFunctions());
+ self::assertCheckExist(9,
'JSON PHP module',
'Error: JSON PHP module required but not installed.',
false,
$this->mockFunctionL10TCalls();
$this->setFunctions(['finfo_open' => false]);
$install = new Installer();
- $this->assertFalse($install->checkFunctions());
- $this->assertCheckExist(10,
+ self::assertFalse($install->checkFunctions());
+ self::assertCheckExist(10,
'File Information PHP module',
'Error: File Information PHP module required but not installed.',
false,
'finfo_open' => true,
]);
$install = new Installer();
- $this->assertTrue($install->checkFunctions());
+ self::assertTrue($install->checkFunctions());
}
/**
{
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
- $this->assertTrue($this->root->hasChild('config/local.config.php'));
+ self::assertTrue($this->root->hasChild('config/local.config.php'));
$install = new Installer();
- $this->assertTrue($install->checkLocalIni());
+ self::assertTrue($install->checkLocalIni());
$this->delConfigFile('local.config.php');
- $this->assertFalse($this->root->hasChild('config/local.config.php'));
+ self::assertFalse($this->root->hasChild('config/local.config.php'));
$install = new Installer();
- $this->assertTrue($install->checkLocalIni());
+ self::assertTrue($install->checkLocalIni());
}
/**
$install = new Installer();
- $this->assertFalse($install->checkHtAccess('https://test'));
- $this->assertSame('test Error', $install->getChecks()[0]['error_msg']['msg']);
+ self::assertFalse($install->checkHtAccess('https://test'));
+ self::assertSame('test Error', $install->getChecks()[0]['error_msg']['msg']);
}
/**
$install = new Installer();
- $this->assertTrue($install->checkHtAccess('https://test'));
+ self::assertTrue($install->checkHtAccess('https://test'));
}
/**
$install = new Installer();
// even there is no supported type, Imagick should return true (because it is not required)
- $this->assertTrue($install->checkImagick());
+ self::assertTrue($install->checkImagick());
- $this->assertCheckExist(1,
+ self::assertCheckExist(1,
$this->l10nMock->t('ImageMagick supports GIF'),
'',
true,
$install = new Installer();
// even there is no supported type, Imagick should return true (because it is not required)
- $this->assertTrue($install->checkImagick());
- $this->assertCheckExist(1,
+ self::assertTrue($install->checkImagick());
+ self::assertCheckExist(1,
$this->l10nMock->t('ImageMagick supports GIF'),
'',
false,
$install = new Installer();
// even there is no supported type, Imagick should return true (because it is not required)
- $this->assertTrue($install->checkImagick());
- $this->assertCheckExist(0,
+ self::assertTrue($install->checkImagick());
+ self::assertCheckExist(0,
'ImageMagick PHP extension is not installed',
'',
false,
*/
public function testDetectLanguage(array $server, array $get, string $default, string $assert)
{
- $this->assertEquals($assert, L10n::detectLanguage($server, $get, $default));
+ self::assertEquals($assert, L10n::detectLanguage($server, $get, $default));
}
}
*/
public function testLock()
{
- $this->assertFalse($this->instance->isLocked('foo'));
- $this->assertTrue($this->instance->acquire('foo', 1));
- $this->assertTrue($this->instance->isLocked('foo'));
- $this->assertFalse($this->instance->isLocked('bar'));
+ self::assertFalse($this->instance->isLocked('foo'));
+ self::assertTrue($this->instance->acquire('foo', 1));
+ self::assertTrue($this->instance->isLocked('foo'));
+ self::assertFalse($this->instance->isLocked('bar'));
}
/**
*/
public function testDoubleLock()
{
- $this->assertFalse($this->instance->isLocked('foo'));
- $this->assertTrue($this->instance->acquire('foo', 1));
- $this->assertTrue($this->instance->isLocked('foo'));
+ self::assertFalse($this->instance->isLocked('foo'));
+ self::assertTrue($this->instance->acquire('foo', 1));
+ self::assertTrue($this->instance->isLocked('foo'));
// We already locked it
- $this->assertTrue($this->instance->acquire('foo', 1));
+ self::assertTrue($this->instance->acquire('foo', 1));
}
/**
*/
public function testReleaseLock()
{
- $this->assertFalse($this->instance->isLocked('foo'));
- $this->assertTrue($this->instance->acquire('foo', 1));
- $this->assertTrue($this->instance->isLocked('foo'));
+ self::assertFalse($this->instance->isLocked('foo'));
+ self::assertTrue($this->instance->acquire('foo', 1));
+ self::assertTrue($this->instance->isLocked('foo'));
$this->instance->release('foo');
- $this->assertFalse($this->instance->isLocked('foo'));
+ self::assertFalse($this->instance->isLocked('foo'));
}
/**
*/
public function testReleaseAll()
{
- $this->assertTrue($this->instance->acquire('foo', 1));
- $this->assertTrue($this->instance->acquire('bar', 1));
- $this->assertTrue($this->instance->acquire('nice', 1));
+ self::assertTrue($this->instance->acquire('foo', 1));
+ self::assertTrue($this->instance->acquire('bar', 1));
+ self::assertTrue($this->instance->acquire('nice', 1));
- $this->assertTrue($this->instance->isLocked('foo'));
- $this->assertTrue($this->instance->isLocked('bar'));
- $this->assertTrue($this->instance->isLocked('nice'));
+ self::assertTrue($this->instance->isLocked('foo'));
+ self::assertTrue($this->instance->isLocked('bar'));
+ self::assertTrue($this->instance->isLocked('nice'));
- $this->assertTrue($this->instance->releaseAll());
+ self::assertTrue($this->instance->releaseAll());
- $this->assertFalse($this->instance->isLocked('foo'));
- $this->assertFalse($this->instance->isLocked('bar'));
- $this->assertFalse($this->instance->isLocked('nice'));
+ self::assertFalse($this->instance->isLocked('foo'));
+ self::assertFalse($this->instance->isLocked('bar'));
+ self::assertFalse($this->instance->isLocked('nice'));
}
/**
*/
public function testReleaseAfterUnlock()
{
- $this->assertFalse($this->instance->isLocked('foo'));
- $this->assertFalse($this->instance->isLocked('bar'));
- $this->assertFalse($this->instance->isLocked('nice'));
- $this->assertTrue($this->instance->acquire('foo', 1));
- $this->assertTrue($this->instance->acquire('bar', 1));
- $this->assertTrue($this->instance->acquire('nice', 1));
+ self::assertFalse($this->instance->isLocked('foo'));
+ self::assertFalse($this->instance->isLocked('bar'));
+ self::assertFalse($this->instance->isLocked('nice'));
+ self::assertTrue($this->instance->acquire('foo', 1));
+ self::assertTrue($this->instance->acquire('bar', 1));
+ self::assertTrue($this->instance->acquire('nice', 1));
- $this->assertTrue($this->instance->release('foo'));
+ self::assertTrue($this->instance->release('foo'));
- $this->assertFalse($this->instance->isLocked('foo'));
- $this->assertTrue($this->instance->isLocked('bar'));
- $this->assertTrue($this->instance->isLocked('nice'));
+ self::assertFalse($this->instance->isLocked('foo'));
+ self::assertTrue($this->instance->isLocked('bar'));
+ self::assertTrue($this->instance->isLocked('nice'));
- $this->assertTrue($this->instance->releaseAll());
+ self::assertTrue($this->instance->releaseAll());
- $this->assertFalse($this->instance->isLocked('bar'));
- $this->assertFalse($this->instance->isLocked('nice'));
+ self::assertFalse($this->instance->isLocked('bar'));
+ self::assertFalse($this->instance->isLocked('nice'));
}
/**
*/
public function testReleaseWitTTL()
{
- $this->assertFalse($this->instance->isLocked('test'));
- $this->assertTrue($this->instance->acquire('test', 1, 10));
- $this->assertTrue($this->instance->isLocked('test'));
- $this->assertTrue($this->instance->release('test'));
- $this->assertFalse($this->instance->isLocked('test'));
+ self::assertFalse($this->instance->isLocked('test'));
+ self::assertTrue($this->instance->acquire('test', 1, 10));
+ self::assertTrue($this->instance->isLocked('test'));
+ self::assertTrue($this->instance->release('test'));
+ self::assertFalse($this->instance->isLocked('test'));
}
/**
*/
public function testGetLocks()
{
- $this->assertTrue($this->instance->acquire('foo', 1));
- $this->assertTrue($this->instance->acquire('bar', 1));
- $this->assertTrue($this->instance->acquire('nice', 1));
+ self::assertTrue($this->instance->acquire('foo', 1));
+ self::assertTrue($this->instance->acquire('bar', 1));
+ self::assertTrue($this->instance->acquire('nice', 1));
- $this->assertTrue($this->instance->isLocked('foo'));
- $this->assertTrue($this->instance->isLocked('bar'));
- $this->assertTrue($this->instance->isLocked('nice'));
+ self::assertTrue($this->instance->isLocked('foo'));
+ self::assertTrue($this->instance->isLocked('bar'));
+ self::assertTrue($this->instance->isLocked('nice'));
$locks = $this->instance->getLocks();
- $this->assertContains('foo', $locks);
- $this->assertContains('bar', $locks);
- $this->assertContains('nice', $locks);
+ self::assertContains('foo', $locks);
+ self::assertContains('bar', $locks);
+ self::assertContains('nice', $locks);
}
/**
*/
public function testGetLocksWithPrefix()
{
- $this->assertTrue($this->instance->acquire('foo', 1));
- $this->assertTrue($this->instance->acquire('test1', 1));
- $this->assertTrue($this->instance->acquire('test2', 1));
+ self::assertTrue($this->instance->acquire('foo', 1));
+ self::assertTrue($this->instance->acquire('test1', 1));
+ self::assertTrue($this->instance->acquire('test2', 1));
- $this->assertTrue($this->instance->isLocked('foo'));
- $this->assertTrue($this->instance->isLocked('test1'));
- $this->assertTrue($this->instance->isLocked('test2'));
+ self::assertTrue($this->instance->isLocked('foo'));
+ self::assertTrue($this->instance->isLocked('test1'));
+ self::assertTrue($this->instance->isLocked('test2'));
$locks = $this->instance->getLocks('test');
- $this->assertContains('test1', $locks);
- $this->assertContains('test2', $locks);
- $this->assertNotContains('foo', $locks);
+ self::assertContains('test1', $locks);
+ self::assertContains('test2', $locks);
+ self::assertNotContains('foo', $locks);
}
/**
{
$this->markTestSkipped('taking too much time without mocking');
- $this->assertFalse($this->instance->isLocked('foo'));
- $this->assertFalse($this->instance->isLocked('bar'));
+ self::assertFalse($this->instance->isLocked('foo'));
+ self::assertFalse($this->instance->isLocked('bar'));
// TODO [nupplaphil] - Because of the Datetime-Utils for the database, we have to wait a FULL second between the checks to invalidate the db-locks/cache
- $this->assertTrue($this->instance->acquire('foo', 2, 1));
- $this->assertTrue($this->instance->acquire('bar', 2, 3));
+ self::assertTrue($this->instance->acquire('foo', 2, 1));
+ self::assertTrue($this->instance->acquire('bar', 2, 3));
- $this->assertTrue($this->instance->isLocked('foo'));
- $this->assertTrue($this->instance->isLocked('bar'));
+ self::assertTrue($this->instance->isLocked('foo'));
+ self::assertTrue($this->instance->isLocked('bar'));
sleep(2);
- $this->assertFalse($this->instance->isLocked('foo'));
- $this->assertTrue($this->instance->isLocked('bar'));
+ self::assertFalse($this->instance->isLocked('foo'));
+ self::assertTrue($this->instance->isLocked('bar'));
sleep(2);
- $this->assertFalse($this->instance->isLocked('foo'));
- $this->assertFalse($this->instance->isLocked('bar'));
+ self::assertFalse($this->instance->isLocked('foo'));
+ self::assertFalse($this->instance->isLocked('bar'));
}
/**
*/
public function testReleaseLockWithoutLock()
{
- $this->assertFalse($this->instance->isLocked('wrongLock'));
- $this->assertFalse($this->instance->release('wrongLock'));
+ self::assertFalse($this->instance->isLocked('wrongLock'));
+ self::assertFalse($this->instance->release('wrongLock'));
}
}
$file = get_temppath() . '/test.sem';
touch($file);
- $this->assertTrue(file_exists($file));
- $this->assertFalse($this->instance->release('test', false));
- $this->assertTrue(file_exists($file));
+ self::assertTrue(file_exists($file));
+ self::assertFalse($this->instance->release('test', false));
+ self::assertTrue(file_exists($file));
}
/**
$file = get_temppath() . '/test.sem';
touch($file);
- $this->assertTrue(file_exists($file));
- $this->assertFalse($this->instance->release('test', true));
- $this->assertTrue(file_exists($file));
+ self::assertTrue(file_exists($file));
+ self::assertFalse($this->instance->release('test', true));
+ self::assertTrue(file_exists($file));
}
/**
$file = get_temppath() . '/test.sem';
touch($file);
- $this->assertTrue(file_exists($file));
- $this->assertTrue($this->instance->acquire('test'));
- $this->assertTrue($this->instance->isLocked('test'));
- $this->assertTrue($this->instance->release('test'));
+ self::assertTrue(file_exists($file));
+ self::assertTrue($this->instance->acquire('test'));
+ self::assertTrue($this->instance->isLocked('test'));
+ self::assertTrue($this->instance->release('test'));
}
}
{
foreach ($data as $cat => $values) {
foreach ($values as $key => $value) {
- $this->assertEquals($data[$cat][$key], $configCache->get($uid, $cat, $key));
+ self::assertEquals($data[$cat][$key], $configCache->get($uid, $cat, $key));
}
}
}
}
}
- $this->assertConfigValues($data, $configCache, $uid);
+ self::assertConfigValues($data, $configCache, $uid);
}
],
]);
- $this->assertEquals([
+ self::assertEquals([
'key1' => 'value1',
'key2' => 'value2',
], $configCache->get($uid, 'system'));
// test explicit cat with null as key
- $this->assertEquals([
+ self::assertEquals([
'key1' => 'value1',
'key2' => 'value2',
], $configCache->get($uid, 'system', null));
}
}
- $this->assertEmpty($configCache->getAll());
+ self::assertEmpty($configCache->getAll());
}
/**
]
];
- $this->assertEquals($diffConfig, $configCache->keyDiff($diffConfig));
+ self::assertEquals($diffConfig, $configCache->keyDiff($diffConfig));
}
/**
$diffConfig = $configCache->getAll();
- $this->assertEmpty($configCache->keyDiff($diffConfig));
+ self::assertEmpty($configCache->keyDiff($diffConfig));
}
/**
]
]);
- $this->assertEquals('supersecure', $configCache->get(1, 'database', 'password'));
- $this->assertNotEquals('supersecure', print_r($configCache->get(1, 'database', 'password'), true));
- $this->assertEquals('notsecured', print_r($configCache->get(1, 'database', 'username'), true));
+ self::assertEquals('supersecure', $configCache->get(1, 'database', 'password'));
+ self::assertNotEquals('supersecure', print_r($configCache->get(1, 'database', 'password'), true));
+ self::assertEquals('notsecured', print_r($configCache->get(1, 'database', 'username'), true));
}
/**
]
]);
- $this->assertEquals('supersecure', $configCache->get(1, 'database', 'password'));
- $this->assertEquals('supersecure', print_r($configCache->get(1, 'database', 'password'), true));
- $this->assertEquals('notsecured', print_r($configCache->get(1, 'database', 'username'), true));
+ self::assertEquals('supersecure', $configCache->get(1, 'database', 'password'));
+ self::assertEquals('supersecure', print_r($configCache->get(1, 'database', 'password'), true));
+ self::assertEquals('notsecured', print_r($configCache->get(1, 'database', 'username'), true));
}
/**
]
]);
- $this->assertEmpty($configCache->get(1, 'database', 'password'));
- $this->assertEmpty($configCache->get(1, 'database', 'username'));
+ self::assertEmpty($configCache->get(1, 'database', 'password'));
+ self::assertEmpty($configCache->get(1, 'database', 'username'));
}
public function testWrongTypePassword()
]
]);
- $this->assertNotEmpty($configCache->get(1, 'database', 'password'));
- $this->assertEmpty($configCache->get(1, 'database', 'username'));
+ self::assertNotEmpty($configCache->get(1, 'database', 'password'));
+ self::assertEmpty($configCache->get(1, 'database', 'username'));
$configCache = new Cache();
],
]);
- $this->assertEquals(23, $configCache->get(1, 'database', 'password'));
- $this->assertEmpty($configCache->get(1, 'database', 'username'));
+ self::assertEquals(23, $configCache->get(1, 'database', 'password'));
+ self::assertEmpty($configCache->get(1, 'database', 'username'));
}
/**
],
]);
- $this->assertEquals('value1', $configCache->get(1, 'cat1', 'key1'));
- $this->assertEquals('value2', $configCache->get(2, 'cat2', 'key2'));
+ self::assertEquals('value1', $configCache->get(1, 'cat1', 'key1'));
+ self::assertEquals('value2', $configCache->get(2, 'cat2', 'key2'));
- $this->assertNull($configCache->get(1, 'cat2', 'key2'));
- $this->assertNull($configCache->get(2, 'cat1', 'key1'));
+ self::assertNull($configCache->get(1, 'cat2', 'key2'));
+ self::assertNull($configCache->get(2, 'cat1', 'key1'));
}
/**
$configCache = new Cache();
- $this->assertNull($configCache->get($uid, 'cat1', 'cat2'));
+ self::assertNull($configCache->get($uid, 'cat1', 'cat2'));
- $this->assertFalse($configCache->set($uid, 'cat1', 'key1', 'doesn\'t matter!'));
- $this->assertFalse($configCache->delete($uid, 'cat1', 'key1'));
+ self::assertFalse($configCache->set($uid, 'cat1', 'key1', 'doesn\'t matter!'));
+ self::assertFalse($configCache->delete($uid, 'cat1', 'key1'));
}
}
// Assert the expected categories
foreach ($data2 as $cat => $data) {
- $this->assertConfig($uid, $cat, $expect[$cat]);
+ self::assertConfig($uid, $cat, $expect[$cat]);
}
}
{
$result = $this->testedConfig->getCache()->getAll();
- $this->assertNotEmpty($result);
- $this->assertArrayHasKey($uid, $result);
- $this->assertArrayHasKey($cat, $result[$uid]);
- $this->assertArraySubset($data, $result[$uid][$cat]);
+ self::assertNotEmpty($result);
+ self::assertArrayHasKey($uid, $result);
+ self::assertArrayHasKey($cat, $result[$uid]);
+ self::assertArraySubset($data, $result[$uid][$cat]);
}
public function testSetUp(int $uid, array $data)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
- $this->assertEmpty($this->testedConfig->getCache()->getAll());
+ self::assertEmpty($this->testedConfig->getCache()->getAll());
}
/**
public function testLoad(int $uid, array $data, array $possibleCats, array $load)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
foreach ($load as $loadedCats) {
$this->testedConfig->load($uid, $loadedCats);
// Assert at least loaded cats are loaded
foreach ($load as $loadedCats) {
- $this->assertConfig($uid, $loadedCats, $data[$loadedCats]);
+ self::assertConfig($uid, $loadedCats, $data[$loadedCats]);
}
}
public function testCacheLoadDouble(int $uid, array $data1, array $data2, array $expect)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
foreach ($data1 as $cat => $data) {
$this->testedConfig->load($uid, $cat);
// Assert at least loaded cats are loaded
foreach ($data1 as $cat => $data) {
- $this->assertConfig($uid, $cat, $data);
+ self::assertConfig($uid, $cat, $data);
}
foreach ($data2 as $cat => $data) {
public function testSetGetWithoutDB(int $uid, $data)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
- $this->assertTrue($this->testedConfig->set($uid, 'test', 'it', $data));
+ self::assertTrue($this->testedConfig->set($uid, 'test', 'it', $data));
- $this->assertEquals($data, $this->testedConfig->get($uid, 'test', 'it'));
- $this->assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it'));
+ self::assertEquals($data, $this->testedConfig->get($uid, 'test', 'it'));
+ self::assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it'));
}
/**
->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
- $this->assertTrue($this->testedConfig->set($uid, 'test', 'it', $data));
+ self::assertTrue($this->testedConfig->set($uid, 'test', 'it', $data));
- $this->assertEquals($data, $this->testedConfig->get($uid, 'test', 'it'));
- $this->assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it'));
+ self::assertEquals($data, $this->testedConfig->get($uid, 'test', 'it'));
+ self::assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it'));
}
/**
public function testGetWrongWithoutDB()
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// without refresh
- $this->assertNull($this->testedConfig->get(0, 'test', 'it'));
+ self::assertNull($this->testedConfig->get(0, 'test', 'it'));
/// beware that the cache returns '!<unset>!' and not null for a non existing value
- $this->assertNull($this->testedConfig->getCache()->get(0, 'test', 'it'));
+ self::assertNull($this->testedConfig->getCache()->get(0, 'test', 'it'));
// with default value
- $this->assertEquals('default', $this->testedConfig->get(0, 'test', 'it', 'default'));
+ self::assertEquals('default', $this->testedConfig->get(0, 'test', 'it', 'default'));
// with default value and refresh
- $this->assertEquals('default', $this->testedConfig->get(0, 'test', 'it', 'default', true));
+ self::assertEquals('default', $this->testedConfig->get(0, 'test', 'it', 'default', true));
}
/**
$this->configCache->load($uid, ['test' => ['it' => 'now']]);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// without refresh
- $this->assertEquals('now', $this->testedConfig->get($uid, 'test', 'it'));
- $this->assertEquals('now', $this->testedConfig->getCache()->get($uid, 'test', 'it'));
+ self::assertEquals('now', $this->testedConfig->get($uid, 'test', 'it'));
+ self::assertEquals('now', $this->testedConfig->getCache()->get($uid, 'test', 'it'));
// with refresh
- $this->assertEquals($data, $this->testedConfig->get($uid, 'test', 'it', null, true));
- $this->assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it'));
+ self::assertEquals($data, $this->testedConfig->get($uid, 'test', 'it', null, true));
+ self::assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it'));
// without refresh and wrong value and default
- $this->assertEquals('default', $this->testedConfig->get($uid, 'test', 'not', 'default'));
- $this->assertNull($this->testedConfig->getCache()->get($uid, 'test', 'not'));
+ self::assertEquals('default', $this->testedConfig->get($uid, 'test', 'not', 'default'));
+ self::assertNull($this->testedConfig->getCache()->get($uid, 'test', 'not'));
}
/**
$this->configCache->load($uid, ['test' => ['it' => $data]]);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
- $this->assertEquals($data, $this->testedConfig->get($uid, 'test', 'it'));
- $this->assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it'));
+ self::assertEquals($data, $this->testedConfig->get($uid, 'test', 'it'));
+ self::assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it'));
- $this->assertTrue($this->testedConfig->delete($uid, 'test', 'it'));
- $this->assertNull($this->testedConfig->get($uid, 'test', 'it'));
- $this->assertNull($this->testedConfig->getCache()->get($uid, 'test', 'it'));
+ self::assertTrue($this->testedConfig->delete($uid, 'test', 'it'));
+ self::assertNull($this->testedConfig->get($uid, 'test', 'it'));
+ self::assertNull($this->testedConfig->getCache()->get($uid, 'test', 'it'));
- $this->assertEmpty($this->testedConfig->getCache()->getAll());
+ self::assertEmpty($this->testedConfig->getCache()->getAll());
}
/**
->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// directly set the value to the cache
$this->testedConfig->getCache()->set($uid, 'test', 'it', 'now');
- $this->assertEquals('now', $this->testedConfig->get($uid, 'test', 'it'));
- $this->assertEquals('now', $this->testedConfig->getCache()->get($uid, 'test', 'it'));
+ self::assertEquals('now', $this->testedConfig->get($uid, 'test', 'it'));
+ self::assertEquals('now', $this->testedConfig->getCache()->get($uid, 'test', 'it'));
// delete from cache only
- $this->assertTrue($this->testedConfig->delete($uid, 'test', 'it'));
+ self::assertTrue($this->testedConfig->delete($uid, 'test', 'it'));
// delete from db only
- $this->assertTrue($this->testedConfig->delete($uid, 'test', 'second'));
+ self::assertTrue($this->testedConfig->delete($uid, 'test', 'second'));
// no delete
- $this->assertFalse($this->testedConfig->delete($uid, 'test', 'third'));
+ self::assertFalse($this->testedConfig->delete($uid, 'test', 'third'));
// delete both
- $this->assertTrue($this->testedConfig->delete($uid, 'test', 'quarter'));
+ self::assertTrue($this->testedConfig->delete($uid, 'test', 'quarter'));
- $this->assertEmpty($this->testedConfig->getCache()->getAll());
+ self::assertEmpty($this->testedConfig->getCache()->getAll());
}
public function dataMultiUid()
$this->configCache->load($data2['uid'], $data2['data']);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
+ self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
- $this->assertConfig($data1['uid'], 'cat1', $data1['data']['cat1']);
- $this->assertConfig($data1['uid'], 'cat2', $data1['data']['cat2']);
- $this->assertConfig($data2['uid'], 'cat1', $data2['data']['cat1']);
- $this->assertConfig($data2['uid'], 'cat2', $data2['data']['cat2']);
+ self::assertConfig($data1['uid'], 'cat1', $data1['data']['cat1']);
+ self::assertConfig($data1['uid'], 'cat2', $data1['data']['cat2']);
+ self::assertConfig($data2['uid'], 'cat1', $data2['data']['cat1']);
+ self::assertConfig($data2['uid'], 'cat2', $data2['data']['cat2']);
}
/**
$this->testedConfig = $this->getInstance();
- $this->assertNull($this->testedConfig->get($uid, 'cat1', 'cat2'));
- $this->assertEquals('fallback!', $this->testedConfig->get($uid, 'cat1', 'cat2', 'fallback!'));
+ self::assertNull($this->testedConfig->get($uid, 'cat1', 'cat2'));
+ self::assertEquals('fallback!', $this->testedConfig->get($uid, 'cat1', 'cat2', 'fallback!'));
- $this->assertFalse($this->testedConfig->set($uid, 'cat1', 'key1', 'doesn\'t matter!'));
- $this->assertFalse($this->testedConfig->delete($uid, 'cat1', 'key1'));
+ self::assertFalse($this->testedConfig->set($uid, 'cat1', 'key1', 'doesn\'t matter!'));
+ self::assertFalse($this->testedConfig->delete($uid, 'cat1', 'key1'));
}
}
// Assert that every category is loaded everytime
foreach ($data as $cat => $values) {
- $this->assertConfig($uid, $cat, $values);
+ self::assertConfig($uid, $cat, $values);
}
}
// Assert that every category is loaded everytime and is NOT overwritten
foreach ($data1 as $cat => $values) {
- $this->assertConfig($uid, $cat, $values);
+ self::assertConfig($uid, $cat, $values);
}
}
{
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
- $this->assertInstanceOf(StorageManager::class, $storageManager);
+ self::assertInstanceOf(StorageManager::class, $storageManager);
}
public function dataStorages()
$storage = $storageManager->getByName($name, $userBackend);
if (!empty($assert)) {
- $this->assertInstanceOf(Storage\IStorage::class, $storage);
- $this->assertInstanceOf($assert, $storage);
+ self::assertInstanceOf(Storage\IStorage::class, $storage);
+ self::assertInstanceOf($assert, $storage);
} else {
- $this->assertNull($storage);
+ self::assertNull($storage);
}
- $this->assertEquals($assertName, $storage);
+ self::assertEquals($assertName, $storage);
}
/**
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
// true in every of the backends
- $this->assertEquals(!empty($assertName), $storageManager->isValidBackend($name));
+ self::assertEquals(!empty($assertName), $storageManager->isValidBackend($name));
// if userBackend is set to true, filter out e.g. SystemRessource
- $this->assertEquals($userBackend, $storageManager->isValidBackend($name, true));
+ self::assertEquals($userBackend, $storageManager->isValidBackend($name, true));
}
/**
{
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
- $this->assertEquals(StorageManager::DEFAULT_BACKENDS, $storageManager->listBackends());
+ self::assertEquals(StorageManager::DEFAULT_BACKENDS, $storageManager->listBackends());
}
/**
{
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
- $this->assertNull($storageManager->getBackend());
+ self::assertNull($storageManager->getBackend());
if ($userBackend) {
$storageManager->setBackend($name);
- $this->assertInstanceOf($assert, $storageManager->getBackend());
+ self::assertInstanceOf($assert, $storageManager->getBackend());
}
}
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
if ($userBackend) {
- $this->assertInstanceOf($assert, $storageManager->getBackend());
+ self::assertInstanceOf($assert, $storageManager->getBackend());
} else {
- $this->assertNull($storageManager->getBackend());
+ self::assertNull($storageManager->getBackend());
}
}
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
- $this->assertTrue($storageManager->register(SampleStorageBackend::class));
+ self::assertTrue($storageManager->register(SampleStorageBackend::class));
- $this->assertEquals(array_merge(StorageManager::DEFAULT_BACKENDS, [
+ self::assertEquals(array_merge(StorageManager::DEFAULT_BACKENDS, [
SampleStorageBackend::getName() => SampleStorageBackend::class,
]), $storageManager->listBackends());
- $this->assertEquals(array_merge(StorageManager::DEFAULT_BACKENDS, [
+ self::assertEquals(array_merge(StorageManager::DEFAULT_BACKENDS, [
SampleStorageBackend::getName() => SampleStorageBackend::class,
]), $this->config->get('storage', 'backends'));
SampleStorageBackend::registerHook();
Hook::loadHooks();
- $this->assertTrue($storageManager->setBackend(SampleStorageBackend::NAME));
- $this->assertEquals(SampleStorageBackend::NAME, $this->config->get('storage', 'name'));
+ self::assertTrue($storageManager->setBackend(SampleStorageBackend::NAME));
+ self::assertEquals(SampleStorageBackend::NAME, $this->config->get('storage', 'name'));
- $this->assertInstanceOf(SampleStorageBackend::class, $storageManager->getBackend());
+ self::assertInstanceOf(SampleStorageBackend::class, $storageManager->getBackend());
- $this->assertTrue($storageManager->unregister(SampleStorageBackend::class));
- $this->assertEquals(StorageManager::DEFAULT_BACKENDS, $this->config->get('storage', 'backends'));
- $this->assertEquals(StorageManager::DEFAULT_BACKENDS, $storageManager->listBackends());
+ self::assertTrue($storageManager->unregister(SampleStorageBackend::class));
+ self::assertEquals(StorageManager::DEFAULT_BACKENDS, $this->config->get('storage', 'backends'));
+ self::assertEquals(StorageManager::DEFAULT_BACKENDS, $storageManager->listBackends());
- $this->assertNull($storageManager->getBackend());
- $this->assertNull($this->config->get('storage', 'name'));
+ self::assertNull($storageManager->getBackend());
+ self::assertNull($this->config->get('storage', 'name'));
}
/**
while ($photo = $this->dba->fetch($photos)) {
- $this->assertEmpty($photo['data']);
+ self::assertEmpty($photo['data']);
$storage = $storageManager->getByName($photo['backend-class']);
$data = $storage->get($photo['backend-ref']);
- $this->assertNotEmpty($data);
+ self::assertNotEmpty($data);
}
}
private function assertGuid($guid, $length, $prefix = '')
{
$length -= strlen($prefix);
- $this->assertRegExp("/^" . $prefix . "[a-z0-9]{" . $length . "}?$/", $guid);
+ self::assertRegExp("/^" . $prefix . "[a-z0-9]{" . $length . "}?$/", $guid);
}
function testGuidWithoutParameter()
{
$this->useBaseUrl();
$guid = System::createGUID();
- $this->assertGuid($guid, 16);
+ self::assertGuid($guid, 16);
}
function testGuidWithSize32()
{
$this->useBaseUrl();
$guid = System::createGUID(32);
- $this->assertGuid($guid, 32);
+ self::assertGuid($guid, 32);
}
function testGuidWithSize64()
{
$this->useBaseUrl();
$guid = System::createGUID(64);
- $this->assertGuid($guid, 64);
+ self::assertGuid($guid, 64);
}
function testGuidWithPrefix()
{
$guid = System::createGUID(23, 'test');
- $this->assertGuid($guid, 23, 'test');
+ self::assertGuid($guid, 23, 'test');
}
}
*/
public function testExists() {
- $this->assertTrue(DBA::exists('config', []));
- $this->assertFalse(DBA::exists('notable', []));
+ self::assertTrue(DBA::exists('config', []));
+ self::assertFalse(DBA::exists('notable', []));
- $this->assertTrue(DBA::exists('config', null));
- $this->assertFalse(DBA::exists('notable', null));
+ self::assertTrue(DBA::exists('config', null));
+ self::assertFalse(DBA::exists('notable', null));
- $this->assertTrue(DBA::exists('config', ['k' => 'hostname']));
- $this->assertFalse(DBA::exists('config', ['k' => 'nonsense']));
+ self::assertTrue(DBA::exists('config', ['k' => 'hostname']));
+ self::assertFalse(DBA::exists('config', ['k' => 'nonsense']));
}
}
* @small
*/
public function testExists() {
- $this->assertTrue(DBStructure::existsTable('config'));
+ self::assertTrue(DBStructure::existsTable('config'));
- $this->assertFalse(DBStructure::existsTable('notatable'));
+ self::assertFalse(DBStructure::existsTable('notatable'));
- $this->assertTrue(DBStructure::existsColumn('config', ['k']));
- $this->assertFalse(DBStructure::existsColumn('config', ['nonsense']));
- $this->assertFalse(DBStructure::existsColumn('config', ['k', 'nonsense']));
+ self::assertTrue(DBStructure::existsColumn('config', ['k']));
+ self::assertFalse(DBStructure::existsColumn('config', ['nonsense']));
+ self::assertFalse(DBStructure::existsColumn('config', ['k', 'nonsense']));
}
/**
$fromType = 'varbinary(255) not null';
$toType = 'varbinary(255) not null comment \'Test To Type\'';
- $this->assertTrue(DBStructure::rename('config', [ $fromColumn => [ $toColumn, $toType ]]));
- $this->assertTrue(DBStructure::existsColumn('config', [ $toColumn ]));
- $this->assertFalse(DBStructure::existsColumn('config', [ $fromColumn ]));
+ self::assertTrue(DBStructure::rename('config', [ $fromColumn => [ $toColumn, $toType ]]));
+ self::assertTrue(DBStructure::existsColumn('config', [ $toColumn ]));
+ self::assertFalse(DBStructure::existsColumn('config', [ $fromColumn ]));
- $this->assertTrue(DBStructure::rename('config', [ $toColumn => [ $fromColumn, $fromType ]]));
- $this->assertTrue(DBStructure::existsColumn('config', [ $fromColumn ]));
- $this->assertFalse(DBStructure::existsColumn('config', [ $toColumn ]));
+ self::assertTrue(DBStructure::rename('config', [ $toColumn => [ $fromColumn, $fromType ]]));
+ self::assertTrue(DBStructure::existsColumn('config', [ $fromColumn ]));
+ self::assertFalse(DBStructure::existsColumn('config', [ $toColumn ]));
}
/**
$oldID = 'client_id';
$newID = 'pw';
- $this->assertTrue(DBStructure::rename('clients', [ $newID ], DBStructure::RENAME_PRIMARY_KEY));
- $this->assertTrue(DBStructure::rename('clients', [ $oldID ], DBStructure::RENAME_PRIMARY_KEY));
+ self::assertTrue(DBStructure::rename('clients', [ $newID ], DBStructure::RENAME_PRIMARY_KEY));
+ self::assertTrue(DBStructure::rename('clients', [ $oldID ], DBStructure::RENAME_PRIMARY_KEY));
}
}
*/
public function testArrayToFile(array $array, string $type, string $file)
{
- $this->assertEquals($file, FileTag::arrayToFile($array, $type));
+ self::assertEquals($file, FileTag::arrayToFile($array, $type));
}
public function dataFileToArray()
*/
public function testFileToArray(string $file, string $type, array $array)
{
- $this->assertEquals($array, FileTag::fileToArray($file, $type));
+ self::assertEquals($array, FileTag::fileToArray($file, $type));
}
}
{
$process = new Process($this->dba);
- $this->assertEquals(0, $this->dba->count('process'));
+ self::assertEquals(0, $this->dba->count('process'));
$process->insert('test', 1);
$process->insert('test2', 2);
$process->insert('test3', 3);
- $this->assertEquals(3, $this->dba->count('process'));
+ self::assertEquals(3, $this->dba->count('process'));
- $this->assertEquals([
+ self::assertEquals([
['command' => 'test']
], $this->dba->selectToArray('process', ['command'], ['pid' => 1]));
$process->deleteByPid(1);
- $this->assertEmpty($this->dba->selectToArray('process', ['command'], ['pid' => 1]));
+ self::assertEmpty($this->dba->selectToArray('process', ['command'], ['pid' => 1]));
- $this->assertEquals(2, $this->dba->count('process'));
+ self::assertEquals(2, $this->dba->count('process'));
}
public function testDoubleInsert()
// double insert doesn't work
$process->insert('test23', 1);
- $this->assertEquals([['command' => 'test']], $this->dba->selectToArray('process', ['command'], ['pid' => 1]));
+ self::assertEquals([['command' => 'test']], $this->dba->selectToArray('process', ['command'], ['pid' => 1]));
}
public function testWrongDelete()
protected function assertOption(IStorage $storage)
{
- $this->assertEmpty($storage->getOptions());
+ self::assertEmpty($storage->getOptions());
}
}
protected function assertOption(IStorage $storage)
{
- $this->assertEquals([
+ self::assertEquals([
'storagepath' => [
'input', 'Storage base path',
$this->root->getChild('storage')->url(),
$dir = $this->root->getChild('storage/f0/c0')->url();
$file = $this->root->getChild('storage/f0/c0/d0i0')->url();
- $this->assertDirectoryExists($dir);
- $this->assertFileExists($file);
+ self::assertDirectoryExists($dir);
+ self::assertFileExists($file);
- $this->assertDirectoryIsWritable($dir);
- $this->assertFileIsWritable($file);
+ self::assertDirectoryIsWritable($dir);
+ self::assertFileIsWritable($file);
- $this->assertEquals('test', file_get_contents($file));
+ self::assertEquals('test', file_get_contents($file));
}
}
public function testInstance()
{
$instance = $this->getInstance();
- $this->assertInstanceOf(IStorage::class, $instance);
+ self::assertInstanceOf(IStorage::class, $instance);
}
/**
$instance = $this->getInstance();
$ref = $instance->put('data12345');
- $this->assertNotEmpty($ref);
+ self::assertNotEmpty($ref);
- $this->assertEquals('data12345', $instance->get($ref));
+ self::assertEquals('data12345', $instance->get($ref));
- $this->assertTrue($instance->delete($ref));
+ self::assertTrue($instance->delete($ref));
}
/**
$instance = $this->getInstance();
// Even deleting not existing references should return "true"
- $this->assertTrue($instance->delete(-1234456));
+ self::assertTrue($instance->delete(-1234456));
}
/**
$instance = $this->getInstance();
// Invalid references return an empty string
- $this->assertEmpty($instance->get(-123456));
+ self::assertEmpty($instance->get(-123456));
}
/**
$instance = $this->getInstance();
$ref = $instance->put('data12345');
- $this->assertNotEmpty($ref);
+ self::assertNotEmpty($ref);
- $this->assertEquals('data12345', $instance->get($ref));
+ self::assertEquals('data12345', $instance->get($ref));
- $this->assertEquals($ref, $instance->put('data5432', $ref));
- $this->assertEquals('data5432', $instance->get($ref));
+ self::assertEquals($ref, $instance->put('data5432', $ref));
+ self::assertEquals('data5432', $instance->get($ref));
}
/**
{
$instance = $this->getInstance();
- $this->assertEquals(-123, $instance->put('data12345', -123));
+ self::assertEquals(-123, $instance->put('data12345', -123));
}
}
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn('7')->once();
$cookie = new Cookie($this->config, $this->baseUrl);
- $this->assertInstanceOf(Cookie::class, $cookie);
+ self::assertInstanceOf(Cookie::class, $cookie);
}
public function dataGet()
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn('7')->once();
$cookie = new Cookie($this->config, $this->baseUrl, [], $cookieData);
- $this->assertInstanceOf(Cookie::class, $cookie);
+ self::assertInstanceOf(Cookie::class, $cookie);
$assertData = $cookie->getData();
if (!$hasValues) {
- $this->assertEmpty($assertData);
+ self::assertEmpty($assertData);
} else {
- $this->assertNotEmpty($assertData);
+ self::assertNotEmpty($assertData);
if (isset($uid)) {
- $this->assertObjectHasAttribute('uid', $assertData);
- $this->assertEquals($uid, $assertData->uid);
+ self::assertObjectHasAttribute('uid', $assertData);
+ self::assertEquals($uid, $assertData->uid);
} else {
- $this->assertObjectNotHasAttribute('uid', $assertData);
+ self::assertObjectNotHasAttribute('uid', $assertData);
}
if (isset($hash)) {
- $this->assertObjectHasAttribute('hash', $assertData);
- $this->assertEquals($hash, $assertData->hash);
+ self::assertObjectHasAttribute('hash', $assertData);
+ self::assertEquals($hash, $assertData->hash);
} else {
- $this->assertObjectNotHasAttribute('hash', $assertData);
+ self::assertObjectNotHasAttribute('hash', $assertData);
}
if (isset($ip)) {
- $this->assertObjectHasAttribute('ip', $assertData);
- $this->assertEquals($ip, $assertData->ip);
+ self::assertObjectHasAttribute('ip', $assertData);
+ self::assertEquals($ip, $assertData->ip);
} else {
- $this->assertObjectNotHasAttribute('ip', $assertData);
+ self::assertObjectNotHasAttribute('ip', $assertData);
}
}
}
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn('7')->once();
$cookie = new Cookie($this->config, $this->baseUrl);
- $this->assertInstanceOf(Cookie::class, $cookie);
+ self::assertInstanceOf(Cookie::class, $cookie);
- $this->assertEquals($assertTrue, $cookie->check($assertHash, $password, $userPrivateKey));
+ self::assertEquals($assertTrue, $cookie->check($assertHash, $password, $userPrivateKey));
}
public function dataSet()
public function assertCookie($uid, $hash, $remoteIp, $lifetime)
{
- $this->assertArrayHasKey(Cookie::NAME, StaticCookie::$_COOKIE);
+ self::assertArrayHasKey(Cookie::NAME, StaticCookie::$_COOKIE);
$data = json_decode(StaticCookie::$_COOKIE[Cookie::NAME]);
- $this->assertObjectHasAttribute('uid', $data);
- $this->assertEquals($uid, $data->uid);
- $this->assertObjectHasAttribute('hash', $data);
- $this->assertEquals($hash, $data->hash);
- $this->assertObjectHasAttribute('ip', $data);
- $this->assertEquals($remoteIp, $data->ip);
+ self::assertObjectHasAttribute('uid', $data);
+ self::assertEquals($uid, $data->uid);
+ self::assertObjectHasAttribute('hash', $data);
+ self::assertEquals($hash, $data->hash);
+ self::assertObjectHasAttribute('ip', $data);
+ self::assertEquals($remoteIp, $data->ip);
if (isset($lifetime) && $lifetime !== 0) {
- $this->assertLessThanOrEqual(time() + $lifetime, StaticCookie::$_EXPIRE);
+ self::assertLessThanOrEqual(time() + $lifetime, StaticCookie::$_EXPIRE);
} else {
- $this->assertLessThanOrEqual(time() + Cookie::DEFAULT_EXPIRE * 24 * 60 * 60, StaticCookie::$_EXPIRE);
+ self::assertLessThanOrEqual(time() + Cookie::DEFAULT_EXPIRE * 24 * 60 * 60, StaticCookie::$_EXPIRE);
}
}
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn(Cookie::DEFAULT_EXPIRE)->once();
$cookie = new StaticCookie($this->config, $this->baseUrl, $serverArray);
- $this->assertInstanceOf(Cookie::class, $cookie);
+ self::assertInstanceOf(Cookie::class, $cookie);
$cookie->set($uid, $password, $privateKey, $lifetime);
- $this->assertCookie($uid, $assertHash, $remoteIp, $lifetime);
+ self::assertCookie($uid, $assertHash, $remoteIp, $lifetime);
}
/**
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn(Cookie::DEFAULT_EXPIRE)->once();
$cookie = new StaticCookie($this->config, $this->baseUrl, $serverArray);
- $this->assertInstanceOf(Cookie::class, $cookie);
+ self::assertInstanceOf(Cookie::class, $cookie);
// Invalid set, should get overwritten
$cookie->set(-1, 'invalid', 'nothing', -234);
$cookie->set($uid, $password, $privateKey, $lifetime);
- $this->assertCookie($uid, $assertHash, $remoteIp, $lifetime);
+ self::assertCookie($uid, $assertHash, $remoteIp, $lifetime);
}
/**
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn(Cookie::DEFAULT_EXPIRE)->once();
$cookie = new StaticCookie($this->config, $this->baseUrl);
- $this->assertInstanceOf(Cookie::class, $cookie);
+ self::assertInstanceOf(Cookie::class, $cookie);
- $this->assertEquals('test', StaticCookie::$_COOKIE[Cookie::NAME]);
- $this->assertEquals(null, StaticCookie::$_EXPIRE);
+ self::assertEquals('test', StaticCookie::$_COOKIE[Cookie::NAME]);
+ self::assertEquals(null, StaticCookie::$_EXPIRE);
$cookie->clear();
- $this->assertEmpty(StaticCookie::$_COOKIE[Cookie::NAME]);
- $this->assertEquals(-3600, StaticCookie::$_EXPIRE);
+ self::assertEmpty(StaticCookie::$_COOKIE[Cookie::NAME]);
+ self::assertEquals(-3600, StaticCookie::$_EXPIRE);
}
}
$record = User::identities($this->parent['uid']);
- $this->assertEquals([], $record);
+ self::assertEquals([], $record);
}
public function testIdentitiesAsParent()
$record = User::identities($this->parent['uid']);
- $this->assertEquals([
+ self::assertEquals([
$this->parent,
$this->child,
$this->manage
$record = User::identities($this->child['uid']);
- $this->assertEquals([
+ self::assertEquals([
$this->parent,
$this->child,
$this->manage
{
public function testGetUid()
{
- $this->assertSame(42, ContactEndpointMock::getUid(42));
- $this->assertSame(42, ContactEndpointMock::getUid(null, 'selfcontact'));
- $this->assertSame(42, ContactEndpointMock::getUid(84, 'selfcontact'));
+ self::assertSame(42, ContactEndpointMock::getUid(42));
+ self::assertSame(42, ContactEndpointMock::getUid(null, 'selfcontact'));
+ self::assertSame(42, ContactEndpointMock::getUid(84, 'selfcontact'));
}
public function testGetUidContactIdNotFound()
'total_count' => 0,
];
- $this->assertSame($expectedEmpty, ContactEndpointMock::ids(Contact::FOLLOWER, 42));
+ self::assertSame($expectedEmpty, ContactEndpointMock::ids(Contact::FOLLOWER, 42));
$expectedFriend = [
'ids' => [47],
'total_count' => 1,
];
- $this->assertSame($expectedFriend, ContactEndpointMock::ids(Contact::FRIEND, 42));
- $this->assertSame($expectedFriend, ContactEndpointMock::ids([Contact::FOLLOWER, Contact::FRIEND], 42));
+ self::assertSame($expectedFriend, ContactEndpointMock::ids(Contact::FRIEND, 42));
+ self::assertSame($expectedFriend, ContactEndpointMock::ids([Contact::FOLLOWER, Contact::FRIEND], 42));
$result = ContactEndpointMock::ids(Contact::SHARING, 42);
- $this->assertArrayHasKey('ids', $result);
- $this->assertContainsOnly('int', $result['ids']);
- $this->assertSame(45, $result['ids'][0]);
+ self::assertArrayHasKey('ids', $result);
+ self::assertContainsOnly('int', $result['ids']);
+ self::assertSame(45, $result['ids'][0]);
$result = ContactEndpointMock::ids([Contact::SHARING, Contact::FRIEND], 42);
- $this->assertArrayHasKey('ids', $result);
- $this->assertContainsOnly('int', $result['ids']);
- $this->assertSame(45, $result['ids'][0]);
+ self::assertArrayHasKey('ids', $result);
+ self::assertContainsOnly('int', $result['ids']);
+ self::assertSame(45, $result['ids'][0]);
}
/**
{
$result = ContactEndpointMock::ids(Contact::SHARING, 42, -1, ContactEndpoint::DEFAULT_COUNT, true);
- $this->assertArrayHasKey('ids', $result);
- $this->assertContainsOnly('string', $result['ids']);
- $this->assertSame('45', $result['ids'][0]);
+ self::assertArrayHasKey('ids', $result);
+ self::assertContainsOnly('string', $result['ids']);
+ self::assertSame('45', $result['ids'][0]);
}
public function testIdsPagination()
$result = ContactEndpointMock::ids([Contact::SHARING, Contact::FRIEND], 42, -1, 1);
- $this->assertSame($expectedDefaultPageResult, $result);
+ self::assertSame($expectedDefaultPageResult, $result);
$nextPageCursor = $result['next_cursor'];
$result = ContactEndpointMock::ids([Contact::SHARING, Contact::FRIEND], 42, $nextPageCursor, 1);
- $this->assertSame($expectedSecondPageResult, $result);
+ self::assertSame($expectedSecondPageResult, $result);
$firstPageCursor = $result['previous_cursor'];
$emptyNextPageCursor = $result['next_cursor'];
$result = ContactEndpointMock::ids([Contact::SHARING, Contact::FRIEND], 42, $firstPageCursor, 1);
- $this->assertSame($expectedFirstPageResult, $result);
+ self::assertSame($expectedFirstPageResult, $result);
$emptyPrevPageCursor = $result['previous_cursor'];
$result = ContactEndpointMock::ids([Contact::SHARING, Contact::FRIEND], 42, $emptyPrevPageCursor, 1);
- $this->assertSame($expectedEmptyPrevPageResult, $result);
+ self::assertSame($expectedEmptyPrevPageResult, $result);
$expectedEmptyNextPageResult = [
'ids' => [],
$result = ContactEndpointMock::ids([Contact::SHARING, Contact::FRIEND], 42, $emptyNextPageCursor, 1);
- $this->assertSame($expectedEmptyNextPageResult, $result);
+ self::assertSame($expectedEmptyNextPageResult, $result);
}
/**
'total_count' => 0,
];
- $this->assertSame($expectedEmpty, ContactEndpointMock::list(Contact::FOLLOWER, 42));
+ self::assertSame($expectedEmpty, ContactEndpointMock::list(Contact::FOLLOWER, 42));
$expectedFriendContactUser = [
'id' => 45,
$result = ContactEndpointMock::list(Contact::SHARING, 42);
- $this->assertArrayHasKey('users', $result);
- $this->assertContainsOnlyInstancesOf(User::class, $result['users']);
- $this->assertSame($expectedFriendContactUser, $result['users'][0]->toArray());
+ self::assertArrayHasKey('users', $result);
+ self::assertContainsOnlyInstancesOf(User::class, $result['users']);
+ self::assertSame($expectedFriendContactUser, $result['users'][0]->toArray());
$result = ContactEndpointMock::list([Contact::SHARING, Contact::FRIEND], 42);
- $this->assertArrayHasKey('users', $result);
- $this->assertContainsOnlyInstancesOf(User::class, $result['users']);
- $this->assertSame($expectedFriendContactUser, $result['users'][0]->toArray());
+ self::assertArrayHasKey('users', $result);
+ self::assertContainsOnlyInstancesOf(User::class, $result['users']);
+ self::assertSame($expectedFriendContactUser, $result['users'][0]->toArray());
}
}
'url' => 'https://test.local'
]);
- $this->assertTrue($curlResult->isSuccess());
- $this->assertFalse($curlResult->isTimeout());
- $this->assertFalse($curlResult->isRedirectUrl());
- $this->assertSame($header, $curlResult->getHeader());
- $this->assertSame($body, $curlResult->getBody());
- $this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
- $this->assertSame('https://test.local', $curlResult->getUrl());
- $this->assertSame('https://test.local', $curlResult->getRedirectUrl());
+ self::assertTrue($curlResult->isSuccess());
+ self::assertFalse($curlResult->isTimeout());
+ self::assertFalse($curlResult->isRedirectUrl());
+ self::assertSame($header, $curlResult->getHeader());
+ self::assertSame($body, $curlResult->getBody());
+ self::assertSame('text/html; charset=utf-8', $curlResult->getContentType());
+ self::assertSame('https://test.local', $curlResult->getUrl());
+ self::assertSame('https://test.local', $curlResult->getRedirectUrl());
}
/**
'redirect_url' => 'https://test.other'
]);
- $this->assertTrue($curlResult->isSuccess());
- $this->assertFalse($curlResult->isTimeout());
- $this->assertTrue($curlResult->isRedirectUrl());
- $this->assertSame($header, $curlResult->getHeader());
- $this->assertSame($body, $curlResult->getBody());
- $this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
- $this->assertSame('https://test.local/test/it', $curlResult->getUrl());
- $this->assertSame('https://test.other/test/it', $curlResult->getRedirectUrl());
+ self::assertTrue($curlResult->isSuccess());
+ self::assertFalse($curlResult->isTimeout());
+ self::assertTrue($curlResult->isRedirectUrl());
+ self::assertSame($header, $curlResult->getHeader());
+ self::assertSame($body, $curlResult->getBody());
+ self::assertSame('text/html; charset=utf-8', $curlResult->getContentType());
+ self::assertSame('https://test.local/test/it', $curlResult->getUrl());
+ self::assertSame('https://test.other/test/it', $curlResult->getRedirectUrl());
}
/**
'redirect_url' => 'https://test.other'
], CURLE_OPERATION_TIMEDOUT, 'Tested error');
- $this->assertFalse($curlResult->isSuccess());
- $this->assertTrue($curlResult->isTimeout());
- $this->assertFalse($curlResult->isRedirectUrl());
- $this->assertSame($header, $curlResult->getHeader());
- $this->assertSame($body, $curlResult->getBody());
- $this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
- $this->assertSame('https://test.local/test/it', $curlResult->getRedirectUrl());
- $this->assertSame('Tested error', $curlResult->getError());
+ self::assertFalse($curlResult->isSuccess());
+ self::assertTrue($curlResult->isTimeout());
+ self::assertFalse($curlResult->isRedirectUrl());
+ self::assertSame($header, $curlResult->getHeader());
+ self::assertSame($body, $curlResult->getBody());
+ self::assertSame('text/html; charset=utf-8', $curlResult->getContentType());
+ self::assertSame('https://test.local/test/it', $curlResult->getRedirectUrl());
+ self::assertSame('Tested error', $curlResult->getError());
}
/**
'url' => 'https://test.local/test/it?key=value',
]);
- $this->assertTrue($curlResult->isSuccess());
- $this->assertFalse($curlResult->isTimeout());
- $this->assertTrue($curlResult->isRedirectUrl());
- $this->assertSame($header, $curlResult->getHeader());
- $this->assertSame($body, $curlResult->getBody());
- $this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
- $this->assertSame('https://test.local/test/it?key=value', $curlResult->getUrl());
- $this->assertSame('https://test.other/some/?key=value', $curlResult->getRedirectUrl());
+ self::assertTrue($curlResult->isSuccess());
+ self::assertFalse($curlResult->isTimeout());
+ self::assertTrue($curlResult->isRedirectUrl());
+ self::assertSame($header, $curlResult->getHeader());
+ self::assertSame($body, $curlResult->getBody());
+ self::assertSame('text/html; charset=utf-8', $curlResult->getContentType());
+ self::assertSame('https://test.local/test/it?key=value', $curlResult->getUrl());
+ self::assertSame('https://test.other/some/?key=value', $curlResult->getRedirectUrl());
}
/**
'content_type' => 'text/html; charset=utf-8',
'url' => 'https://test.local'
]);
- $this->assertTrue($curlResult->inHeader('vary'));
- $this->assertFalse($curlResult->inHeader('wrongHeader'));
+ self::assertTrue($curlResult->inHeader('vary'));
+ self::assertFalse($curlResult->inHeader('wrongHeader'));
}
/**
$headers = $curlResult->getHeaderArray();
- $this->assertNotEmpty($headers);
- $this->assertArrayHasKey('vary', $headers);
+ self::assertNotEmpty($headers);
+ self::assertArrayHasKey('vary', $headers);
}
/**
'url' => 'https://test.local'
]);
- $this->assertNotEmpty($curlResult->getHeader());
- $this->assertEmpty($curlResult->getHeader('wrongHeader'));
+ self::assertNotEmpty($curlResult->getHeader());
+ self::assertEmpty($curlResult->getHeader('wrongHeader'));
}
}
$feedLink = Probe::getFeedLink($url, $body);
- $this->assertEquals($expected, $feedLink, 'base url = ' . $url . ' | href = ' . $href);
+ self::assertEquals($expected, $feedLink, 'base url = ' . $url . ' | href = ' . $href);
}
}
}
$feedLink = Probe::getFeedLink('http://example.com', $body);
- $this->assertEquals($expected, $feedLink, 'base url = ' . $url . ' | href = ' . $href);
+ self::assertEquals($expected, $feedLink, 'base url = ' . $url . ' | href = ' . $href);
}
}
}
{
$activity = new Activity();
- $this->assertEquals($assert, $activity->match($haystack, $needle));
+ self::assertEquals($assert, $activity->match($haystack, $needle));
}
public function testIsHidden()
{
$activity = new Activity();
- $this->assertTrue($activity->isHidden(Activity::LIKE));
- $this->assertFalse($activity->isHidden(Activity\ObjectType::BOOKMARK));
+ self::assertTrue($activity->isHidden(Activity::LIKE));
+ self::assertFalse($activity->isHidden(Activity\ObjectType::BOOKMARK));
}
}
$acl = $aclFormatter->expand($text);
- $this->assertEquals($assert, $acl);
+ self::assertEquals($assert, $acl);
- $this->assertMergable($acl);
+ self::assertMergable($acl);
}
public function assertMergable(array $aclOne, array $aclTwo = [])
{
- $this->assertTrue(is_array($aclOne));
- $this->assertTrue(is_array($aclTwo));
+ self::assertTrue(is_array($aclOne));
+ self::assertTrue(is_array($aclTwo));
$aclMerged = array_unique(array_merge($aclOne, $aclTwo));
- $this->assertTrue(is_array($aclMerged));
+ self::assertTrue(is_array($aclMerged));
return $aclMerged;
}
*/
public function testExpand($input, array $assert)
{
- $this->assertAcl($input, $assert);
+ self::assertAcl($input, $assert);
}
/**
$allow_people = $aclFormatter->expand();
$allow_groups = $aclFormatter->expand();
- $this->assertEmpty($aclFormatter->expand(null));
- $this->assertEmpty($aclFormatter->expand());
+ self::assertEmpty($aclFormatter->expand(null));
+ self::assertEmpty($aclFormatter->expand());
$recipients = array_unique(array_merge($allow_people, $allow_groups));
- $this->assertEmpty($recipients);
+ self::assertEmpty($recipients);
}
public function dataAclToString()
{
$aclFormatter = new ACLFormatter();
- $this->assertEquals($assert, $aclFormatter->toString($input));
+ self::assertEquals($assert, $aclFormatter->toString($input));
}
}
public function testEmptyArrayEmptyDelimiter()
{
$str = Arrays::recursiveImplode([], '');
- $this->assertEmpty($str);
+ self::assertEmpty($str);
}
/**
public function testEmptyArrayNonEmptyDelimiter()
{
$str = Arrays::recursiveImplode([], ',');
- $this->assertEmpty($str);
+ self::assertEmpty($str);
}
/**
public function testNonEmptyArrayEmptyDelimiter()
{
$str = Arrays::recursiveImplode([1], '');
- $this->assertSame($str, '1');
+ self::assertSame($str, '1');
}
/**
public function testNonEmptyArray2EmptyDelimiter()
{
$str = Arrays::recursiveImplode([1, 2], '');
- $this->assertSame($str, '12');
+ self::assertSame($str, '12');
}
/**
public function testNonEmptyArrayNonEmptyDelimiter()
{
$str = Arrays::recursiveImplode([1], ',');
- $this->assertSame($str, '1');
+ self::assertSame($str, '1');
}
/**
public function testNonEmptyArray2NonEmptyDelimiter()
{
$str = Arrays::recursiveImplode([1, 2], ',');
- $this->assertSame($str, '1,2');
+ self::assertSame($str, '1,2');
}
/**
public function testEmptyMultiArray2EmptyDelimiter()
{
$str = Arrays::recursiveImplode([[1], []], '');
- $this->assertSame($str, '{1}{}');
+ self::assertSame($str, '{1}{}');
}
/**
public function testEmptyMulti2Array2EmptyDelimiter()
{
$str = Arrays::recursiveImplode([[1], [2]], '');
- $this->assertSame($str, '{1}{2}');
+ self::assertSame($str, '{1}{2}');
}
/**
public function testEmptyMultiArray2NonEmptyDelimiter()
{
$str = Arrays::recursiveImplode([[1], []], ',');
- $this->assertSame($str, '{1},{}');
+ self::assertSame($str, '{1},{}');
}
/**
public function testEmptyMulti2Array2NonEmptyDelimiter()
{
$str = Arrays::recursiveImplode([[1], [2]], ',');
- $this->assertSame($str, '{1},{2}');
+ self::assertSame($str, '{1},{2}');
}
/**
public function testEmptyMulti3Array2NonEmptyDelimiter()
{
$str = Arrays::recursiveImplode([[1], [2, [3]]], ',');
- $this->assertSame($str, '{1},{2,{3}}');
+ self::assertSame($str, '{1},{2,{3}}');
}
}
public function testDetermineBasePath(array $server, $input, $output)
{
$basepath = new BasePath($input, $server);
- $this->assertEquals($output, $basepath->getPath());
+ self::assertEquals($output, $basepath->getPath());
}
/**
$baseUrl = new BaseURL($configMock, $server);
- $this->assertEquals($assert['hostname'], $baseUrl->getHostname());
- $this->assertEquals($assert['urlPath'], $baseUrl->getUrlPath());
- $this->assertEquals($assert['sslPolicy'], $baseUrl->getSSLPolicy());
- $this->assertEquals($assert['scheme'], $baseUrl->getScheme());
- $this->assertEquals($assert['url'], $baseUrl->get());
+ self::assertEquals($assert['hostname'], $baseUrl->getHostname());
+ self::assertEquals($assert['urlPath'], $baseUrl->getUrlPath());
+ self::assertEquals($assert['sslPolicy'], $baseUrl->getSSLPolicy());
+ self::assertEquals($assert['scheme'], $baseUrl->getScheme());
+ self::assertEquals($assert['url'], $baseUrl->get());
}
public function dataSave()
$baseUrl->save($save['hostname'], $save['sslPolicy'], $save['urlPath']);
- $this->assertEquals($url, $baseUrl->get());
+ self::assertEquals($url, $baseUrl->get());
}
/**
$baseUrl->saveByURL($url);
- $this->assertEquals($url, $baseUrl->get());
+ self::assertEquals($url, $baseUrl->get());
}
public function dataGetBaseUrl()
$baseUrl = new BaseURL($configMock, []);
- $this->assertEquals($assert, $baseUrl->get($ssl));
+ self::assertEquals($assert, $baseUrl->get($ssl));
}
public function dataCheckRedirectHTTPS()
$baseUrl = new BaseURL($configMock, $server);
- $this->assertEquals($redirect, $baseUrl->checkRedirectHttps());
+ self::assertEquals($redirect, $baseUrl->checkRedirectHttps());
}
public function dataWrongSave()
}
$baseUrl = new BaseURL($configMock, []);
- $this->assertFalse($baseUrl->save('test', 10, 'nope'));
+ self::assertFalse($baseUrl->save('test', 10, 'nope'));
// nothing should have changed because we never successfully saved anything
- $this->assertEquals($baseUrl->getHostname(), 'friendica.local');
- $this->assertEquals($baseUrl->getUrlPath(), 'new/test');
- $this->assertEquals($baseUrl->getSSLPolicy(), BaseURL::DEFAULT_SSL_SCHEME);
- $this->assertEquals($baseUrl->get(), 'http://friendica.local/new/test');
+ self::assertEquals($baseUrl->getHostname(), 'friendica.local');
+ self::assertEquals($baseUrl->getUrlPath(), 'new/test');
+ self::assertEquals($baseUrl->getSSLPolicy(), BaseURL::DEFAULT_SSL_SCHEME);
+ self::assertEquals($baseUrl->get(), 'http://friendica.local/new/test');
}
}
$configFileLoader->setupCache($configCache);
- $this->assertEquals($this->root->url(), $configCache->get('system', 'basepath'));
+ self::assertEquals($this->root->url(), $configCache->get('system', 'basepath'));
}
/**
$configFileLoader->setupCache($configCache);
- $this->assertEquals('testhost', $configCache->get('database', 'hostname'));
- $this->assertEquals('testuser', $configCache->get('database', 'username'));
- $this->assertEquals('testpw', $configCache->get('database', 'password'));
- $this->assertEquals('testdb', $configCache->get('database', 'database'));
+ self::assertEquals('testhost', $configCache->get('database', 'hostname'));
+ self::assertEquals('testuser', $configCache->get('database', 'username'));
+ self::assertEquals('testpw', $configCache->get('database', 'password'));
+ self::assertEquals('testdb', $configCache->get('database', 'database'));
- $this->assertEquals('admin@test.it', $configCache->get('config', 'admin_email'));
- $this->assertEquals('Friendica Social Network', $configCache->get('config', 'sitename'));
+ self::assertEquals('admin@test.it', $configCache->get('config', 'admin_email'));
+ self::assertEquals('Friendica Social Network', $configCache->get('config', 'sitename'));
}
/**
$configFileLoader->setupCache($configCache);
- $this->assertEquals('testhost', $configCache->get('database', 'hostname'));
- $this->assertEquals('testuser', $configCache->get('database', 'username'));
- $this->assertEquals('testpw', $configCache->get('database', 'password'));
- $this->assertEquals('testdb', $configCache->get('database', 'database'));
+ self::assertEquals('testhost', $configCache->get('database', 'hostname'));
+ self::assertEquals('testuser', $configCache->get('database', 'username'));
+ self::assertEquals('testpw', $configCache->get('database', 'password'));
+ self::assertEquals('testdb', $configCache->get('database', 'database'));
- $this->assertEquals('admin@test.it', $configCache->get('config', 'admin_email'));
+ self::assertEquals('admin@test.it', $configCache->get('config', 'admin_email'));
}
/**
$configFileLoader->setupCache($configCache);
- $this->assertEquals('testhost', $configCache->get('database', 'hostname'));
- $this->assertEquals('testuser', $configCache->get('database', 'username'));
- $this->assertEquals('testpw', $configCache->get('database', 'password'));
- $this->assertEquals('testdb', $configCache->get('database', 'database'));
- $this->assertEquals('anotherCharset', $configCache->get('database', 'charset'));
+ self::assertEquals('testhost', $configCache->get('database', 'hostname'));
+ self::assertEquals('testuser', $configCache->get('database', 'username'));
+ self::assertEquals('testpw', $configCache->get('database', 'password'));
+ self::assertEquals('testdb', $configCache->get('database', 'database'));
+ self::assertEquals('anotherCharset', $configCache->get('database', 'charset'));
- $this->assertEquals('/var/run/friendica.pid', $configCache->get('system', 'pidfile'));
- $this->assertEquals('Europe/Berlin', $configCache->get('system', 'default_timezone'));
- $this->assertEquals('fr', $configCache->get('system', 'language'));
+ self::assertEquals('/var/run/friendica.pid', $configCache->get('system', 'pidfile'));
+ self::assertEquals('Europe/Berlin', $configCache->get('system', 'default_timezone'));
+ self::assertEquals('fr', $configCache->get('system', 'language'));
- $this->assertEquals('admin@test.it', $configCache->get('config', 'admin_email'));
- $this->assertEquals('Friendly admin', $configCache->get('config', 'admin_nickname'));
+ self::assertEquals('admin@test.it', $configCache->get('config', 'admin_email'));
+ self::assertEquals('Friendly admin', $configCache->get('config', 'admin_nickname'));
- $this->assertEquals('/another/php', $configCache->get('config', 'php_path'));
- $this->assertEquals('999', $configCache->get('config', 'max_import_size'));
- $this->assertEquals('666', $configCache->get('system', 'maximagesize'));
+ self::assertEquals('/another/php', $configCache->get('config', 'php_path'));
+ self::assertEquals('999', $configCache->get('config', 'max_import_size'));
+ self::assertEquals('666', $configCache->get('system', 'maximagesize'));
- $this->assertEquals('quattro,vier,duepuntozero', $configCache->get('system', 'allowed_themes'));
- $this->assertEquals('1', $configCache->get('system', 'no_regfullname'));
+ self::assertEquals('quattro,vier,duepuntozero', $configCache->get('system', 'allowed_themes'));
+ self::assertEquals('1', $configCache->get('system', 'no_regfullname'));
}
public function testLoadAddonConfig()
$conf = $configFileLoader->loadAddonConfig('test');
- $this->assertEquals('testhost', $conf['database']['hostname']);
- $this->assertEquals('testuser', $conf['database']['username']);
- $this->assertEquals('testpw', $conf['database']['password']);
- $this->assertEquals('testdb', $conf['database']['database']);
+ self::assertEquals('testhost', $conf['database']['hostname']);
+ self::assertEquals('testuser', $conf['database']['username']);
+ self::assertEquals('testpw', $conf['database']['password']);
+ self::assertEquals('testdb', $conf['database']['database']);
- $this->assertEquals('admin@test.it', $conf['config']['admin_email']);
+ self::assertEquals('admin@test.it', $conf['config']['admin_email']);
}
/**
$configFileLoader->setupCache($configCache);
- $this->assertEquals('admin@overwritten.local', $configCache->get('config', 'admin_email'));
- $this->assertEquals('newValue', $configCache->get('system', 'newKey'));
+ self::assertEquals('admin@overwritten.local', $configCache->get('config', 'admin_email'));
+ self::assertEquals('newValue', $configCache->get('system', 'newKey'));
}
/**
$configFileLoader->setupCache($configCache);
- $this->assertEquals('admin@overwritten.local', $configCache->get('config', 'admin_email'));
- $this->assertEquals('newValue', $configCache->get('system', 'newKey'));
+ self::assertEquals('admin@overwritten.local', $configCache->get('config', 'admin_email'));
+ self::assertEquals('newValue', $configCache->get('system', 'newKey'));
}
/**
$configFileLoader->setupCache($configCache);
- $this->assertEquals('admin@test.it', $configCache->get('config', 'admin_email'));
- $this->assertEmpty($configCache->get('system', 'NewKey'));
+ self::assertEquals('admin@test.it', $configCache->get('config', 'admin_email'));
+ self::assertEmpty($configCache->get('system', 'NewKey'));
}
}
{
global $phpMock;
$phpMock['random_int'] = function ($mMin, $mMax) use ($min, $max) {
- $this->assertEquals($min, $mMin);
- $this->assertEquals($max, $mMax);
+ self::assertEquals($min, $mMin);
+ self::assertEquals($max, $mMax);
return 1;
};
}
public function testRandomDigitsRandomInt()
{
- $this->assertRandomInt(0, 9);
+ self::assertRandomInt(0, 9);
$test = Crypto::randomDigits(1);
- $this->assertEquals(1, strlen($test));
- $this->assertEquals(1, $test);
+ self::assertEquals(1, strlen($test));
+ self::assertEquals(1, $test);
$test = Crypto::randomDigits(8);
- $this->assertEquals(8, strlen($test));
- $this->assertEquals(11111111, $test);
+ self::assertEquals(8, strlen($test));
+ self::assertEquals(11111111, $test);
}
public function dataRsa()
*/
public function testPubRsaToMe(string $key, string $expected)
{
- $this->assertEquals($expected, Crypto::rsaToPem(base64_decode($key)));
+ self::assertEquals($expected, Crypto::rsaToPem(base64_decode($key)));
}
'n' => new BigInteger($m, 256)
]);
- $this->assertEquals($expectedRSA->getPublicKey(), $key);
+ self::assertEquals($expectedRSA->getPublicKey(), $key);
}
/**
$checkKey = Crypto::meToPem($m, $e);
- $this->assertEquals($key, $checkKey);
+ self::assertEquals($key, $checkKey);
}
}
{
$dtFormat = new DateTimeFormat();
- $this->assertEquals($assert, $dtFormat->isYearMonth($input));
+ self::assertEquals($assert, $dtFormat->isYearMonth($input));
}
}
$emailer = new EmailerSpy($this->config, $this->pConfig, $this->baseUrl, new NullLogger(), $this->l10n);
- $this->assertTrue($emailer->send($testEmail));
-
- $this->assertContains("X-Friendica-Host: friendica.local", EmailerSpy::$MAIL_DATA['headers']);
- $this->assertContains("X-Friendica-Platform: Friendica", EmailerSpy::$MAIL_DATA['headers']);
- $this->assertContains("List-ID: <notification.friendica.local>", EmailerSpy::$MAIL_DATA['headers']);
- $this->assertContains("List-Archive: <http://friendica.local/notifications/system>", EmailerSpy::$MAIL_DATA['headers']);
- $this->assertContains("Reply-To: Sender <sender@friendica.local>", EmailerSpy::$MAIL_DATA['headers']);
- $this->assertContains("MIME-Version: 1.0", EmailerSpy::$MAIL_DATA['headers']);
+ self::assertTrue($emailer->send($testEmail));
+
+ self::assertContains("X-Friendica-Host: friendica.local", EmailerSpy::$MAIL_DATA['headers']);
+ self::assertContains("X-Friendica-Platform: Friendica", EmailerSpy::$MAIL_DATA['headers']);
+ self::assertContains("List-ID: <notification.friendica.local>", EmailerSpy::$MAIL_DATA['headers']);
+ self::assertContains("List-Archive: <http://friendica.local/notifications/system>", EmailerSpy::$MAIL_DATA['headers']);
+ self::assertContains("Reply-To: Sender <sender@friendica.local>", EmailerSpy::$MAIL_DATA['headers']);
+ self::assertContains("MIME-Version: 1.0", EmailerSpy::$MAIL_DATA['headers']);
// Base64 "Test Text"
- $this->assertContains(chunk_split(base64_encode('Test Text')), EmailerSpy::$MAIL_DATA['body']);
+ self::assertContains(chunk_split(base64_encode('Test Text')), EmailerSpy::$MAIL_DATA['body']);
// Base64 "Test Message<b>Bold</b>"
- $this->assertContains(chunk_split(base64_encode("Test Message<b>Bold</b>")), EmailerSpy::$MAIL_DATA['body']);
- $this->assertEquals("Test Subject", EmailerSpy::$MAIL_DATA['subject']);
- $this->assertEquals("recipient@friendica.local", EmailerSpy::$MAIL_DATA['to']);
- $this->assertEquals("-f sender@friendica.local", EmailerSpy::$MAIL_DATA['parameters']);
+ self::assertContains(chunk_split(base64_encode("Test Message<b>Bold</b>")), EmailerSpy::$MAIL_DATA['body']);
+ self::assertEquals("Test Subject", EmailerSpy::$MAIL_DATA['subject']);
+ self::assertEquals("recipient@friendica.local", EmailerSpy::$MAIL_DATA['to']);
+ self::assertEquals("-f sender@friendica.local", EmailerSpy::$MAIL_DATA['parameters']);
}
public function testTwoMessageIds()
$emailer = new EmailerSpy($this->config, $this->pConfig, $this->baseUrl, new NullLogger(), $this->l10n);
// even in case there are two message ids, send the mail anyway
- $this->assertTrue($emailer->send($testEmail));
+ self::assertTrue($emailer->send($testEmail));
// check case sensitive key problem
- $this->assertArrayHasKey('Message-ID', $testEmail->getAdditionalMailHeader());
- $this->assertArrayHasKey('Message-Id', $testEmail->getAdditionalMailHeader());
+ self::assertArrayHasKey('Message-ID', $testEmail->getAdditionalMailHeader());
+ self::assertArrayHasKey('Message-Id', $testEmail->getAdditionalMailHeader());
}
}
public function assertEmail(IEmail $email, array $asserts)
{
- $this->assertEquals($asserts['subject'] ?? $email->getSubject(), $email->getSubject());
- $this->assertEquals($asserts['html'] ?? $email->getMessage(), $email->getMessage());
- $this->assertEquals($asserts['text'] ?? $email->getMessage(true), $email->getMessage(true));
- $this->assertEquals($asserts['toAddress'] ?? $email->getToAddress(), $email->getToAddress());
- $this->assertEquals($asserts['fromAddress'] ?? $email->getFromAddress(), $email->getFromAddress());
- $this->assertEquals($asserts['fromName'] ?? $email->getFromName(), $email->getFromName());
- $this->assertEquals($asserts['replyTo'] ?? $email->getReplyTo(), $email->getReplyTo());
- $this->assertEquals($asserts['uid'] ?? $email->getRecipientUid(), $email->getRecipientUid());
- $this->assertEquals($asserts['header'] ?? $email->getAdditionalMailHeader(), $email->getAdditionalMailHeader());
+ self::assertEquals($asserts['subject'] ?? $email->getSubject(), $email->getSubject());
+ self::assertEquals($asserts['html'] ?? $email->getMessage(), $email->getMessage());
+ self::assertEquals($asserts['text'] ?? $email->getMessage(true), $email->getMessage(true));
+ self::assertEquals($asserts['toAddress'] ?? $email->getToAddress(), $email->getToAddress());
+ self::assertEquals($asserts['fromAddress'] ?? $email->getFromAddress(), $email->getFromAddress());
+ self::assertEquals($asserts['fromName'] ?? $email->getFromName(), $email->getFromName());
+ self::assertEquals($asserts['replyTo'] ?? $email->getReplyTo(), $email->getReplyTo());
+ self::assertEquals($asserts['uid'] ?? $email->getRecipientUid(), $email->getRecipientUid());
+ self::assertEquals($asserts['header'] ?? $email->getAdditionalMailHeader(), $email->getAdditionalMailHeader());
}
/**
{
$builder = new SampleMailBuilder($this->l10n, $this->baseUrl, $this->config, new NullLogger());
- $this->assertInstanceOf(MailBuilder::class, $builder);
+ self::assertInstanceOf(MailBuilder::class, $builder);
}
/**
->forUser(['uid' => 100])
->build(true);
- $this->assertEmail($testEmail, [
+ self::assertEmail($testEmail, [
'subject' => 'Subject',
'html' => 'Html',
'text' => 'text',
->withSender('Sender', 'sender@friendica.local')
->build(true);
- $this->assertEmail($testEmail, [
+ self::assertEmail($testEmail, [
'toAddress' => 'recipient@friendica.local',
'fromName' => 'Sender',
'fromAddress' => 'sender@friendica.local',
->withSender('Sender', 'sender@friendica.local')
->build(true);
- $this->assertEmail($testEmail, [
+ self::assertEmail($testEmail, [
'toAddress' => 'recipient@friendica.local',
'fromName' => 'Sender',
'fromAddress' => 'sender@friendica.local',
{
$builder = new SystemMailBuilder($this->l10n, $this->baseUrl, $this->config, new NullLogger(), 'moreply@friendica.local', 'FriendicaSite');
- $this->assertInstanceOf(MailBuilder::class, $builder);
- $this->assertInstanceOf(SystemMailBuilder::class, $builder);
+ self::assertInstanceOf(MailBuilder::class, $builder);
+ self::assertInstanceOf(SystemMailBuilder::class, $builder);
}
}
YWuxyvBa0Z6NdOb0di70cdrSDEsL5Gz7LBY5J2N9KdGg=="';
$headers = HTTPSignature::parseSigheader($header);
- $this->assertSame([
+ self::assertSame([
'keyId' => 'test-key-a',
'algorithm' => 'hs2019',
'created' => '1402170695',
$object = [];
$data = JsonLD::fetchElementArray($object, 'field');
- $this->assertNull($data);
+ self::assertNull($data);
}
public function testFetchElementArrayFoundEmptyArray()
$object = ['field' => []];
$data = JsonLD::fetchElementArray($object, 'field');
- $this->assertSame([[]], $data);
+ self::assertSame([[]], $data);
}
public function testFetchElementArrayFoundID()
$object = ['field' => ['value1', ['@id' => 'value2'], ['@id' => 'value3']]];
$data = JsonLD::fetchElementArray($object, 'field', '@id');
- $this->assertSame(['value1', 'value2', 'value3'], $data);
+ self::assertSame(['value1', 'value2', 'value3'], $data);
}
public function testFetchElementArrayFoundID2()
'value3', ['@id' => 'value4', 'subfield42' => 'value42']]];
$data = JsonLD::fetchElementArray($object, 'field', '@id');
- $this->assertSame(['value3', 'value4'], $data);
+ self::assertSame(['value3', 'value4'], $data);
}
public function testFetchElementArrayFoundArrays()
{
['subfield21' => 'value21', 'subfield22' => 'value22']];
$data = JsonLD::fetchElementArray($object, 'field');
- $this->assertSame($expect, $data);
+ self::assertSame($expect, $data);
}
public function testFetchElementNotFound()
$object = [];
$data = JsonLD::fetchElement($object, 'field');
- $this->assertNull($data);
+ self::assertNull($data);
}
public function testFetchElementFound()
$object = ['field' => 'value'];
$data = JsonLD::fetchElement($object, 'field');
- $this->assertSame('value', $data);
+ self::assertSame('value', $data);
}
public function testFetchElementFoundEmptyString()
$object = ['field' => ''];
$data = JsonLD::fetchElement($object, 'field');
- $this->assertSame('', $data);
+ self::assertSame('', $data);
}
public function testFetchElementKeyFoundEmptyArray()
$object = ['field' => ['content' => []]];
$data = JsonLD::fetchElement($object, 'field', 'content');
- $this->assertSame([], $data);
+ self::assertSame([], $data);
}
public function testFetchElementFoundID()
$object = ['field' => ['field2' => 'value2', '@id' => 'value', 'field3' => 'value3']];
$data = JsonLD::fetchElement($object, 'field');
- $this->assertSame('value', $data);
+ self::assertSame('value', $data);
}
public function testFetchElementType()
$object = ['source' => ['content' => 'body', 'mediaType' => 'text/bbcode']];
$data = JsonLD::fetchElement($object, 'source', 'content', 'mediaType', 'text/bbcode');
- $this->assertSame('body', $data);
+ self::assertSame('body', $data);
}
public function testFetchElementTypeValueNotFound()
$object = ['source' => ['content' => 'body', 'mediaType' => 'text/html']];
$data = JsonLD::fetchElement($object, 'source', 'content', 'mediaType', 'text/bbcode');
- $this->assertNull($data);
+ self::assertNull($data);
}
public function testFetchElementTypeNotFound()
$object = ['source' => ['content' => 'body', 'mediaType' => 'text/html']];
$data = JsonLD::fetchElement($object, 'source', 'content', 'mediaType2', 'text/html');
- $this->assertNull($data);
+ self::assertNull($data);
}
public function testFetchElementKeyWithoutType()
$object = ['source' => ['content' => 'body', 'mediaType' => 'text/bbcode']];
$data = JsonLD::fetchElement($object, 'source', 'content');
- $this->assertSame('body', $data);
+ self::assertSame('body', $data);
}
public function testFetchElementTypeArray()
['content' => 'body', 'mediaType' => 'text/bbcode']]];
$data = JsonLD::fetchElement($object, 'source', 'content', 'mediaType', 'text/bbcode');
- $this->assertSame('body', $data);
+ self::assertSame('body', $data);
}
public function testFetchElementTypeValueArrayNotFound()
['content' => 'body', 'mediaType' => 'text/bbcode']]];
$data = JsonLD::fetchElement($object, 'source', 'content', 'mediaType', 'text/markdown');
- $this->assertNull($data);
+ self::assertNull($data);
}
public function testFetchElementTypeArrayNotFound()
['content' => 'body', 'mediaType' => 'text/bbcode']]];
$data = JsonLD::fetchElement($object, 'source', 'content', 'mediaType2', 'text/bbcode');
- $this->assertNull($data);
+ self::assertNull($data);
}
}
public function assertLogline($string)
{
- $this->assertRegExp(self::LOGLINE, $string);
+ self::assertRegExp(self::LOGLINE, $string);
}
public function assertLoglineNums($assertNum, $string)
{
- $this->assertEquals($assertNum, preg_match_all(self::LOGLINE, $string));
+ self::assertEquals($assertNum, preg_match_all(self::LOGLINE, $string));
}
/**
$logger->notice('message', ['an' => 'context']);
$text = $this->getContent();
- $this->assertLogline($text);
- $this->assertLoglineNums(4, $text);
+ self::assertLogline($text);
+ self::assertLoglineNums(4, $text);
}
/**
$logger->emergency('A {psr} test', ['psr' => 'working']);
$logger->alert('An {array} test', ['array' => ['it', 'is', 'working']]);
$text = $this->getContent();
- $this->assertContains('A working test', $text);
- $this->assertContains('An ["it","is","working"] test', $text);
+ self::assertContains('A working test', $text);
+ self::assertContains('An ["it","is","working"] test', $text);
}
/**
$logger->emergency('A test');
$text = $this->getContent();
- $this->assertContains('"file":"' . self::FILE . '"', $text);
- $this->assertContains('"line":' . self::LINE, $text);
- $this->assertContains('"function":"' . self::FUNC . '"', $text);
+ self::assertContains('"file":"' . self::FILE . '"', $text);
+ self::assertContains('"line":' . self::LINE, $text);
+ self::assertContains('"function":"' . self::FUNC . '"', $text);
}
/**
$text = $this->getContent();
- $this->assertLoglineNums(5, $text);
+ self::assertLoglineNums(5, $text);
}
/**
$text = $this->getContent();
- $this->assertLogline($text);
+ self::assertLogline($text);
- $this->assertContains(@json_encode($context), $text);
+ self::assertContains(@json_encode($context), $text);
}
}
$text = $logfile->getContent();
- $this->assertLogline($text);
+ self::assertLogline($text);
}
/**
$text = $logfile->getContent();
- $this->assertLoglineNums(2, $text);
+ self::assertLoglineNums(2, $text);
}
/**
{
private function assertUid($uid, $length = 7)
{
- $this->assertRegExp('/^[a-zA-Z0-9]{' . $length . '}+$/', $uid);
+ self::assertRegExp('/^[a-zA-Z0-9]{' . $length . '}+$/', $uid);
}
/**
for ($i = 1; $i < 14; $i++) {
$workLogger = new WorkerLogger($logger, 'test', $i);
$uid = $workLogger->getWorkerId();
- $this->assertUid($uid, $i);
+ self::assertUid($uid, $i);
}
}
$testContext = $context;
$testContext['worker_id'] = $workLogger->getWorkerId();
$testContext['worker_cmd'] = 'test';
- $this->assertUid($testContext['worker_id']);
+ self::assertUid($testContext['worker_id']);
$logger
->shouldReceive($func)
->with($msg, $testContext)
$context = $testContext = ['test' => 'it'];
$testContext['worker_id'] = $workLogger->getWorkerId();
$testContext['worker_cmd'] = 'test';
- $this->assertUid($testContext['worker_id']);
+ self::assertUid($testContext['worker_id']);
$logger
->shouldReceive('log')
->with('debug', 'a test', $testContext)
$profiler->saveTimestamp($timestamp, $name, $function);
}
- $this->assertGreaterThanOrEqual(0, $profiler->get($name));
+ self::assertGreaterThanOrEqual(0, $profiler->get($name));
}
/**
$profiler->saveTimestamp($timestamp, $name);
$profiler->reset();
- $this->assertEquals(0, $profiler->get($name));
+ self::assertEquals(0, $profiler->get($name));
}
public function dataBig()
foreach ($data as $perf => $items) {
foreach ($items['functions'] as $function) {
// assert that the output contains the functions
- $this->assertRegExp('/' . $function . ': \d+/', $output);
+ self::assertRegExp('/' . $function . ': \d+/', $output);
}
}
}
$profiler = new Profiler($configCache);
- $this->assertFalse($profiler->isRendertime());
- $this->assertEmpty($profiler->getRendertimeString());
+ self::assertFalse($profiler->isRendertime());
+ self::assertEmpty($profiler->getRendertimeString());
$profiler->saveTimestamp(time(), 'network', 'test1');
$profiler->update($config);
- $this->assertFalse($profiler->isRendertime());
- $this->assertEmpty($profiler->getRendertimeString());
+ self::assertFalse($profiler->isRendertime());
+ self::assertEmpty($profiler->getRendertimeString());
$config->shouldReceive('get')
->with('system', 'profiler')
$profiler->saveTimestamp(time(), 'database', 'test2');
- $this->assertTrue($profiler->isRendertime());
+ self::assertTrue($profiler->isRendertime());
$output = $profiler->getRendertimeString();
- $this->assertRegExp('/test1: \d+/', $output);
- $this->assertRegExp('/test2: \d+/', $output);
+ self::assertRegExp('/test1: \d+/', $output);
+ self::assertRegExp('/test2: \d+/', $output);
}
}
$randomname1 = Strings::getRandomName(10);
$randomname2 = Strings::getRandomName(10);
- $this->assertNotEquals($randomname1, $randomname2);
+ self::assertNotEquals($randomname1, $randomname2);
}
/**
$randomname1 = Strings::getRandomName(9);
$randomname2 = Strings::getRandomName(9);
- $this->assertNotEquals($randomname1, $randomname2);
+ self::assertNotEquals($randomname1, $randomname2);
}
/**
public function testRandomNameNoLength()
{
$randomname1 = Strings::getRandomName(0);
- $this->assertEquals(0, strlen($randomname1));
+ self::assertEquals(0, strlen($randomname1));
}
/**
public function testRandomNameNegativeLength()
{
$randomname1 = Strings::getRandomName(-23);
- $this->assertEquals(0, strlen($randomname1));
+ self::assertEquals(0, strlen($randomname1));
}
/**
public function testRandomNameLength1()
{
$randomname1 = Strings::getRandomName(1);
- $this->assertEquals(1, strlen($randomname1));
+ self::assertEquals(1, strlen($randomname1));
$randomname2 = Strings::getRandomName(1);
- $this->assertEquals(1, strlen($randomname2));
+ self::assertEquals(1, strlen($randomname2));
}
/**
$validstring = Strings::escapeTags($invalidstring);
$escapedString = Strings::escapeHtml($invalidstring);
- $this->assertEquals('[submit type="button" onclick="alert(\'failed!\');" /]', $validstring);
- $this->assertEquals(
+ self::assertEquals('[submit type="button" onclick="alert(\'failed!\');" /]', $validstring);
+ self::assertEquals(
"<submit type="button" onclick="alert('failed!');" />",
$escapedString
);
*/
public function testIsHex($input, $valid)
{
- $this->assertEquals($valid, Strings::isHex($input));
+ self::assertEquals($valid, Strings::isHex($input));
}
/**
public function testSubstringReplaceASCII()
{
for ($start = -10; $start <= 10; $start += 5) {
- $this->assertEquals(
+ self::assertEquals(
substr_replace('string', 'replacement', $start),
Strings::substringReplace('string', 'replacement', $start)
);
for ($length = -10; $length <= 10; $length += 5) {
- $this->assertEquals(
+ self::assertEquals(
substr_replace('string', 'replacement', $start, $length),
Strings::substringReplace('string', 'replacement', $start, $length)
);
*/
public function testSubstringReplaceMultiByte(string $expected, string $string, string $replacement, int $start, int $length = null)
{
- $this->assertEquals(
+ self::assertEquals(
$expected,
Strings::substringReplace(
$string,
return $text;
});
- $this->assertEquals($originalText, $text);
+ self::assertEquals($originalText, $text);
}
public function testPerformWithEscapedBlocksNested()
return $text;
});
- $this->assertEquals($originalText, $text);
+ self::assertEquals($originalText, $text);
}
}
$text="<tag>I want to break\n this!11!<?hard?></tag>";
$xml=XML::escape($text);
$retext=XML::unescape($text);
- $this->assertEquals($text, $retext);
+ self::assertEquals($text, $retext);
}
/**
//should be possible to parse it
$values=array();
$index=array();
- $this->assertEquals(1, xml_parse_into_struct($xml_parser, $text, $values, $index));
- $this->assertEquals(
+ self::assertEquals(1, xml_parse_into_struct($xml_parser, $text, $values, $index));
+ self::assertEquals(
array('TEXT'=>array(0)),
$index
);
- $this->assertEquals(
+ self::assertEquals(
array(array('tag'=>'TEXT', 'type'=>'complete', 'level'=>1, 'value'=>$tag)),
$values
);