diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-06-17 07:11:34 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2024-06-17 09:20:16 +0200 |
| commit | d0d150ec25fcfdae66e473d6021703e9a2861a3c (patch) | |
| tree | 3e39ff5522f3165be4d9bae0f735e4e6701d02f4 /tests | |
| parent | 80652e3036134217927f707f3019456f1a4ffa69 (diff) | |
fixes #3990
Closes #3990
Merge request studip/studip!2839
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/lib/VisualTest.php | 1 | ||||
| -rw-r--r-- | tests/unit/lib/classes/OpenGraphTest.php | 34 |
2 files changed, 34 insertions, 1 deletions
diff --git a/tests/unit/lib/VisualTest.php b/tests/unit/lib/VisualTest.php index dfa2945..5eeb8b2 100644 --- a/tests/unit/lib/VisualTest.php +++ b/tests/unit/lib/VisualTest.php @@ -10,7 +10,6 @@ */ require_once 'lib/models/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&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]); + } +} |
