| 1 |
<?php
|
| 2 |
// $Id: simplepie.test,v 1.1.2.1 2008/09/01 22:54:08 mustafau Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
*/
|
| 7 |
|
| 8 |
class SimplePieTestCase extends DrupalWebTestCase {
|
| 9 |
public static function getInfo() {
|
| 10 |
return array(
|
| 11 |
'name' => 'SimplePie Core test case',
|
| 12 |
'description' => 'Tests whether SimplePie Core is working or not.',
|
| 13 |
'group' => 'SimplePie Core',
|
| 14 |
);
|
| 15 |
}
|
| 16 |
|
| 17 |
function setUp() {
|
| 18 |
parent::setUp('simplepie');
|
| 19 |
$web_user = $this->drupalCreateUser(array('administer news feeds', 'access news feeds'));
|
| 20 |
$this->drupalLogin($web_user);
|
| 21 |
}
|
| 22 |
|
| 23 |
function getRSS091Sample() {
|
| 24 |
$feed = <<<EOT
|
| 25 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 26 |
<rss version="0.91">
|
| 27 |
<channel>
|
| 28 |
<title>Example</title>
|
| 29 |
<link>http://example.com</link>
|
| 30 |
<description>Example updates</description>
|
| 31 |
<language>en-us</language>
|
| 32 |
<copyright>Copyright 2000, Example team.</copyright>
|
| 33 |
<managingEditor>editor@example.com</managingEditor>
|
| 34 |
<webMaster>webmaster@example.com</webMaster>
|
| 35 |
<image>
|
| 36 |
<title>Example</title>
|
| 37 |
<url>http://example.com/images/druplicon.png</url>
|
| 38 |
<link>http://example.com</link>
|
| 39 |
<width>88</width>
|
| 40 |
<height>100</height>
|
| 41 |
<description>Example updates</description>
|
| 42 |
</image>
|
| 43 |
<item>
|
| 44 |
<title>Example turns one</title>
|
| 45 |
<link>http://example.com/example-turns-one</link>
|
| 46 |
<description>Example turns one.</description>
|
| 47 |
</item>
|
| 48 |
</channel>
|
| 49 |
</rss>
|
| 50 |
EOT;
|
| 51 |
|
| 52 |
$path = 'public://rss091.xml';
|
| 53 |
return file_unmanaged_save_data($opml, $path);
|
| 54 |
}
|
| 55 |
|
| 56 |
function testSimplePie() {
|
| 57 |
$url = $this->getRSS091Sample();
|
| 58 |
$this->drupalGet($url);
|
| 59 |
$this->assertResponse(array(200), t('URL !url is accessible', array('!url' => $url)));
|
| 60 |
|
| 61 |
$simplepie = simplepie_get($url, FALSE, FALSE);
|
| 62 |
$this->assertEqual('Example', $simplepie->get_title(), t('Feed title matches; !title.', array('!title' => $simplepie->get_title())));
|
| 63 |
}
|
| 64 |
}
|