Re: Test Controller with Fixtures problem

2010-07-28 Thread generaltao
This can be closed - for anybody having this prob in the future:

Always make sure to create fixtures for all models in your system if
you're adding the tests late in the game. Furthermore, sometimes you
will get extra problems if you didn't set your fixtures to import
records, so ensure you're doing that too.

Good luck!



On Jul 27, 10:29 am, generaltao general...@gmail.com wrote:
 I'm getting a terribly strange problem whereby if I add the var
 $fitures to my test controller I end up with a very specific error
 when firing testAction. I had to add a $fixtures collection simply
 because we have a whole bunch of models in the system already and it
 seemed to be looking for test_suite_table tables. Adding fixtures
 for these models seemed to do the trick. However, here is the error I
 get on even the very first testAction fired:

 Error:  The requested address '/test/en/articles' was not found on
 this server.

 I can't figure out why this would only happen if I include a $fixtures
 collection on the test controller. Anybody have ideas?

 Here is my test controller, pulled almost exactly from cake's docs. If
 anybody can help me out that would be fantastic.

 ?php
 class ArticleTestControllerTest extends CakeTestCase {

    var $fixtures = array(
        'app.widget',
    );

    function startCase() {
      echo 'h1Starting Test Case/h1';
    }

    function endCase() {
      echo 'h1Ending Test Case/h1';
    }

    function startTest($method) {
      echo 'h3Starting method ' . $method . '/h3';
    }

    function endTest($method) {
      echo 'hr /';
    }

    function testIndex() {
      $result = $this-testAction('test/en/articles',
       array('fixturize'=false)
      );
      debug($result);
    }

    function testIndexShort() {
      $result = $this-testAction('test/en/articles/index/short');
      debug($result);
    }

    function testIndexShortGetRenderedHtml() {
      $result = $this-testAction('test/en/articles/index/short',
      array('return' = 'render'));
      debug(htmlentities($result));
    }

    function testIndexShortGetViewVars() {
      $result = $this-testAction('test/en/articles/index/short',
      array('return' = 'vars'));
      debug($result);
    }

    function testIndexFixturized() {
      $result = $this-testAction(
         'test/en/articles/index/short',
         array(
             'fixturize'=true
         )
      );
      debug($result);
    }

    function testIndexPostFixturized() {
      $data = array('Article' = array('user_id' = 1, 'published'
           = 1, 'slug'='new-article', 'title' = 'New Article',
 'body' = 'New Body'));
      $result = $this-testAction('test/en/articles/index',
      array('fixturize' = true, 'data' = $data, 'method' =
 'post'));
      debug($result);
    }}

 ?

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Test Controller with Fixtures problem

2010-07-27 Thread generaltao
I'm getting a terribly strange problem whereby if I add the var
$fitures to my test controller I end up with a very specific error
when firing testAction. I had to add a $fixtures collection simply
because we have a whole bunch of models in the system already and it
seemed to be looking for test_suite_table tables. Adding fixtures
for these models seemed to do the trick. However, here is the error I
get on even the very first testAction fired:

Error:  The requested address '/test/en/articles' was not found on
this server.

I can't figure out why this would only happen if I include a $fixtures
collection on the test controller. Anybody have ideas?

Here is my test controller, pulled almost exactly from cake's docs. If
anybody can help me out that would be fantastic.

?php
class ArticleTestControllerTest extends CakeTestCase {

   var $fixtures = array(
   'app.widget',
   );


   function startCase() {
 echo 'h1Starting Test Case/h1';
   }

   function endCase() {
 echo 'h1Ending Test Case/h1';
   }

   function startTest($method) {
 echo 'h3Starting method ' . $method . '/h3';
   }

   function endTest($method) {
 echo 'hr /';
   }

   function testIndex() {
 $result = $this-testAction('test/en/articles',
  array('fixturize'=false)
 );
 debug($result);
   }

   function testIndexShort() {
 $result = $this-testAction('test/en/articles/index/short');
 debug($result);
   }

   function testIndexShortGetRenderedHtml() {
 $result = $this-testAction('test/en/articles/index/short',
 array('return' = 'render'));
 debug(htmlentities($result));
   }

   function testIndexShortGetViewVars() {
 $result = $this-testAction('test/en/articles/index/short',
 array('return' = 'vars'));
 debug($result);
   }

   function testIndexFixturized() {
 $result = $this-testAction(
'test/en/articles/index/short',
array(
'fixturize'=true
)
 );
 debug($result);
   }

   function testIndexPostFixturized() {
 $data = array('Article' = array('user_id' = 1, 'published'
  = 1, 'slug'='new-article', 'title' = 'New Article',
'body' = 'New Body'));
 $result = $this-testAction('test/en/articles/index',
 array('fixturize' = true, 'data' = $data, 'method' =
'post'));
 debug($result);
   }
}
?

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en