Yii

yii2的单元测试

丶灬走出姿态 提交于 2020-02-11 02:58:52
1.什么是单元测试 单元测试其实就是一种代码级别的测试,主要用于判断自己写的代码是否是自己想要的。其实一般情况下单元测试用于跨部门,高耦合,多人参与的项目。 2.如何进行单元测试 很简单,就是使用。比如如果你想测试一个方法,直接运行方法,打印结果进行判断就可以了。只不过这样并不能完全表示它的准确性。也不够逼格,所以就运用而生了标准和工具。引申的说一下,其实世间万物都是个性化的,但是个性化并不能让别人准确的理解这个事物(或者理解需要花费时间和精力),所以就定了各种标准。个人感觉标准就是为给平凡而准备的等级,超凡的事物,从来不屑于遵循标准,因为它本身做的就比标准多很多。 3.yii2的单元测试 基于codecopt在做开发测试,这是一个测试工具,他可以做单元测试,功能测试,验收测试,api接口测试等,这里主要介绍下单元测试,其他没有几样没有做,只是进行猜测 详细介绍可以参考官网推荐https://codeception.com/for/yii 下面说说我自己的简单单元测试的过程,首先你需要初始化codecopt的配置。这个使用命令行进行自动生成的。 我用的wampserver,没有win下开发的,没有添加环境变量,也就是不能直接在命令行执行php,所以直接在命令行外执行的。 1)首先查找codecept文件的位置,由于我的yii2是其他人弄了5年的基础版本,搞了什么不知道

Yii应用的目录结构和入口脚本

别来无恙 提交于 2020-02-11 01:16:59
以下是一个通过高级模版安装后典型的Yii应用的目录结构: . ├── backend ├── common ├── console ├── environments ├── frontend ├── nbproject ├── tests ├── vendor ├── composer.json ├── composer.lock ├── init ├── init.bat ├── LICENSE.md ├── README.md ├── requirements.php ├── yii └── yii.bat 对于高级应用而言,相当于有 backend frontend console 三个独立的Yii应用。 由于 console 类的应用比较特殊,我们稍后再讲。这里讲典型的Web应用的目录结构。 公共目录 这里的公共目录可不止 common 目录,但这个目录从字面上来看, 是所有公共目录里最“公共”的。 common 目录下的东西, 对于本高级应用的任一独立的应用而言,都是可见、可用的。一般情况下, common 具有以下结构: . ├── config ├── mail └── models 其中: config 就是通用的配置,这些配置将作用于前后台和命令行。 mail 就是应用的前后台和命令行的与邮件相关的布局文件等。 models 就是前后台和命令行都可能用到的数据模型

Yii Application works fine on localhost, but throws “not found” error on GoDaddy.com

杀马特。学长 韩版系。学妹 提交于 2020-02-08 04:56:02
问题 My Yii site works perfectly fine, when run on my laptop (localhost). But, when copied to GoDaddy.com and run from there, I'm getting following error message: Not Found The requested URL /website/Search_Best_Boat_Deals was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache Server at website.com Port 80 My main.php configuration file has the following configuration for URL management 'urlManager'=

Yii Application works fine on localhost, but throws “not found” error on GoDaddy.com

元气小坏坏 提交于 2020-02-08 04:55:35
问题 My Yii site works perfectly fine, when run on my laptop (localhost). But, when copied to GoDaddy.com and run from there, I'm getting following error message: Not Found The requested URL /website/Search_Best_Boat_Deals was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache Server at website.com Port 80 My main.php configuration file has the following configuration for URL management 'urlManager'=

YII file upload not adding to database using form

梦想与她 提交于 2020-02-05 10:16:50
问题 Im attempting to add a file upload field to a form in YII, while its succesfully submitting and uploading the file to the correct folder, its not adding anything to the database. Im only learning this platform so any guidance would be great. Here is my view... <div class="row"> <div class="span4"><?php echo $form->labelEx($model,'slider_image'); ?></div> <div class="span5"><?php echo $form->fileField($model,'slider_image'); ?></div> <div class="span3"><?php echo $form->error($model,'slider

Yii2 - subdomain routing

不打扰是莪最后的温柔 提交于 2020-01-30 05:17:06
问题 I want to use subdomain as id, and I need dynamic router to do this. In urlManager , I added this line: "http://<user:\w+>.local.dev/<controller:\w+>/<action>" => '<controller>/<action>', When I try any action, for example: function actionMyAccount($user){ echo $user;... } I am not getting anything - the var isn't printed, and script stops working (screen is white). When I remove $user, the page is loading without any problems How can I achieve subdomain router? 回答1: I think your router

Yii2框架连接postgreSql

扶醉桌前 提交于 2020-01-29 22:04:14
1、配置连接postgresql的连接信息: $dev = [ 'class' => 'yii\db\Connection', 'dsn' => 'pgsql:host=122.112.182.211;port=8000;dbname=sdk_info', 'username' => 'dbadmin', 'password' => 'Styl2018@', 'charset' => 'utf8', // 'emulatePrepare' => true ]; return $dev; =========================== 2、Yii2目录下,models目录下新建model: class TestSdkVsent extends Base { public static function getDb() { return \Yii::$app->dbDws; } public static function tableName() { return 'sdk_info.tb_sdk_vsent'; // TODO: Change the autogenerated stub } public static function test() { $find = static::find(); $result = $find->select('rtt')->limit

Yii2框架连接postgreSql

情到浓时终转凉″ 提交于 2020-01-29 22:04:07
1、配置连接postgresql的连接信息: $dev = [ 'class' => 'yii\db\Connection', 'dsn' => 'pgsql:host=122.112.182.211;port=8000;dbname=sdk_info', 'username' => 'dbadmin', 'password' => 'Styl2018@', 'charset' => 'utf8', // 'emulatePrepare' => true ]; return $dev; 2、Yii2目录下,models目录下新建model: class TestSdkVsent extends Base { public static function getDb() { return \Yii::$app->dbDws; } public static function tableName() { return 'sdk_info.tb_sdk_vsent'; // TODO: Change the autogenerated stub } public static function test() { $find = static::find(); $result = $find->select('rtt')->limit(1) ->asArray()->one();

How can I customize the labels for the pager in Yii?

五迷三道 提交于 2020-01-29 07:13:02
问题 I am new to Yii. I want to implement custom pagination. I want to change the appearance of the pager. How do I change the labels of the pager's links? I want the links to appear like so: << < 1 2 3 4 > >> instead of their default appearance, which is like this: [first] [previous] 1 2 3 4 [next] [last] I am using CListView to display the data, which I have set up like this: $this->widget('zii.widgets.CListView', array( 'dataProvider' => $categoryProjects, 'itemView' => '_itemDetailsView',

How can I customize the labels for the pager in Yii?

爷,独闯天下 提交于 2020-01-29 07:12:05
问题 I am new to Yii. I want to implement custom pagination. I want to change the appearance of the pager. How do I change the labels of the pager's links? I want the links to appear like so: << < 1 2 3 4 > >> instead of their default appearance, which is like this: [first] [previous] 1 2 3 4 [next] [last] I am using CListView to display the data, which I have set up like this: $this->widget('zii.widgets.CListView', array( 'dataProvider' => $categoryProjects, 'itemView' => '_itemDetailsView',