Fixtures in WebTestCase?

http://book.cakephp.org/view/1219/Web-testing-Testing-views#About-CakeWebTestCase-1220

Short answer: Nope.

Long answer: Eventhough you can't use fixtures, you can still make
your app use a secondary database instead of your production one.
This is not a CakePHP solution, rather than a manipulation of
SimpleTest.  The idea of a web test case is to test your app as a
whole.  It basically simulates a browser that you can make calls on
your app, submit forms, click links, etc...  The idea is to test the
app in a real browser and as such it uses the real database as your
app doesn't know any better.... unless you make your app smarter.

I highly suggest you read through the documentation at SimpleTest as
well as poke your head into the actual source.  By doing so you'll
notice you can directly access the browser being used by the
WebTestCase with getBrowser(). With that, if you look into what you
can do on the browser (http://simpletest.sourceforge.net/en/
browser_documentation.html) you can add additional headers to each
request.   Your app then can look at the request before doing
anything, if your specified test header is present, switch the default
database constructor to use a test database instead of your production
one and you're free to run as many webtests as you please.

What I do, and most of the companies/clients I've worked for, is have
three environments, development, staging, and production.  Each have
their own separate database they connect to and are maintained through
various migrations/source control.  Staging is for all purposes
identical to production, except for the fact it's connected to a
different non-live database (and is usually closed to the public).  As
such it is safe to run web tests on staging as it doesn't affect the
live database.  The idea being, if there is a problem you'll discover
it first on the staging site before it gets pushed over to your
production site.

Hope that helps,
Nick

On Sep 14, 3:43 am, psybear83 <[email protected]> wrote:
> Dear CakePHP community
>
> I'm asking this question (or related ones) for quite a short while
> now, and I still didn't get a clear answer. So I ask one more single
> time:
>
> Is there a way to use fixtures with web tests (CakeWebTestCase, not
> CakeTestCase!), or not?
>
> I'd like to create useful web tests that test my application like a
> bunch of real users would, andit would be really, really useful to
> have fixtures available for these tests like one has with unit tests.
> But I didn't find an article or something like that yet... maybe I was
> just blind (I really hope this is the case).
>
> Thanks a lot for help
> Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to