<?php
namespace app\models;
use Yii;
use yii\base\Model;
class EntryForm extends Model
{
public $name;
public $email;
public function rules()
{
return [
[['name', 'email'], 'required'],
['email', 'email'],
];
}
}
<?php
namespace tests\models;
use app\models\EntryForm;
class EntryFormTest extends \Codeception\Test\Unit
{
public function testValidInput()
{
$model = new EntryForm();
$model->name = 'Harry Qin';
$model->email = '15848778@qq.com';
expect_that($model->validate());
return $model;
}
public function testInvalidInput()
{
$model = new EntryForm();
$model->name = 'Harry Qin';
$model->email = 'xxyy';
expect_not($model->validate());
$model = new EntryForm();
$model->name = '';
$model->email = '15848778@qq.com';
expect_not($model->validate());
}
/**
* 下面一行表示这里输入的参数值来自testValidInput的输出
* @depends testValidInput
*/
public function testModelProperty($model)
{
expect($model->name)->equals('Harry Qin');
}
}
composer exec codecept run unit
。。。。。。 ✔ EntryFormTest: Valid input (0.00s) ✔ EntryFormTest: Invalid input (0.00s) ✔ EntryFormTest: Model property (0.00s)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有