Replace assertContains() for string assertions

This commit is contained in:
Philipp 2021-05-23 23:16:33 +02:00
parent dda817cad8
commit a361a1af6a
No known key found for this signature in database
GPG Key ID: 9A28B7D4FF5667BD
3 changed files with 24 additions and 24 deletions

View File

@ -189,7 +189,7 @@ class ApiTest extends FixtureTest
private function assertXml($result = '', $root_element = '')
{
self::assertStringStartsWith('<?xml version="1.0"?>', $result);
self::assertContains('<' . $root_element, $result);
self::assertStringContainsString('<' . $root_element, $result);
// We could probably do more checks here.
}
@ -1505,7 +1505,7 @@ class ApiTest extends FixtureTest
$result = api_search('json');
foreach ($result['status'] as $status) {
self::assertStatus($status);
self::assertContains('reply', $status['text'], '', true);
self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
}
}
@ -1521,7 +1521,7 @@ class ApiTest extends FixtureTest
$result = api_search('json');
foreach ($result['status'] as $status) {
self::assertStatus($status);
self::assertContains('reply', $status['text'], '', true);
self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
}
}
@ -1537,7 +1537,7 @@ class ApiTest extends FixtureTest
$result = api_search('json');
foreach ($result['status'] as $status) {
self::assertStatus($status);
self::assertContains('reply', $status['text'], '', true);
self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
}
}
@ -1551,7 +1551,7 @@ class ApiTest extends FixtureTest
$result = api_search('json');
foreach ($result['status'] as $status) {
self::assertStatus($status);
self::assertContains('#friendica', $status['text'], '', true);
self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
}
}
@ -2874,7 +2874,7 @@ class ApiTest extends FixtureTest
$_POST['text'] = 'message_text';
$_POST['screen_name'] = $this->friendUser['nick'];
$result = api_direct_messages_new('json');
self::assertContains('message_text', $result['direct_message']['text']);
self::assertStringContainsString('message_text', $result['direct_message']['text']);
self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
self::assertEquals(1, $result['direct_message']['friendica_seen']);
}
@ -2891,8 +2891,8 @@ class ApiTest extends FixtureTest
$_POST['screen_name'] = $this->friendUser['nick'];
$_REQUEST['title'] = 'message_title';
$result = api_direct_messages_new('json');
self::assertContains('message_text', $result['direct_message']['text']);
self::assertContains('message_title', $result['direct_message']['text']);
self::assertStringContainsString('message_text', $result['direct_message']['text']);
self::assertStringContainsString('message_title', $result['direct_message']['text']);
self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
self::assertEquals(1, $result['direct_message']['friendica_seen']);
}

View File

@ -78,16 +78,16 @@ class EMailerTest extends MockedTest
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']);
self::assertStringContainsString("X-Friendica-Host: friendica.local", EmailerSpy::$MAIL_DATA['headers']);
self::assertStringContainsString("X-Friendica-Platform: Friendica", EmailerSpy::$MAIL_DATA['headers']);
self::assertStringContainsString("List-ID: <notification.friendica.local>", EmailerSpy::$MAIL_DATA['headers']);
self::assertStringContainsString("List-Archive: <http://friendica.local/notifications/system>", EmailerSpy::$MAIL_DATA['headers']);
self::assertStringContainsString("Reply-To: Sender <sender@friendica.local>", EmailerSpy::$MAIL_DATA['headers']);
self::assertStringContainsString("MIME-Version: 1.0", EmailerSpy::$MAIL_DATA['headers']);
// Base64 "Test Text"
self::assertContains(chunk_split(base64_encode('Test Text')), EmailerSpy::$MAIL_DATA['body']);
self::assertStringContainsString(chunk_split(base64_encode('Test Text')), EmailerSpy::$MAIL_DATA['body']);
// Base64 "Test Message<b>Bold</b>"
self::assertContains(chunk_split(base64_encode("Test Message<b>Bold</b>")), EmailerSpy::$MAIL_DATA['body']);
self::assertStringContainsString(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']);

View File

@ -106,8 +106,8 @@ abstract class AbstractLoggerTest extends MockedTest
$logger->emergency('A {psr} test', ['psr' => 'working']);
$logger->alert('An {array} test', ['array' => ['it', 'is', 'working']]);
$text = $this->getContent();
self::assertContains('A working test', $text);
self::assertContains('An ["it","is","working"] test', $text);
self::assertStringContainsString('A working test', $text);
self::assertStringContainsString('An ["it","is","working"] test', $text);
}
/**
@ -119,9 +119,9 @@ abstract class AbstractLoggerTest extends MockedTest
$logger->emergency('A test');
$text = $this->getContent();
self::assertContains('"file":"' . self::FILE . '"', $text);
self::assertContains('"line":' . self::LINE, $text);
self::assertContains('"function":"' . self::FUNC . '"', $text);
self::assertStringContainsString('"file":"' . self::FILE . '"', $text);
self::assertStringContainsString('"line":' . self::LINE, $text);
self::assertStringContainsString('"function":"' . self::FUNC . '"', $text);
}
/**
@ -157,7 +157,7 @@ abstract class AbstractLoggerTest extends MockedTest
self::assertLogline($text);
self::assertContains(@json_encode($context), $text);
self::assertStringContainsString(@json_encode($context), $text);
}
/**
@ -176,7 +176,7 @@ abstract class AbstractLoggerTest extends MockedTest
self::assertLogline($text);
self::assertContains(@json_encode($assertion), $this->getContent());
self::assertStringContainsString(@json_encode($assertion), $this->getContent());
}
public function testNoObjectHandling()
@ -187,6 +187,6 @@ abstract class AbstractLoggerTest extends MockedTest
self::assertLogline($text);
self::assertContains('test', $this->getContent());
self::assertStringContainsString('test', $this->getContent());
}
}