comment + link extraction
[stapibas.git] / tests / stapibas / Content / Extractor / LinkTest.php
1 <?php
2 namespace stapibas;
3 require_once 'stapibas/autoloader.php';
4
5 class Content_Extractor_LinkTest extends \PHPUnit_Framework_TestCase
6 {
7     public function testExtractShadowBox()
8     {
9         $doc = new \DOMDocument();
10         @$doc->loadHtmlFile(__DIR__ . '/data/shadowbox-popup-positioning.htm');
11         $source = 'http://www.bogo/tagebuch/shadowbox-popup-positioning.htm';
12         $target = 'http://www.bogo/tagebuch/demo/shadowbox-manual-positioning/static.html';
13         
14         $logger = new Logger();
15         $logger->debug = true;
16         $cel = new Content_Extractor_Link($logger);
17         $link = $cel->extract($doc, $source, $target);
18         
19         $this->assertNotNull($link, 'No extracted data');
20
21         $this->assertEquals(
22             'Shadowbox: Manual popup positioning',
23             $link['title']
24         );
25
26         $this->assertEquals('Christian Weiske', $link['author_name']);
27         $this->assertNull($link['author_image']);
28         $this->assertEquals('http://www.bogo/', $link['author_url']);
29     }
30
31     public function testExtractXmlShadowBox()
32     {
33         $doc = new \DOMDocument();
34         @$doc->load(__DIR__ . '/data/shadowbox-popup-positioning.htm');
35         $source = 'http://www.bogo/tagebuch/shadowbox-popup-positioning.htm';
36         $target = 'http://www.bogo/tagebuch/demo/shadowbox-manual-positioning/static.html';
37         
38         $logger = new Logger();
39         $logger->debug = true;
40         $cel = new Content_Extractor_Link($logger);
41         $link = $cel->extract($doc, $source, $target);
42         
43         $this->assertNotNull($link, 'No extracted data');
44
45         $this->assertEquals(
46             'Shadowbox: Manual popup positioning',
47             $link['title']
48         );
49
50         $this->assertEquals('Christian Weiske', $link['author_name']);
51         $this->assertNull($link['author_image']);
52         $this->assertEquals('http://www.bogo/', $link['author_url']);
53     }
54
55     public function testExtractLaurent()
56     {
57         $doc = new \DOMDocument();
58         @$doc->loadHtmlFile(__DIR__ . '/data/laurent-eschenauer.html');
59         $source = 'http://eschnou.com/entry/testing-indieweb-federation-with-waterpigscouk-aaronpareckicom-and--62-24908.html';
60         $target = 'http://indiewebcamp.com';
61         
62         $logger = new Logger();
63         $logger->debug = true;
64         $cel = new Content_Extractor_Link($logger);
65         $link = $cel->extract($doc, $source, $target);
66         
67         $this->assertNotNull($link, 'No extracted data');
68
69         $this->assertEquals(
70             'Testing #indieweb federation with @waterpigs.co.uk, @aaronparecki.com and @indiewebcamp.com !',
71             $link['title']
72         );
73
74         $this->assertNull($link['author_name']);
75         $this->assertNull($link['author_image']);
76         $this->assertNull($link['author_url']);
77     }
78
79 }
80 ?>