Skip to content

Commit

Permalink
MINOR Fixed RSSFeedTest which should put test configuration code into…
Browse files Browse the repository at this point in the history
… setUp() and tearDown() methods. If the test fails halfway through, these will get called to clean up the state (from r113430)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@114535 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
Sam Minnee committed Dec 5, 2010
1 parent 1a3897a commit 400157c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tests/api/RSSFeedTest.php
Expand Up @@ -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();

Expand Down Expand Up @@ -44,11 +41,21 @@ function testRSSFeed() {
$this->assertContains('<description>ItemA AltContent</description>', $content);
$this->assertContains('<description>ItemB AltContent</description>', $content);
$this->assertContains('<description>ItemC AltContent</description>', $content);

}

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 = $origServer;
$_SERVER['HTTP_HOST'] = self::$original_host;
}

}

class RSSFeedTest_ItemA extends ViewableData {
Expand Down

0 comments on commit 400157c

Please sign in to comment.