Conditions | 5 |
Paths | 3 |
Total Lines | 23 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
1 | <?php |
||
7 | public function up() |
||
8 | { |
||
9 | if(isset($_SERVER['TRAVIS'])||(isset($_SERVER['PWD'])&&strpos($_SERVER['PWD'], '/tests/'))) |
||
10 | return null; |
||
11 | |||
12 | $userName = 'webmaster'; |
||
13 | |||
14 | $tableName = \dektrium\user\models\User::tableName(); |
||
15 | $query = 'SELECT COUNT(*) FROM '.$tableName.' WHERE `username`=:username'; |
||
16 | $count = \Yii::$app->db->createCommand($query, [':username'=>$userName])->queryScalar(); |
||
17 | if($count>0) |
||
18 | return null; |
||
19 | |||
20 | $user = \Yii::createObject([ |
||
21 | 'class' => \dektrium\user\models\User::className(), |
||
22 | 'scenario' => 'create', |
||
23 | 'username' => $userName, |
||
24 | 'password' => $userName, |
||
25 | 'email' => $userName.'@yii2enterprise.dev', |
||
26 | ]); |
||
27 | |||
28 | return $user->create(); |
||
29 | } |
||
30 | |||
49 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.