blob: 416660b0c88b8dbb37f812f50798e2075218b2a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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]);
}
}
|