mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
1050c7ee4e
commit
9bae66760a
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user