Changeset 771 for trunk/app/tests

Show
Ignore:
Timestamp:
09/20/08 15:32:48 (2 months ago)
Author:
aarkerio
Message:

New Unit Testing models

Location:
trunk/app/tests
Files:
4 added
3 modified

Legend:

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

    r533 r771  
    11<?php  
     2// Chipotle Software 2002-2008 GPLv3 
     3// MM  
    24class EntriesControllerTest extends CakeTestCase {  
     5 
    36  public function startCase()  
    47  {  
     
    2124  }  
    2225 
    23   public function testIndex()  
     26  public function testDisplay()  
    2427  {  
    25     $result = $this->testAction('/entries/index');  
     28    $result = $this->testAction('/entries/display');  
    2629    debug($result);  
    2730  } 
     
    5457  public function testIndexPostFixturized()  
    5558  {  
    56     $data = array('Article' => array('user_id' => 1, 'published'  
     59    $data = array('Entry' => array('user_id' => 1, 'published'  
    5760                     => 1, 'slug'=>'new-article', 'title' => 'New Article', 'body' => 'New Body'));  
    5861    $result = $this->testAction('/entries/index',  
  • trunk/app/tests/cases/models/entry.test.php

    r533 r771  
    11<?php   
    2  App::import('Model','Entry');  
     2// Chipotle Software 2002-2008 GLv3 
     3 
     4App::import('Model','Entry');  
    35    
    46class EntryTest extends Entry {  
    5   public $name = 'EntryTest';  
    6   public $useDbConfig = 'test_suite';  
     7  public $name        = 'EntryTest';  
     8  public $useDbConfig = 'test_suit';  
    79}  
    810    
    911class EntryTestCase extends CakeTestCase {  
    10   public $fixtures = array('entry_test' );  
    1112 
    12   public function testPublished()  
     13  public $fixtures = array('app.entry_test');  
     14  /* 
     15  public function testGetComments()  
    1316  { 
    1417    $this->EntryTest =& new EntryTest(); 
    1518     
    16     $result = $this->EntryTest->published(array('id', 'title')); 
     19    $result = $this->EntryTest->getComments(2); 
     20 
    1721    $expected = array( 
    1822              array('EntryTest' => array( 'id' => 1, 'title' => 'First Entry' )), 
     
    2226     
    2327    $this->assertEqual($result, $expected); 
    24   } 
     28  }*/ 
    2529}  
    2630?> 
  • trunk/app/tests/fixtures/entry_test_fixture.php

    r533 r771  
    11<?php   
     2// Entry Model Unit Test 
    23class EntryTestFixture extends CakeTestFixture {  
    34 
     
    56  public $import = array('model' => 'Entry', 'records' => true);   
    67  public $fields = array(  
    7               'id' => array('type' => 'integer', 'key' => 'primary'),  
    8               'title' => array('type' => 'string', 'length' => 255, 'null' => false),  
    9               'body' => 'text',  
    10               'published' => array('type' => 'integer', 'default' => '0', 'null' => false),  
    11               'created' => 'datetime',  
    12                       'updated' => 'datetime'  
    13               );  
    14   public $records = array(  
    15                array ('id' => 1, 'title' => 'First Entry', 'body' => 'First Entry Body', 'published' => '1', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),  
    16                array ('id' => 2, 'title' => 'Second Entry', 'body' => 'Second Entry Body', 'published' => '1', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'),  
    17                array ('id' => 3, 'title' => 'Third Entry', 'body' => 'Third Entry Body', 'published' => '1', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31')  
     8              'id'        => array('type' => 'integer', 'key' => 'primary'),  
     9              'title'     => array('type'=>'string', 'length'=>50, 'null'=>false),  
     10              'body'      => array('type'=>'text', 'null'=>false),  
     11              'published' => array('type' => 'integer', 'default' => 0, 'null' => false), 
     12                      'user_id'   => array('type' => 'integer', 'default' => 1, 'null' => false),  
     13              'created'   => 'timestamp',  
     14                      'updated'   => 'timestamp'  
     15              ); 
     16  public $records = array( 
     17               array('id'=>1, 'title' => 'First Entry', 'body' => 'First Entry Body', 'published'=>1, 'user_id'=>1, 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),  
     18               array('id'=>2, 'title' => 'Second Entry', 'body' => 'Second Entry Body', 'published' => 1, 'user_id'=>1, 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'),  
     19               array('id'=>3, 'title'=>'Third Entry', 'body' => 'Third Entry Body', 'published' => 1, 'user_id'=>1, 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31')  
    1820               );  
    1921}