Hello,<br><br>I have a model (MyApp/Models/Bar.pm) which retrieves data from the db using the generated schema files (in MyApp/Schema/Result/*.pm).<br><br>My plan is to mock the classes which are called when retrieving data from the database.<br>
<br>BEGIN {<br>      my $resultset_mock = Test::MockObject-&gt;new();<br>      $resultset_mock-&gt;fake_module(&#39;DBIx::Class::ResultSet&#39; =&gt; ( &#39;count&#39; =&gt; sub { 0 } ));<br><br>      my $pin_attempt_mock = Test::MockObject-&gt;new();<br>
      $pin_attempt_mock-&gt;fake_module(&#39;MyApp::Schema::Result::Foo&#39; =&gt; (&#39;search&#39; =&gt; sub { bless $resultset_mock, &#39;DBIx::Class::ResultSet&#39; }));<br>}<br><br><br>BEGIN { use_ok &#39;MyApp::Model::Bar&#39; }<br>
<br>is (MyApp::Model::Bar-&gt;_get_failed_challenges(&#39;test&#39;, &#39;test&#39;),<br>    0,<br>    &#39;get failed challenges&#39;<br>    );<br><br>MyApp::Model::Bar-&gt;_get_failed_challenges contains calls to search and count (shown below) <br>
<br>my $result = $c-&gt;model(&#39;Foo&#39;)-&gt;search({...});<br>$result-&gt;count();<br><br>If I call MyApp::Schema::Result::Foo-&gt;search()-&gt;count() the mock returns 0 (and other values that I tested). However when I attempt to use test the Bar model the following error is returned.<br>
<br>&quot;You must pass a package name and it cannot be blessed at /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/Class/MOP/Class.pm line 41&quot;<br><br>Also if I follow the stack trace down into the MyApp files, it points to the line in 
MyApp::Model::Bar-&gt;_get_failed_challenges which calls search.<br><br>Any help would be appreciated!<br><br>Thanks,<br><br clear="all">-- Frank <br>