/** * This method is called before each test method. * * @param \Codeception\Event\TestEvent $event */ public function _before($event) { // delete this signed up user User::deleteAll(['email' => '*****@*****.**', 'username' => 'demo']); // delete roles Role::deleteAll(); }
public function actionDelete($id) { if (empty($user = User::findOne($id))) { throw new \yii\web\NotFoundHttpException(); } $count = User::deleteAll(['id' => $id]); Invitation::deleteAll(['email' => $user->email, 'status' => Invitation::STATUS_SIGNUP]); if ($count >= 1) { $this->goBack(); } }
public function actionDelete($id = 'none', $ids = 'none') { if ($id != 'none') { if (User::find()->where(['id' => $id])->one()->delete()) { Yii::$app->getSession()->addFlash('success', '<b>Пользователь успешно удален</b>'); return $this->actionIndex(); } else { Yii::$app->getSession()->addFlash('success', '<b>Не удалось удалить пользователя</b>'); return $this->actionIndex(); } } if ($ids != 'none') { $ids = explode(',', $ids); if (User::deleteAll(['id' => $ids])) { Yii::$app->getSession()->addFlash('success', '<b>Пользователи успешно удалены</b>'); return $this->actionIndex(); } else { Yii::$app->getSession()->addFlash('success', '<b>Не удалось удалить пользователя</b>'); return $this->actionIndex(); } } }
public function actionUser() { // create or change global admin user User::deleteAll(['username' => 'admin']); echo "\n Введите новый пароль администратора или пустую строку для выхода "; $passw = trim(fgets(STDIN)); if (!$passw) { echo "\n Действие прервано \n "; exit(1); } $model = new User(); $model->username = '******'; $model->email = Yii::$app->params['adminEmail']; $model->password = $passw; $model->role = User::ROLE_ADMIN; if ($model->save(false)) { echo "\n Пароль администратора изменен \n "; exit(0); } else { echo "\n Ошибка изменения пароля \n "; exit(1); } }
public function actionDeleteUser() { $selection = (array) Yii::$app->request->post('selection'); foreach ($selection as $id) { if ($id != Yii::$app->params['adminId']) { User::deleteAll(['id' => $id]); Post::deleteAll(['user_id' => $id]); PostNotification::deleteAll(['action_id' => $id]); PostNotification::deleteAll(['receiver_id' => $id]); Comment::deleteAll(['user_id' => $id]); Like::deleteAll(['user_id' => $id]); Message::deleteAll(['sender_id' => $id]); Message::deleteAll(['receiver_id' => $id]); Relationship::deleteAll(['user_id_1' => $id]); Relationship::deleteAll(['user_id_2' => $id]); RelationshipNotification::deleteAll(['action_id' => $id]); RelationshipNotification::deleteAll(['receive_id' => $id]); Schedule::deleteAll(['own_id' => $id]); ScheduleNotification::deleteAll(['action_id' => $id]); ScheduleNotification::deleteAll(['receiver_id' => $id]); } } return $this->render('user-manage'); }
/** * This method is called after each cest class test method, even if test failed. * @param \Codeception\Event\TestEvent $event */ public function _after($event) { User::deleteAll(['email' => '*****@*****.**', 'username' => 'tester']); }
/** * @param AcceptanceTester $I */ public function testSignup(AcceptanceTester $I) { Option::up('allow_signup', '1'); $I->wantTo('ensure that signup works'); $signupPage = SignupPage::openBy($I); $I->see('Register a new membership', 'p'); $I->amGoingTo('submit signup form with no data'); $signupPage->submit([]); $I->expectTo('see validations error'); $I->see('Username cannot be blank.', '.help-block'); $I->see('Email cannot be blank.', '.help-block'); $I->see('Password cannot be blank.', '.help-block'); $I->amGoingTo('submit signup form with no correct email and password'); $signupPage->submit(['username' => 'newuser', 'email' => 'newuser.email', 'password' => 'pass']); $I->expectTo('see that email and password are not correct.'); $I->dontSee('Username cannot be blank.', '.help-block'); $I->see('Email is not a valid email address.', '.help-block'); $I->see('Password should contain at least 6 characters.', '.help-block'); $I->amGoingTo('submit signup form with correct data'); $signupPage->submit(['username' => 'newuser', 'email' => '*****@*****.**', 'password' => 'password']); $I->expect('new user saved.'); $I->dontSee('Username cannot be blank.', '.help-block'); $I->dontSee('Email is not a valid email address.', '.help-block'); $I->dontSee('Password should contain at least 6 characters.', '.help-block'); User::deleteAll(['username' => 'newuser']); Option::up('allow_signup', '0'); }
/** * @param AcceptanceTester $I */ public function testCreate(AcceptanceTester $I) { $I->wantTo('ensure that create user works'); $createPage = CreatePage::openBy($I); $I->see('Add New User', 'h1'); $I->cantSeeElement('#user-role option[value="superadmin"]'); $I->amGoingTo('submit user form with no data'); $createPage->submit([]); $I->expectTo('see validation errors'); $I->see('Username cannot be blank.', '.help-block'); $I->see('Email cannot be blank.', '.help-block'); $I->see('Password cannot be blank.', '.help-block'); $I->amGoingTo('submit user form with no correct email and password'); $createPage->submit(['username' => 'newuser', 'password' => 'newu', 'email' => 'newuser@email']); $I->expectTo('see that given email is not correct'); $I->dontSee('Username cannot be blank.', '.help-block'); $I->see('Password should contain at least 6 characters.', '.help-block'); $I->see('Email is not a valid email address.', '.help-block'); $I->amGoingTo('submit user form with correct data'); $createPage->submit(['username' => 'newuser', 'password' => 'newuser', 'email' => '*****@*****.**']); $I->expect('new user saved'); $I->see('View User: newuser', 'h1'); User::deleteAll(['username' => 'newuser']); }
public function actionDeleteajx() { $post = Yii::$app->request->post(); $post['id']; User::deleteAll(['id' => $post['id']]); }
public function actionDeleteemployee() { $data = json_decode(file_get_contents("php://input")); $query = User::deleteAll('sn=' . $data->sn); if ($query) { $response["status"] = 'success'; $response["message"] = 'Owner deleted successfully.'; //$response["data"]=(int)$model->id; http_response_code(200); header('Content-type: application/json'); echo json_encode($response, JSON_NUMERIC_CHECK); } }