Changeset 771

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

New Unit Testing models

Location:
trunk/app
Files:
4 added
11 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/postgresql/entries.sql

    r750 r771  
    11-- entries in the users blogs 
    22CREATE TABLE entries ( 
    3 id serial PRIMARY KEY, 
    4 title varchar(50) NOT NULL, 
    5 body text NOT NULL, 
    6 subject_id int REFERENCES subjects(id) NOT NULL, 
    7 created timestamp(0) with time zone DEFAULT now() NOT NULL, 
    8 status int NOT NULL DEFAULT 0, 
    9 user_id int REFERENCES users(id) ON DELETE CASCADE, 
    10 discution int NOT NULL DEFAULT 0,  -- discution, Activ/Desactiv   1/0 
    11 "karanet" smallint NOT NULL DEFAULT 0 
     3 id serial PRIMARY KEY, 
     4 title varchar(50) NOT NULL, 
     5 body text NOT NULL, 
     6 subject_id int REFERENCES subjects(id) NOT NULL, 
     7 created timestamp(0) with time zone DEFAULT now() NOT NULL, 
     8 status int NOT NULL DEFAULT 0, 
     9 user_id int REFERENCES users(id) ON DELETE CASCADE, 
     10 discution int NOT NULL DEFAULT 0,  -- discution, Activ/Desactiv   1/0 
     11 "karanet" smallint NOT NULL DEFAULT 0 
    1212); 
    1313-- search engine index 
  • trunk/app/config/sql/postgresql/resources.sql

    r436 r771  
    1 -- table for school library 
    2 CREATE TABLE resources ( 
    3 id serial PRIMARY KEY, 
    4 clasification varchar(40) NOT NULL UNIQUE, 
    5 media smallint NOT NULL,  -- Book, CD, LP, magazine 
    6 title varchar (100), 
    7 author varchar(90) NOT NULL, 
    8 edition smallint,    
    9 editor varchar(100),     
    10 cost money, 
    11 copies smallint NOT NULL DEFAULT 1 
     1-- tables for school library 
     2 
     3CREATE TABLE types ( 
     4  id serial PRIMARY KEY, 
     5  type varchar(80) NOT NULL 
    126); 
    137 
     8INSERT INTO types (type) VALUES ('Book');  
     9INSERT INTO types (type) VALUES ('Magazine'); 
     10INSERT INTO types (type) VALUES ('Newspaper'); 
     11INSERT INTO types (type) VALUES ('DVD'); 
     12INSERT INTO types (type) VALUES ('CD'); 
     13 
     14 
     15CREATE TABLE resources ( 
     16  id serial PRIMARY KEY, 
     17  clasification varchar(40) NOT NULL UNIQUE, 
     18  type_id smallint NOT NULL references types(id) ON DELETE CASCADE,  -- Book, CD, LP, periodicals 
     19  title varchar (100), 
     20  author varchar(150) NOT NULL, 
     21  edition smallint, 
     22  editor varchar(100), 
     23  isonumber varchar(20), --ISBN, ISSN, NS 
     24  cost money DEFAULT '0.0', 
     25  copies smallint NOT NULL DEFAULT 1, 
     26  created timestamp(0) without time zone DEFAULT now() NOT NULL 
     27); 
     28 
     29-- Prestamos 
     30CREATE TABLE lendings ( 
     31  id serial PRIMARY KEY, 
     32  resource_id int NOT NULL references resources(id), 
     33  lend timestamp(0) without time zone DEFAULT now() NOT NULL, 
     34  days smallint NOT NULL DEFAULT 7, 
     35  user_id int NOT NULL references users(id) 
     36); 
  • trunk/app/controllers/wikis_controller.php

    r770 r771  
    8181        if ($this->Wiki->save($this->data)):    
    8282               $id = $this->Wiki->getLastInsertID(); 
    83                $this->msgFlash(__('WikiPage added', true), '/admin/wikis/edit/'.$id); 
     83               $this->msgFlash(__('WikiPage saved', true), '/admin/wikis/edit/'.$id); 
    8484    endif;  
    8585   endif; 
     
    122122        if ($this->Wiki->save($this->data['Wiki'])):  
    123123            if ( $this->data['Wiki']['end'] == 1 ):  // edition ends 
    124                      $this->msgFlash('Wiki page saved', '/admin/wikis/listing'); 
     124                     $this->msgFlash('WikiPage saved', '/admin/wikis/listing'); 
    125125            else:     
    126                      $this->msgFlash('Wiki page saved', '/admin/wikis/edit/'.$this->data['Wiki']['id']); 
     126                     $this->msgFlash('WikiPage saved', '/admin/wikis/edit/'.$this->data['Wiki']['id']); 
    127127        endif; 
    128         else: 
    129         $this->flash('Error in DB, contact staff', '/admin/wikis/listing'); 
     128       
    130129    endif;  
    131  
    132   
    133130  endif; 
    134131 } 
  • 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}  
  • trunk/app/views/elements/admin_menu.ctp

    r758 r771  
    1313                                                                  $html->link(__('Forums', true), '/admin/catforums/listing'), 
    1414                                                                  $html->link(__('Messages', true), '/admin/messages/listing') 
     15                                                                  //$html->link(__('WikiPages', true), '/admin/wikis/listing') 
    1516                                                             ), 
    1617             $html->link('Webquests', '/admin/webquests/listing'), 
  • trunk/app/views/elements/wikibar.ctp

    r767 r771  
    1  
    21<script type= "text/javascript">/*<![CDATA[*/ 
    3 // wiki_add('*','*','bold') 
    4 function wiki_add(open_tag, close_tag, tag_text) { 
     2// wiki_add('--','--','underline') 
     3function wiki_add(open_tag, close_tag, tag_text)  
     4{ 
    55  var text_element = document.getElementById('WikiContent'); 
    66 
     
    1515    while (p1 > p0 && text_element.value.substring(p1-1, p1) == ' ')  
    1616    { 
    17       p1--; 
     17      p1--;   // position 
    1818    } 
    19      
    20     if (p1 > p0)  
     19    if (p1 > p0)  // si en verdad hay texto en el textarea  
    2120    { 
    2221      str = text_element.value.substring(p0, p1); 
     
    3534    text_element.focus(); 
    3635    range = document.selection.createRange() 
    37       if (str == '')  
    38       { 
    39     range.text = open_tag + tag_text + close_tag; 
    40     range.moveStart('character', -close_tag.length - tag_text.length ); 
    41     range.moveEnd('character', -close_tag.length ); 
    42        }  
    43        else  
     36    if (str == '')  
     37    { 
     38       range.text = open_tag + tag_text + close_tag; 
     39       range.moveStart('character', -close_tag.length - tag_text.length ); 
     40       range.moveEnd('character', -close_tag.length ); 
     41    }  
     42    else  
     43    { 
     44       if (str.charAt(str.length - 1) == " ")  
    4445       { 
    45      if (str.charAt(str.length - 1) == " ")  
    46          { 
    4746      close_tag = close_tag + " "; 
    4847      str = str.substr(0, str.length - 1); 
    49     } 
    50     range.text = open_tag + str + close_tag; 
    51       } 
     48      } 
     49      range.text = open_tag + str + close_tag; 
     50    } 
    5251    range.select(); 
    5352  }  
     
    6160</script> 
    6261 
    63 <div id="toolbar"> 
    64 <a href="#toolbar"><img onclick="wiki_add('*','*','bold');" src="/img/static/button_bold.png" alt="Bold" title="Bold" /></a>  
    65 <a href="#toolbar"><img onclick="wiki_add('**','**','italics');" src="/img/static/button_italic.png" alt="Italics"  /></a>  
    66 <a href="#toolbar"><img onclick="wiki_add('--','--','underline');" src="/img/static/button_underline.png" alt="Underline" title="Underline" /></a>  
    67 <a href="#toolbar"><img onclick="wiki_add('', '\\n#########','heading 1');" src="/img/static/button_headline.png" alt="Heading 1" /></a>  
    68 <a href="#toolbar"><img onclick="wiki_add('', '\\n=========','heading 2');" src="/img/static/button_hr.png" alt="Line" /></a>  
    69 <a href="#toolbar"><img onclick="wiki_add('', '\\n---------','heading 3');" src="/img/static/button_heading3.png" alt="Heading 3" /></a>  
    70 <a href="#toolbar"><img onclick="wiki_add('{', '}','image url');" src="/img/static/button_image.png" alt="Inline image" /></a>  
    71 <a href="#toolbar"><img onclick="wiki_add('[link url]', '[/]','link text');" src="/img/static/button_link.png" alt="Inline link" /></a> 
     62<div id="toolbar" style="padding:0;margin:15px 0 0 0;"> 
     63<a href="#legend"><img onclick="wiki_add('\'\'\'','\'\'\'','bold');" src="/img/static/button_bold.png" class="wikibutton" alt="Bold" title="Bold" /></a>  
     64<a href="#legend"><img onclick="wiki_add('\'\'','\'\'','italics');" src="/img/static/button_italic.png" class="wikibutton" alt="Italics"  /></a>  
     65<a href="#legend"><img onclick="wiki_add('--','--','underline');" src="/img/static/button_underline.png" class="wikibutton" alt="Underline" title="Underline" /></a>  
     66<a href="#legend"><img onclick="wiki_add('\n==', '==\n','heading 1');" src="/img/static/button_headline.png" class="wikibutton" alt="Heading 1" title="Headline 1" /></a>  
     67<a href="#legend"><img onclick="wiki_add('', '\n----\n','');" src="/img/static/button_hr.png" class="wikibutton" alt="Line" title="Line" /></a>  
     68<a href="#legend"><img onclick="wiki_add('[', ']','http://www.ejemplo.com|Título del enlace');" src="/img/static/button_extlink.png" class="wikibutton" alt="External Link" title="External link" /></a>  
     69<a href="#legend"><img onclick="wiki_add('[[', ']]','Imagen:Ejemplo.jpg');" src="/img/static/button_image.png" class="wikibutton" alt="Inline image" title="Inline image" /></a>  
     70<a href="#legend"><img onclick="wiki_add('[', ']','Link text');" src="/img/static/button_link.png" class="wikibutton" title="Inline link" alt="Inline link" /></a> 
    7271</div> 
  • trunk/app/views/entries/admin_start.ctp

    r764 r771  
    3030 echo $html->div('main-item', $tmp, array('title'=>'Messages', 'onclick'=>"document.location.href='/admin/messages/listing'")); 
    3131 
    32  $tmp  = $html->link($html->image('wikis.png', array('title'=>'Wikis', 'alt'=>'Wikis')), '/admin/wikis/listing', null, null, false); 
    33  $tmp .= $html->link('Wikis', '/admin/wikis/listing', array('title'=>'Wikis', 'class'=>'main-item-caption')); 
    34  echo $html->div('main-item', $tmp, array('title'=>'Blog', 'onclick'=>"document.location.href='/admin/wikis/listing'")); 
     32// $tmp  = $html->link($html->image('wikis.png', array('title'=>'Wikis', 'alt'=>'Wikis')), '/admin/wikis/listing', null, null, false); 
     33// $tmp .= $html->link('Wikis', '/admin/wikis/listing', array('title'=>'Wikis', 'class'=>'main-item-caption')); 
     34// echo $html->div('main-item', $tmp, array('title'=>'Blog', 'onclick'=>"document.location.href='/admin/wikis/listing'")); 
    3535 
    3636 $tmp  = $html->link($html->image('mmultimedia.png',array('title'=>__('Shared files', true), 'alt'=>__('Shared files', true))), '/admin/shares/listing', null, null, false); 
  • trunk/app/views/wikis/admin_edit.ctp

    r770 r771  
    66?> 
    77<fieldset> 
    8   <legend><?php __('Edit Wiki'); ?></legend> 
     8  <legend id="legend"><?php __('Edit Wiki'); ?></legend> 
    99<?php   
    1010echo $form->input('Wiki.title', array('size' => 60, 'maxlength'=>80)); 
     
    1616echo $form->select('Wiki.vclassroom_id', $vclassrooms, null, null, false); 
    1717 
     18echo $html->link($html->image('admin/myimages.jpg', array('alt'=>__('My Images', true), 'title'=>__('My Images',true))), '#', array("onclick"=>"javascript:window.open('/admin/images/listing/set', 'blank', 'toolbar=no, scrollbars=yes,width=700,height=500')"), null, false);  
     19 
    1820echo $this->element('wikibar'); 
     21 
    1922echo $form->textarea('Wiki.content', array('cols'=>100,'rows' =>20, 'class'=>'wikitext')); 
    20 echo $html->div('optional',$form->label('Wiki.status', 'Status:').$form->checkbox('Wiki.status', array('value'=>1))); 
     23echo $form->label('Wiki.status', __('Status', true)); 
     24echo $form->checkbox('Wiki.status', array('value'=>1)); 
    2125 
    22 echo $html->div('optional',$form->label('Wiki.end', 'End:').$form->checkbox('Wiki.end', array('value'=>1))); 
     26echo $form->label('Wiki.end', __('End', true)); 
     27echo $form->checkbox('Wiki.end', array('value'=>1)); 
    2328 
    24 echo $html->div('submit', $form->end(__('Save', true))); 
     29echo $form->end(__('Save', true)); 
    2530?> 
    2631<script type="text/javascript"> 
     
    3439</fieldset> 
    3540 
    36 <?php echo $html->link('View revisions', '/admin/wikis/history/'.$this->data['Wiki']['id']); ?> 
     41<?php echo $html->link(__('View history', true), '/admin/wikis/history/'.$this->data['Wiki']['id']); ?> 
  • trunk/app/webroot/css/cpanel/cpanel.css

    r697 r771  
    10331033 
    10341034.petit{font-style:oblique;font-size:7pt;}  
     1035 
     1036.wikibutton{padding:0;margin:0;}