aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/lib/classes/OpenGraphTest.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2024-06-17 07:11:34 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2024-06-17 07:11:34 +0000
commit8f3ad43e9375a242f64a21d3c651834849db2d10 (patch)
treeb796caa65ab38a73832b78607ddfc35d05476aba /tests/unit/lib/classes/OpenGraphTest.php
parentfddbe49917aaa43b5b3fff3a505fa6afcf627a92 (diff)
fixes #3990
Closes #3990 Merge request studip/studip!2839
Diffstat (limited to 'tests/unit/lib/classes/OpenGraphTest.php')
-rw-r--r--tests/unit/lib/classes/OpenGraphTest.php34
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&amp;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]);
+ }
+}