Adapt tests for PhpUnit 7.5
This commit is contained in:
parent
5947698dc1
commit
4b38b6aa16
10 changed files with 36 additions and 35 deletions
|
@ -22,6 +22,8 @@ require_once __DIR__ . '/../../include/api.php';
|
||||||
*
|
*
|
||||||
* Functions that use header() need to be tested in a separate process.
|
* Functions that use header() need to be tested in a separate process.
|
||||||
* @see https://phpunit.de/manual/5.7/en/appendixes.annotations.html#appendixes.annotations.runTestsInSeparateProcesses
|
* @see https://phpunit.de/manual/5.7/en/appendixes.annotations.html#appendixes.annotations.runTestsInSeparateProcesses
|
||||||
|
*
|
||||||
|
* @backupGlobals enabled
|
||||||
*/
|
*/
|
||||||
class ApiTest extends FixtureTest
|
class ApiTest extends FixtureTest
|
||||||
{
|
{
|
||||||
|
@ -108,10 +110,6 @@ class ApiTest extends FixtureTest
|
||||||
'authenticated' => true,
|
'authenticated' => true,
|
||||||
'uid' => $this->selfUser['id']
|
'uid' => $this->selfUser['id']
|
||||||
];
|
];
|
||||||
|
|
||||||
$_POST = [];
|
|
||||||
$_GET = [];
|
|
||||||
$_SERVER = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,7 +138,7 @@ class ApiTest extends FixtureTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function assertOtherUser(array $user)
|
private function assertOtherUser(array $user = [])
|
||||||
{
|
{
|
||||||
self::assertEquals($this->otherUser['id'], $user['id']);
|
self::assertEquals($this->otherUser['id'], $user['id']);
|
||||||
self::assertEquals($this->otherUser['id'], $user['id_str']);
|
self::assertEquals($this->otherUser['id'], $user['id_str']);
|
||||||
|
@ -157,10 +155,10 @@ class ApiTest extends FixtureTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function assertStatus(array $status)
|
private function assertStatus(array $status = [])
|
||||||
{
|
{
|
||||||
self::assertInternalType('string', $status['text']);
|
self::assertInternalType('string', $status['text'] ?? '');
|
||||||
self::assertInternalType('int', $status['id']);
|
self::assertInternalType('int', $status['id'] ?? '');
|
||||||
// We could probably do more checks here.
|
// We could probably do more checks here.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +169,7 @@ class ApiTest extends FixtureTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function assertList(array $list)
|
private function assertList(array $list = [])
|
||||||
{
|
{
|
||||||
self::assertInternalType('string', $list['name']);
|
self::assertInternalType('string', $list['name']);
|
||||||
self::assertInternalType('int', $list['id']);
|
self::assertInternalType('int', $list['id']);
|
||||||
|
@ -188,7 +186,7 @@ class ApiTest extends FixtureTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function assertXml($result, $root_element)
|
private function assertXml($result = '', $root_element = '')
|
||||||
{
|
{
|
||||||
self::assertStringStartsWith('<?xml version="1.0"?>', $result);
|
self::assertStringStartsWith('<?xml version="1.0"?>', $result);
|
||||||
self::assertContains('<' . $root_element, $result);
|
self::assertContains('<' . $root_element, $result);
|
||||||
|
@ -304,6 +302,7 @@ class ApiTest extends FixtureTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
|
* @preserveGlobalState disabled
|
||||||
* @expectedException Friendica\Network\HTTPException\UnauthorizedException
|
* @expectedException Friendica\Network\HTTPException\UnauthorizedException
|
||||||
*/
|
*/
|
||||||
public function testApiLoginWithoutLogin()
|
public function testApiLoginWithoutLogin()
|
||||||
|
@ -316,6 +315,7 @@ class ApiTest extends FixtureTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
|
* @preserveGlobalState disabled
|
||||||
* @expectedException Friendica\Network\HTTPException\UnauthorizedException
|
* @expectedException Friendica\Network\HTTPException\UnauthorizedException
|
||||||
*/
|
*/
|
||||||
public function testApiLoginWithBadLogin()
|
public function testApiLoginWithBadLogin()
|
||||||
|
@ -349,6 +349,7 @@ class ApiTest extends FixtureTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
|
* @doesNotPerformAssertions
|
||||||
*/
|
*/
|
||||||
public function testApiLoginWithCorrectLogin()
|
public function testApiLoginWithCorrectLogin()
|
||||||
{
|
{
|
||||||
|
@ -1312,8 +1313,8 @@ class ApiTest extends FixtureTest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the api_media_upload() function.
|
* Test the api_media_upload() function.
|
||||||
*
|
* @runInSeparateProcess
|
||||||
* @return void
|
* @preserveGlobalState disabled
|
||||||
* @expectedException Friendica\Network\HTTPException\BadRequestException
|
* @expectedException Friendica\Network\HTTPException\BadRequestException
|
||||||
*/
|
*/
|
||||||
public function testApiMediaUpload()
|
public function testApiMediaUpload()
|
||||||
|
@ -1504,7 +1505,7 @@ class ApiTest extends FixtureTest
|
||||||
$result = api_search('json');
|
$result = api_search('json');
|
||||||
foreach ($result['status'] as $status) {
|
foreach ($result['status'] as $status) {
|
||||||
self::assertStatus($status);
|
self::assertStatus($status);
|
||||||
self::assertContains('reply', $status['text'], null, true);
|
self::assertContains('reply', $status['text'], '', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1520,7 +1521,7 @@ class ApiTest extends FixtureTest
|
||||||
$result = api_search('json');
|
$result = api_search('json');
|
||||||
foreach ($result['status'] as $status) {
|
foreach ($result['status'] as $status) {
|
||||||
self::assertStatus($status);
|
self::assertStatus($status);
|
||||||
self::assertContains('reply', $status['text'], null, true);
|
self::assertContains('reply', $status['text'], '', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1536,14 +1537,13 @@ class ApiTest extends FixtureTest
|
||||||
$result = api_search('json');
|
$result = api_search('json');
|
||||||
foreach ($result['status'] as $status) {
|
foreach ($result['status'] as $status) {
|
||||||
self::assertStatus($status);
|
self::assertStatus($status);
|
||||||
self::assertContains('reply', $status['text'], null, true);
|
self::assertContains('reply', $status['text'], '', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the api_search() function with an q parameter contains hashtag.
|
* Test the api_search() function with an q parameter contains hashtag.
|
||||||
*
|
* @doesNotPerformAssertions
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testApiSearchWithHashtag()
|
public function testApiSearchWithHashtag()
|
||||||
{
|
{
|
||||||
|
@ -1551,14 +1551,13 @@ class ApiTest extends FixtureTest
|
||||||
$result = api_search('json');
|
$result = api_search('json');
|
||||||
foreach ($result['status'] as $status) {
|
foreach ($result['status'] as $status) {
|
||||||
self::assertStatus($status);
|
self::assertStatus($status);
|
||||||
self::assertContains('#friendica', $status['text'], null, true);
|
self::assertContains('#friendica', $status['text'], '', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the api_search() function with an exclude_replies parameter.
|
* Test the api_search() function with an exclude_replies parameter.
|
||||||
*
|
* @doesNotPerformAssertions
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testApiSearchWithExcludeReplies()
|
public function testApiSearchWithExcludeReplies()
|
||||||
{
|
{
|
||||||
|
@ -2474,8 +2473,7 @@ class ApiTest extends FixtureTest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the api_format_items() function.
|
* Test the api_format_items() function.
|
||||||
*
|
* @doesNotPerformAssertions
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testApiFormatItems()
|
public function testApiFormatItems()
|
||||||
{
|
{
|
||||||
|
@ -2500,8 +2498,7 @@ class ApiTest extends FixtureTest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the api_format_items() function with an XML result.
|
* Test the api_format_items() function with an XML result.
|
||||||
*
|
* @doesNotPerformAssertions
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testApiFormatItemsWithXml()
|
public function testApiFormatItemsWithXml()
|
||||||
{
|
{
|
||||||
|
@ -2617,8 +2614,7 @@ class ApiTest extends FixtureTest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the api_lists_statuses() function with a list ID.
|
* Test the api_lists_statuses() function with a list ID.
|
||||||
*
|
* @doesNotPerformAssertions
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function testApiListsStatusesWithListId()
|
public function testApiListsStatusesWithListId()
|
||||||
{
|
{
|
||||||
|
@ -3271,8 +3267,6 @@ class ApiTest extends FixtureTest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the api_fr_photo_create_update() function.
|
* Test the api_fr_photo_create_update() function.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @expectedException Friendica\Network\HTTPException\BadRequestException
|
* @expectedException Friendica\Network\HTTPException\BadRequestException
|
||||||
*/
|
*/
|
||||||
public function testApiFrPhotoCreateUpdate()
|
public function testApiFrPhotoCreateUpdate()
|
||||||
|
|
|
@ -40,6 +40,7 @@ class ArrayCacheTest extends MemoryCacheTest
|
||||||
public function testTTL()
|
public function testTTL()
|
||||||
{
|
{
|
||||||
// Array Cache doesn't support TTL
|
// Array Cache doesn't support TTL
|
||||||
|
self::markTestSkipped("Array Cache doesn't support TTL");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -463,10 +463,11 @@ class InstallerTest extends MockedTest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the setup of the config cache for installation
|
* Test the setup of the config cache for installation
|
||||||
|
* @doesNotPerformAssertions
|
||||||
*/
|
*/
|
||||||
public function testSetUpCache()
|
public function testSetUpCache()
|
||||||
{
|
{
|
||||||
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
|
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; })->times(5);
|
||||||
|
|
||||||
$install = new Installer();
|
$install = new Installer();
|
||||||
$configCache = Mockery::mock(Cache::class);
|
$configCache = Mockery::mock(Cache::class);
|
||||||
|
|
|
@ -33,7 +33,6 @@ class ArrayCacheLockTest extends LockTest
|
||||||
|
|
||||||
public function testLockTTL()
|
public function testLockTTL()
|
||||||
{
|
{
|
||||||
// ArrayCache doesn't support TTL
|
self::markTestSkipped("ArrayCache doesn't support TTL");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,7 @@ class SemaphoreLockTest extends LockTest
|
||||||
|
|
||||||
public function testLockTTL()
|
public function testLockTTL()
|
||||||
{
|
{
|
||||||
// Semaphore doesn't work with TTL
|
self::markTestSkipped("Semaphore doesn't work with TTL");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
namespace Friendica\Test\src\Security\TwoFactor\Factory;
|
namespace Friendica\Test\src\Security\TwoFactor\Factory;
|
||||||
|
|
||||||
use Friendica\Security\TwoFactor\Factory\TrustedBrowser;
|
use Friendica\Security\TwoFactor\Factory\TrustedBrowser;
|
||||||
|
use Friendica\Test\MockedTest;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Logger\VoidLogger;
|
use Friendica\Util\Logger\VoidLogger;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
class TrustedBrowserTest extends \PHPUnit_Framework_TestCase
|
class TrustedBrowserTest extends MockedTest
|
||||||
{
|
{
|
||||||
public function testCreateFromTableRowSuccess()
|
public function testCreateFromTableRowSuccess()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
namespace Friendica\Test\src\Security\TwoFactor\Model;
|
namespace Friendica\Test\src\Security\TwoFactor\Model;
|
||||||
|
|
||||||
use Friendica\Security\TwoFactor\Model\TrustedBrowser;
|
use Friendica\Security\TwoFactor\Model\TrustedBrowser;
|
||||||
|
use Friendica\Test\MockedTest;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
class TrustedBrowserTest extends \PHPUnit_Framework_TestCase
|
class TrustedBrowserTest extends MockedTest
|
||||||
{
|
{
|
||||||
public function test__construct()
|
public function test__construct()
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,7 @@ class ProfilerLoggerTest extends MockedTest
|
||||||
/**
|
/**
|
||||||
* Test if the profiler is profiling data
|
* Test if the profiler is profiling data
|
||||||
* @dataProvider dataTests
|
* @dataProvider dataTests
|
||||||
|
* @doesNotPerformAssertions
|
||||||
*/
|
*/
|
||||||
public function testProfiling($function, $message, array $context)
|
public function testProfiling($function, $message, array $context)
|
||||||
{
|
{
|
||||||
|
@ -64,6 +65,7 @@ class ProfilerLoggerTest extends MockedTest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the log() function
|
* Test the log() function
|
||||||
|
* @doesNotPerformAssertions
|
||||||
*/
|
*/
|
||||||
public function testProfilingLog()
|
public function testProfilingLog()
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,6 +95,7 @@ class SyslogLoggerTest extends AbstractLoggerTest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the close() method
|
* Test the close() method
|
||||||
|
* @doesNotPerformAssertions
|
||||||
*/
|
*/
|
||||||
public function testClose()
|
public function testClose()
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,7 @@ class VoidLoggerTest extends MockedTest
|
||||||
/**
|
/**
|
||||||
* Test if the profiler is profiling data
|
* Test if the profiler is profiling data
|
||||||
* @dataProvider dataTests
|
* @dataProvider dataTests
|
||||||
|
* @doesNotPerformAssertions
|
||||||
*/
|
*/
|
||||||
public function testNormal($function, $message, array $context)
|
public function testNormal($function, $message, array $context)
|
||||||
{
|
{
|
||||||
|
@ -41,6 +42,7 @@ class VoidLoggerTest extends MockedTest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the log() function
|
* Test the log() function
|
||||||
|
* @doesNotPerformAssertions
|
||||||
*/
|
*/
|
||||||
public function testProfilingLog()
|
public function testProfilingLog()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue