MINOR Fixed RSSFeedTest which should put test configuration code into setUp() and tearDown() methods. If the test fails halfway through, these will get called to clean up the state

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@113430 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-11-04 03:34:17 +00:00 committed by Sam Minnee
parent 1050c7ee4e
commit 9bae66760a

View File

@ -4,18 +4,15 @@
* @subpackage tests
*/
class RSSFeedTest extends SapphireTest {
protected static $original_host;
function testRSSFeed() {
$list = new DataObjectSet();
$list->push(new RSSFeedTest_ItemA());
$list->push(new RSSFeedTest_ItemB());
$list->push(new RSSFeedTest_ItemC());
$origServer = $_SERVER;
$_SERVER['HTTP_HOST'] = 'www.example.org';
Director::setBaseURL('/');
$rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description");
$content = $rssFeed->feedContent();
@ -44,11 +41,21 @@ class RSSFeedTest extends SapphireTest {
$this->assertContains('<description>ItemA AltContent</description>', $content);
$this->assertContains('<description>ItemB AltContent</description>', $content);
$this->assertContains('<description>ItemC AltContent</description>', $content);
Director::setBaseURL(null);
$_SERVER = $origServer;
}
public function setUp() {
parent::setUp();
Director::setBaseURL('/');
if(!self::$original_host) self::$original_host = $_SERVER['HTTP_HOST'];
$_SERVER['HTTP_HOST'] = 'www.example.org';
}
public function tearDown() {
parent::tearDown();
Director::setBaseURL(null);
$_SERVER['HTTP_HOST'] = self::$original_host;
}
}
class RSSFeedTest_ItemA extends ViewableData {