Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Catalyst + FormFu + Test::WWW::Mechanize::Catalyst = Kablooey

by matija (Priest)
on Oct 07, 2009 at 12:38 UTC ( [id://799707]=perlquestion: print w/replies, xml ) Need Help??

matija has asked for the wisdom of the Perl Monks concerning the following question:

I have a test file that goes somewhat like this:

#!/usr/bin/perl -w use strict; use FindBin; use lib "$FindBin::Bin/../lib"; use lib "$FindBin::Bin/../Myapp/lib/"; #use Test::MockObject; use Test::WWW::Mechanize::Catalyst; use Test::More tests=>12; use DateTime; use DateTime::Duration; my $mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'Myapp' +); # more tests make no difference
If the use Test::MockObject is commented out, everything works, and the test passes. But if the line is NOT commented out, I get
Deep recursion on subroutine "HTML::FormFu::base::render" at /usr/shar +e/perl5/HTML/FormFu/Element.pm line 34. Deep recursion on subroutine "UNIVERSAL::can::can" at /usr/share/perl5 +/UNIVERSAL/isa.pm line 60. Deep recursion on subroutine "UNIVERSAL::isa" at /usr/share/perl5/UNIV +ERSAL/can.pm line 43. Deep recursion on subroutine "UNIVERSAL::can::can" at /usr/share/perl5 +/HTML/FormFu/Element/_Field.pm line 158. Deep recursion on subroutine "UNIVERSAL::isa" at /usr/share/perl5/UNIV +ERSAL/can.pm line 43. Deep recursion on subroutine "HTML::FormFu::Element::Block::string" at + /usr/share/perl5/HTML/FormFu/base.pm line 15. Deep recursion on subroutine "HTML::FormFu::Element::_Input::string" a +t /usr/share/perl5/HTML/FormFu/base.pm line 15. Deep recursion on subroutine "HTML::FormFu::Element::render_data" at / +usr/share/perl5/HTML/FormFu/Element/_Input.pm line 39. Deep recursion on subroutine "HTML::FormFu::Element::_Input::render_da +ta_non_recursive" at /usr/share/perl5/HTML/FormFu/Element.pm line 190 +. Deep recursion on subroutine "HTML::FormFu::Element::_Field::render_da +ta_non_recursive" at /usr/lib/perl/5.10/mro.pm line 28. Deep recursion on subroutine "HTML::FormFu::Element::_Field::nested_na +me" at /usr/share/perl5/HTML/FormFu/Element/_Field.pm line 606. Deep recursion on subroutine "HTML::FormFu::Element::_Field::nested_na +mes" at /usr/share/perl5/HTML/FormFu/Element/_Field.pm line 130. Deep recursion on anonymous subroutine at /usr/share/perl5/UNIVERSAL/i +sa.pm line 35.

If I edit the controller and replace use base 'Catalyst::Controller::HTML::FormFu'; with use parent 'Catalyst::Controller'; then the Test::WWW::Mechanize::Catalyst object is allocated correctly, but, of course, nothing relying on FormFu works anymore.

Anybody ran into this before? Any ideas what this could be? Any ideas for work-arounds?

Replies are listed 'Best First'.
Re: Catalyst + FormFu + Test::WWW::Mechanize::Catalyst = Kablooey
by zby (Vicar) on Oct 07, 2009 at 19:41 UTC
    How about trying using HTML::FormFu directly? As far as I remember Catalyst::Controller::HTML::FormFu only loads a specified config file - but it is trivial to do that directly. Personally - I gave up with FormFu and use HTML::FormHandler by the way.
Re: Catalyst + FormFu + Test::WWW::Mechanize::Catalyst = Kablooey
by Your Mother (Archbishop) on Oct 07, 2009 at 19:58 UTC

    I echo zby's comments. I had the FormFu Controller auto-config-loader clash with another module (the REST Controller) and I was able to get them to cohabitate peacefully by doing the config manually.

      Can you show me how? I tried replacing the Catalyst/FormFu controller with a method of "use HTML::FormFu", and the problem persists.

        I think this is all I did but the code has moved a bit (REST is out for now but it was working with it in)-

        package MyApp::Controller::User; use strict; use warnings; use parent 'Catalyst::Controller::HTML::FormFu'; sub register : Local Args(0) Form { my ( $self, $c ) = @_; my $form = $self->form(); $form->load_config_filestem("user/register"); # et cetera... }
Re: Catalyst + FormFu + Test::WWW::Mechanize::Catalyst = Kablooey
by matija (Priest) on Oct 10, 2009 at 16:25 UTC

    Well, I've done some more digging, even up to creating a new catalyst project to see if I can figure out where the conflict occurs by adding stuff instead of commenting them out.

    I finally decided that the problem was not FormFu, but Test::MockObject. While tests where I had Test::WWW::Mechanize::Catalyst and Test::MockObject (but not FormFu) passed, if I tried to enter them with a debugger, allocating the mech object crashed.

    So I tried getting rid of Test::MockObject, and considering I only needed to mock a single method, I was able to do it with an assignment to %INC and a sub MyApp::Foo::Bar {...} declaration.

    I'll see if I can do all the tests I need in conjunction with Catalyst modules without using MockObject.

    But I want to thank the people who drew my attention to FormHandler. I may not use it in this project, but I think I'm going to use it in something soon...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://799707]
Approved by marto
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-19 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found