aboutsummaryrefslogtreecommitdiff
path: root/tests
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
parentfddbe49917aaa43b5b3fff3a505fa6afcf627a92 (diff)
fixes #3990
Closes #3990 Merge request studip/studip!2839
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/lib/VisualTest.php1
-rw-r--r--tests/unit/lib/classes/OpenGraphTest.php34
2 files changed, 34 insertions, 1 deletions
diff --git a/tests/unit/lib/VisualTest.php b/tests/unit/lib/VisualTest.php
index ae9263f..2e75b1f 100644
--- a/tests/unit/lib/VisualTest.php
+++ b/tests/unit/lib/VisualTest.php
@@ -10,7 +10,6 @@
*/
require_once 'lib/classes/SimpleORMap.class.php';
-require_once 'lib/models/OpenGraphURL.class.php';
require_once 'lib/visual.inc.php';
require_once 'lib/classes/Config.class.php';
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]);
+ }
+}