PHPonTraxTest
[ class tree: PHPonTraxTest ] [ index: PHPonTraxTest ] [ all elements ]

Source for file active_record.php

Documentation is available at active_record.php

  1. <?php
  2. /**
  3.  *  File for mock ActiveRecord class
  4.  *
  5.  *  This file has the same name as the file holding the
  6.  *  {@link ActiveRecord} class.  To use the mock ActiveRecord, put
  7.  *  this file in the PHP include path ahead of the Trax library, so
  8.  *  that any class which requires active_record.php will load this
  9.  *  version.
  10.  *
  11.  * (PHP 5)
  12.  *
  13.  * @package PHPonTraxTest
  14.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  15.  * @copyright (c) Walter O. Haas 2006
  16.  * @version $Id: active_record.php 199 2006-05-05 01:52:43Z haas $
  17.  * @author Walt Haas <haas@xmission.com>
  18.  */
  19.  
  20. /**
  21.  * Mock ActiveRecord class for testing
  22.  */
  23. class ActiveRecord {
  24.  
  25.     /**
  26.      *  Expected query
  27.      *  @var string 
  28.      */
  29.     private $expected_query = null;
  30.  
  31.     /**
  32.      *  Expected result
  33.      *  @var string 
  34.      */
  35.     private $expected_result = null;
  36.  
  37.     /**
  38.      *  Set expected query and return
  39.      *
  40.      *  This is a test routine that does not exist in the real
  41.      *  ActiveRecord.
  42.      *  @param string $expected Expected query
  43.      *  @param string $result Result to be returned when expected
  44.      *   query is received.
  45.      */
  46.     public function expect_query($expected$result{
  47.         $this->expected_query = $expected;
  48.         $this->expected_result = $result;
  49.     }
  50.  
  51.     /**
  52.      *  Get contents of one column of record selected by id and table
  53.      *
  54.      *  When called, {@link $id} identifies one record in the table
  55.      *  identified by {@link $table}.  Fetch from the database the
  56.      *  contents of column $column of this record.
  57.      *  @param string Name of column to retrieve
  58.      *  @return string Column contents
  59.      *  @expected_query
  60.      */
  61.     function send($column{
  62.         if ($column != $this->expected_query{
  63.             PHPUnit2_Framework_Assert::fail('ActiveRecord::send() called with'
  64.                  .' "'.$column.'", expected "'.$this->expected_query.'"');
  65.         }
  66.         return $this->expected_result;
  67.     }
  68.  
  69. }
  70.  
  71. // -- set Emacs parameters --
  72. // Local variables:
  73. // tab-width: 4
  74. // c-basic-offset: 4
  75. // c-hanging-comment-ender-p: nil
  76. // indent-tabs-mode: nil
  77. // End:
  78. ?>

Documentation generated on Mon, 21 May 2007 22:27:58 -0600 by phpDocumentor 1.3.2