Skip to content

Commit 55ccddd

Browse files
committed
tests
1 parent a0d8bab commit 55ccddd

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

tests/Unit/ItemTest.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,6 +3313,78 @@ public function getPermalinkDataProvider()
33133313
];
33143314
}
33153315

3316+
/**
3317+
* @dataProvider getBaseProvider
3318+
*/
3319+
public function test_get_base($data, $expected)
3320+
{
3321+
$feed = new SimplePie();
3322+
$feed->set_raw_data($data);
3323+
$feed->enable_cache(false);
3324+
$feed->init();
3325+
3326+
$item = $feed->get_item(0);
3327+
$this->assertInstanceOf(Item::class, $item);
3328+
3329+
$this->assertSame($expected, $item->get_content());
3330+
}
3331+
3332+
public function getBaseProvider()
3333+
{
3334+
return [
3335+
'Test item get_base xml:base' => [
3336+
<<<EOT
3337+
<feed xmlns="http://www.w3.org/2005/Atom">
3338+
<title type="text">Test get_base 1</title>
3339+
<link rel="alternate" type="text/html" href="http://example.net/tests/"/>
3340+
<entry>
3341+
<title>Test get_base 1.1</title>
3342+
<link rel="alternate" type="text/html" href="http://example.net/tests/test1/example.html"/>
3343+
<id>tag:example.net,2022:1</id>
3344+
<content type="html" xml:base="http://example.net/tests/test2/">
3345+
&lt;a href="hello.html#world"&gt;Hello&lt;/a&gt;
3346+
</content>
3347+
</entry>
3348+
</feed>
3349+
EOT,
3350+
'<a href="http://example.net/tests/test2/hello.html#world">Hello</a>',
3351+
],
3352+
'Test item get_base item link' => [
3353+
<<<EOT
3354+
<feed xmlns="http://www.w3.org/2005/Atom">
3355+
<title type="text">Test get_base 2</title>
3356+
<link rel="alternate" type="text/html" href="http://example.net/tests/"/>
3357+
<entry>
3358+
<title>Test get_base 2.1</title>
3359+
<link rel="alternate" type="text/html" href="http://example.net/tests/test1/example.html"/>
3360+
<id>tag:example.net,2022:2</id>
3361+
<content type="html">
3362+
&lt;a href="hello.html#world"&gt;Hello&lt;/a&gt;
3363+
</content>
3364+
</entry>
3365+
</feed>
3366+
EOT,
3367+
'<a href="http://example.net/tests/test1/hello.html#world">Hello</a>',
3368+
],
3369+
'Test item get_base feed link' => [
3370+
<<<EOT
3371+
<feed xmlns="http://www.w3.org/2005/Atom">
3372+
<title type="text">Test get_base 3</title>
3373+
<link rel="alternate" type="text/html" href="http://example.net/tests/"/>
3374+
<entry>
3375+
<title>Test get_base 3.1</title>
3376+
<id>tag:example.net,2022:3</id>
3377+
<content type="xhtml">
3378+
<div xmlns="http://www.w3.org/1999/xhtml"><a href="hello.html#world">Hello</a></div>
3379+
</content>
3380+
</entry>
3381+
</feed>
3382+
EOT,
3383+
'<a href="http://example.net/tests/hello.html#world">Hello</a>',
3384+
],
3385+
];
3386+
}
3387+
33163388
/**
33173389
* @dataProvider getPermalinkDataProvider
33183390
*/

0 commit comments

Comments
 (0)