I have some problems with the TestSuite. Controller functions:
function admin_view($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid Article.', true)); $this->redirect(array('action'=>'index')); } $this->set('article', $this->Article->read(null, $id)); } function admin_add() { if (!empty($this->data)) { $this->Article->create(); $this->data['Article']['text'] = $this->__formatText($this->data ['Article']['text']); if ($this->Article->save($this->data)) { $this->Session->setFlash(__('The Article has been saved', true)); // $this->redirect(array('action'=>'index')); } else { $result = true; $this->Session->setFlash(__('The Article could not be saved. Please, try again.', true)); } $result = $this->Article->findAll(); } $authors = $this->Article->Author->find('list'); $this->set(compact('authors')); } Test file: <?php /* SVN FILE: $Id$ */ /* ArticlesController Test cases generated on: 2008-12-22 18:12:14 : 1229966834*/ App::import('Controller', 'Articles'); class TestArticles extends ArticlesController { var $autoRender = false; } class ArticlesControllerTest extends CakeTestCase { var $Articles = null; function setUp() { $this->Articles = new TestArticles(); $this->Articles->constructClasses(); } function testArticlesControllerInstance() { $this->assertTrue(is_a($this->Articles, 'ArticlesController')); } function testAddMargin() { $expected = 160; $result = $this->Articles->__addMargin(100, 0.6); debug('Expected: '. $expected); debug('Result: '. $result); $this->assertEqual($result, $expected); } function testAdminArticleDetail() { $viewVars = $this->testAction('/admin/articles/view/1', array ('return' => 'vars')); debug(is_array($viewVars['article']['Article'])); $this->assertTrue(is_array($viewVars['article']['Article'])); } function testAdminArticlesAdd() { $result = $this->testAction( '/admin/articles/add', array( 'method' => 'post', 'data' => array('Article' => array( 'headline_1' => 'Lorem ipsum dolor sit amet', 'text' => 'Lorem ipsum dolor sit amet, aliquet feugiat.' )), 'fixturize' => false, 'return' => 'render' )); debug($result); $this->assertTrue(preg_match('/has been saved/i', $result)); } function tearDown() { unset($this->Articles); } } ?> Now my Problem: 1. When I write another value than 'return' => 'vars', I don't get an output. So testAdminArticlesAdd() fails! 2. testAdminArticleDetail() don't fail, but when I click on 'Show Passes', I get this error: Missung Contoller - Error: Test.phpController could not be found. 3. When I set 'fixturize' true, the testAdminArticlesAdd() test fails because a table is missing. Not the article table, but a table which has a relation to article. 4. // $this->redirect(array('action'=>'index')); Problem: I have try out some solutions, but no one really works. Is there an example for a working solution. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---