*
* 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
+ *
+ * @backupGlobals enabled
*/
class ApiTest extends FixtureTest
{
'authenticated' => true,
'uid' => $this->selfUser['id']
];
-
- $_POST = [];
- $_GET = [];
- $_SERVER = [];
}
/**
*
* @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_str']);
*
* @return void
*/
- private function assertStatus(array $status)
+ private function assertStatus(array $status = [])
{
- self::assertInternalType('string', $status['text']);
- self::assertInternalType('int', $status['id']);
+ self::assertInternalType('string', $status['text'] ?? '');
+ self::assertInternalType('int', $status['id'] ?? '');
// We could probably do more checks here.
}
*
* @return void
*/
- private function assertList(array $list)
+ private function assertList(array $list = [])
{
self::assertInternalType('string', $list['name']);
self::assertInternalType('int', $list['id']);
*
* @return void
*/
- private function assertXml($result, $root_element)
+ private function assertXml($result = '', $root_element = '')
{
self::assertStringStartsWith('<?xml version="1.0"?>', $result);
self::assertContains('<' . $root_element, $result);
*
* @return void
* @runInSeparateProcess
+ * @preserveGlobalState disabled
* @expectedException Friendica\Network\HTTPException\UnauthorizedException
*/
public function testApiLoginWithoutLogin()
*
* @return void
* @runInSeparateProcess
+ * @preserveGlobalState disabled
* @expectedException Friendica\Network\HTTPException\UnauthorizedException
*/
public function testApiLoginWithBadLogin()
*
* @return void
* @runInSeparateProcess
+ * @doesNotPerformAssertions
*/
public function testApiLoginWithCorrectLogin()
{
/**
* Test the api_media_upload() function.
- *
- * @return void
+ * @runInSeparateProcess
+ * @preserveGlobalState disabled
* @expectedException Friendica\Network\HTTPException\BadRequestException
*/
public function testApiMediaUpload()
$result = api_search('json');
foreach ($result['status'] as $status) {
self::assertStatus($status);
- self::assertContains('reply', $status['text'], null, true);
+ self::assertContains('reply', $status['text'], '', true);
}
}
$result = api_search('json');
foreach ($result['status'] as $status) {
self::assertStatus($status);
- self::assertContains('reply', $status['text'], null, true);
+ self::assertContains('reply', $status['text'], '', true);
}
}
$result = api_search('json');
foreach ($result['status'] as $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.
- *
- * @return void
+ * @doesNotPerformAssertions
*/
public function testApiSearchWithHashtag()
{
$result = api_search('json');
foreach ($result['status'] as $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.
- *
- * @return void
+ * @doesNotPerformAssertions
*/
public function testApiSearchWithExcludeReplies()
{
/**
* Test the api_format_items() function.
- *
- * @return void
+ * @doesNotPerformAssertions
*/
public function testApiFormatItems()
{
/**
* Test the api_format_items() function with an XML result.
- *
- * @return void
+ * @doesNotPerformAssertions
*/
public function testApiFormatItemsWithXml()
{
/**
* Test the api_lists_statuses() function with a list ID.
- *
- * @return void
+ * @doesNotPerformAssertions
*/
public function testApiListsStatusesWithListId()
{
/**
* Test the api_fr_photo_create_update() function.
- *
- * @return void
* @expectedException Friendica\Network\HTTPException\BadRequestException
*/
public function testApiFrPhotoCreateUpdate()