diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /tests/unit/lib/classes/OpenGraphTest.php | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'tests/unit/lib/classes/OpenGraphTest.php')
| -rw-r--r-- | tests/unit/lib/classes/OpenGraphTest.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/unit/lib/classes/OpenGraphTest.php b/tests/unit/lib/classes/OpenGraphTest.php new file mode 100644 index 0000000..416660b --- /dev/null +++ b/tests/unit/lib/classes/OpenGraphTest.php @@ -0,0 +1,34 @@ +<?php +/** + * @author Jan-Hendrik Willms <tleilax+studip@gmail.com> + * @license GPL2 or any later version + */ +class OpenGraphTest extends \Codeception\Test\Unit +{ + public function setUp(): void + { + static $config = [ + 'OPENGRAPH_ENABLE' => true, + ]; + + Config::set(new Config($config)); + } + + public function testURLExtraction() + { + $text = 'this is a link: https://example.org?foo=bar&bar=foo - believe it or not'; + $urls = OpenGraph::extractUrlsFromText($text); + + $this->assertCount(1, $urls); + $this->assertEquals('https://example.org?foo=bar&bar=foo', $urls[0]); + } + + public function testURLExtractionFromHTML() + { + $html = Studip\Markup::HTML_MARKER . '<a href="https://example.org?foo=bar&bar=foo">this is a link</a> - believe it or not'; + $urls = OpenGraph::extractUrlsFromHtml($html); + + $this->assertCount(1, $urls); + $this->assertEquals('https://example.org?foo=bar&bar=foo', $urls[0]); + } +} |
