variables from outside of the view as well. I was trying to figure out
how the form helper does it (the way select options are automagically
pulled from $$associatedModelName) but wasn't able to find the code
where it's done. ClassRegistry is the best way to do this inside of a
helper as well, right?
On Apr 25, 3:31 pm, jacmoe <jac...@mail.dk> wrote:
> Here's how I do this:
> $view =& ClassRegistry::getObject('view');
> $some_view_var = isset($view->viewVars['var']
> ['another_var']) ? $view->viewVars['var']['another_var'] : null;
> I am aware that it is against CakePHP coding conventions to use the
> tertiary conditional operator, but I don't care. :P
>
> Cheers
>
> Jacob
>
> On Apr 25, 4:08 pm, wratke <wra...@rogers.com> wrote:
>
>
>
> > I'm wondering if there's any way to get the viewVars when unit testing
> > a
> > controller without using the testAction. I've taken a look at the
> > testAction function in the Cake code and see how it gets the View
> > object
> > and then dumps and returns the viewVars, but as far as I can tell
> > there
> > isn't any way to do something similar without using the testAction
> > function. Is there something in Cake that allows you to access the
> > viewVars that I'm missing? Or should I be dumping the viewVars from
> > the
> > View object manually in my tests? I'm excited to start testing my
> > controllers with Mock objects, but without having access to the
> > viewVars
> > set in the controller I'm finding it difficult to make any assertions
> > in
> > my tests to make sure things are being set properly.
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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 cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment