Changeset 772 for trunk/app/tests

Show
Ignore:
Timestamp:
09/22/08 10:09:12 (2 months ago)
Author:
aarkerio
Message:

New Unit Testing models

Location:
trunk/app/tests
Files:
6 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/tests/cases/controllers/news_controller.test.php

    r771 r772  
    44  public function startCase()  
    55  {  
    6     echo '<h1>Starting Test Case</h1>';  
     6    echo '<h1>Starting News Test Case</h1>';  
    77  }  
    88  public function endCase() {  
    9     echo '<h1>Ending Test Case</h1>';  
     9    echo '<h1>Ending News Test Case</h1>';  
    1010  }  
    11   public public function startTest($method) {  
     11  public function startTest($method) {  
    1212    echo '<h3>Starting method ' . $method . '</h3>';  
    1313  }  
     
    1515    echo '<hr />';  
    1616  }  
    17   public function testDisplay() {  
    18     $result = $this->testAction('/news/display');  
     17  /* public function testDisplay()  
     18  {  
     19    $result = $this->testAction('/news/display', array('return'=>'render'));  
    1920    debug($result);  
    20   }  
     21  } */ 
    2122  public function testView()  
    2223  {  
    2324    $result = $this->testAction('/news/view/16', array('return'=>'render'));  
    24     debug($result);  
     25    // debug($result);  
     26  } 
     27  public function testDisplayNewIdGetRenderedHtml() 
     28  {  
     29    $result = $this->testAction('/news/display/16', array('return' => 'render'));  
     30    //debug(htmlentities($result));  
    2531  }  
    26   public function testDisplayGetRenderedHtml() {  
     32  /* public function testDisplayGetRenderedHtml() {  
    2733    $result = $this->testAction('/news/display/', array('return' => 'render'));  
    2834    debug(htmlentities($result));  
     
    3238                array('return' => 'vars'));  
    3339    debug($result);  
    34   }  
    35   public function testDiplayFixturized() {  
    36     $result = $this->testAction('/news/display/',  
    37                 array('fixturize' => true));  
    38     debug($result);  
     40  }*/ 
     41  public function testDisplayFixturized() {  
     42    $result = $this->testAction('/admin/news/add', array('fixturize' => true));  
     43    debug($result); 
    3944  }  
    4045  public function testDisplayPostFixturized()  
    4146  {  
    42     $data = array('News' => array('user_id' => 1, 'published'  
    43                      => 1, 'slug'=>'new-article', 'title' => 'New Article', 'body' => 'New Body'));  
    44     $result = $this->testAction('/news/display',  
    45                 array('fixturize' => true, 'data' => $data, 'method' => 'post'));  
     47    $data = array('News' => array('user_id' =>1, 'status'=>1, 'title' => 'New Article', 'body' => 'New Body'));  
     48    $result = $this->testAction('/admin/news/add', array('fixturize' => true, 'method' => 'post'));  
    4649    debug($result);  
    4750  }  
  • trunk/app/tests/fixtures/news_test_fixture.php

    r771 r772  
    1 <?php   
     1<?php 
    22// News Model Unit Test 
    33class NewsTestFixture extends CakeTestFixture {  
    44 
    55  public $name   = 'NewsTest';  
    6   public $import = array('model' => 'News', 'records' => true);   
     6  //public $import = array('model' => 'News', 'records' => true, 'conection'=>'default');   
    77  public $fields = array(  
    88              'id'        => array('type' => 'integer', 'key' => 'primary'),  
    99              'title'     => array('type'=>'string', 'length'=>50, 'null'=>false),  
    1010              'body'      => array('type'=>'text', 'null'=>false),  
    11               'published' => array('type' => 'integer', 'default' => 0, 'null' => false), 
     11              'status'    => array('type' => 'integer', 'default' => 0, 'null' => false), 
    1212                      'user_id'   => array('type' => 'integer', 'default' => 1, 'null' => false),  
    1313              'created'   => 'timestamp',