Hi,
I have a database table and created a model for it using gii:
/**
* This is the model class for table "Subscriptions".
*
* The followings are the available columns in table 'Subscriptions':
* @property integer $ID
* @property integer $ModuleID
* @property integer $AfdelingID
* @property string $SignUpDate
* @property string $StartDate
* @property string $CancelDate
* @property string $EndDate
* @property integer $State
*
* The followings are the available model relations:
* @property Afdelingen $afdeling
* @property Detectoren $module
*/
class TestSubscription extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'Subscriptions';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('AfdelingID, SignUpDate, State', 'required'),
array('ModuleID, AfdelingID, State', 'numerical', 'integerOnly'=>true),
array('StartDate, CancelDate, EndDate', 'safe'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('ID, ModuleID, AfdelingID, SignUpDate, StartDate, CancelDate, EndDate, State', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'afdeling' => array(self::BELONGS_TO, 'Afdelingen', 'AfdelingID'),
'module' => array(self::BELONGS_TO, 'Detectoren', 'ModuleID'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'ID' => 'ID',
'ModuleID' => 'Module',
'AfdelingID' => 'Afdeling',
'SignUpDate' => 'Sign Up Date',
'StartDate' => 'Start Date',
'CancelDate' => 'Cancel Date',
'EndDate' => 'End Date',
'State' => 'State',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('ID',$this->ID);
$criteria->compare('ModuleID',$this->ModuleID);
$criteria->compare('AfdelingID',$this->AfdelingID);
$criteria->compare('SignUpDate',$this->SignUpDate,true);
$criteria->compare('StartDate',$this->StartDate,true);
$criteria->compare('CancelDate',$this->CancelDate,true);
$criteria->compare('EndDate',$this->EndDate,true);
$criteria->compare('State',$this->State);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return TestSubscription the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
I build a super basic unit test:
class SubscriptionTest extends CTestCase
{
function testCreate()
{
echo "This is a test\n";
$subscription= new TestSubscription();
echo "Done\n";
$this->assertTrue( true );
}
}
but when i run it in cmd using "PHPUnit ./unit/SubscriptionTest.php" i get the following result:
PHPUnit 3.7.21 by Sebastian Bergmann.
Configuration read from C:\xampp\htdocs\cabletracks.com\protected\tests\phpunit.xml
This is a test
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36 bytes) in C:\xampp\htdocs\cabletracks.com\framework\caching\CMemCache.php on line 116
I did not change anything in the model, it is straight from gii.
When i use any other model i created this way i have no problem at all, only with this model.
Anyone got an idea what this could be?
thanks!