Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Functional tests fail


Go to End


4 Posts   1975 Views

Avatar
Shane Garelja

Community Member, 18 Posts

9 March 2011 at 10:48pm

Hi,

I'm trying to write some functional tests but am having an issue getting a valid page back when using Director::test(). All I get is a 404 - page not found.

I have a simple test that calls:

$response1 = Director::test('contact/');
Debug::show("<!-- START ".$response1->getBody()." END -->");

The debug output shows HTML for the 404 page... so my test obviously fails because the HTML code I'm asserting to validate the page loaded properly is absent.

What am I missing here?

Avatar
Willr

Forum Moderator, 5523 Posts

11 March 2011 at 5:54pm

Is your contact page in your yaml file. Tests run in a 'new' database and not your sites database so any pages you have setup via the CMS won't be there.

Avatar
Shane Garelja

Community Member, 18 Posts

11 March 2011 at 6:08pm

Ahhh - yep. That's what I'm missing :) Thanks Will! Much appreciated.

Avatar
Rob Clarkson

Community Member, 26 Posts

31 May 2016 at 1:19pm

For anyone else that had an issue similar to this that presents with 404 errors with functional tests

Your pages are not published. The solution is to publish all your pages, or use the draft pages with this call

$this->useDraftSite();