diff --git a/assets/AppAsset.php b/src/assets/AppAsset.php
similarity index 53%
rename from assets/AppAsset.php
rename to src/assets/AppAsset.php
index e7038ab27..ab374bd27 100644
--- a/assets/AppAsset.php
+++ b/src/assets/AppAsset.php
@@ -10,25 +10,29 @@
namespace app\assets;
+use yii\bootstrap5\BootstrapAsset;
use yii\web\AssetBundle;
+use yii\web\View;
+use yii\web\YiiAsset;
/**
- * Main application asset bundle.
- *
- * @author Qiang Xue
- * @since 2.0
+ * Registers application CSS and JS assets with Bootstrap 5 and jQuery dependencies.
*/
-class AppAsset extends AssetBundle
+final class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
+ public $depends = [
+ BootstrapAsset::class,
+ YiiAsset::class,
+ ];
public $js = [
+ 'js/color-mode.js',
];
- public $depends = [
- 'yii\web\YiiAsset',
- 'yii\bootstrap5\BootstrapAsset'
+ public $jsOptions = [
+ 'position' => View::POS_HEAD,
];
}
diff --git a/commands/HelloController.php b/src/commands/HelloController.php
similarity index 64%
rename from commands/HelloController.php
rename to src/commands/HelloController.php
index 07a63b150..8641c9151 100644
--- a/commands/HelloController.php
+++ b/src/commands/HelloController.php
@@ -14,25 +14,22 @@
use yii\console\ExitCode;
/**
- * This command echoes the first argument that you have entered.
+ * Echoes the first argument that you have entered.
*
- * This command is provided as an example for you to learn how to create console commands.
- *
- * @author Qiang Xue
- * @since 2.0
+ * Provided as an example for learning how to create console commands.
*/
final class HelloController extends Controller
{
/**
* This command echoes what you have entered as the message.
*
- * @param string $message the message to be echoed.
+ * @param string $message The message to be echoed.
*
* @return int Exit code
*/
public function actionIndex(string $message = 'hello world'): int
{
- echo $message . "\n";
+ echo "{$message}\n";
return ExitCode::OK;
}
diff --git a/src/controllers/SiteController.php b/src/controllers/SiteController.php
new file mode 100644
index 000000000..963b6edbd
--- /dev/null
+++ b/src/controllers/SiteController.php
@@ -0,0 +1,90 @@
+render('about');
+ }
+
+ /**
+ * Displays contact page.
+ */
+ public function actionContact(): Response|string
+ {
+ $model = new ContactForm();
+
+ /** @var array $post */
+ $post = $this->request->post();
+ $params = Yii::$app->params;
+
+ $contact = $model->load($post) && $model->contact(
+ $this->mailer,
+ $params['adminEmail'],
+ $params['senderEmail'],
+ $params['senderName'],
+ );
+
+ if ($contact) {
+ Yii::$app->session->setFlash(
+ 'success',
+ 'Thank you for contacting us. We will respond to you as soon as possible.',
+ );
+
+ return $this->refresh();
+ }
+
+ return $this->render('contact', ['model' => $model]);
+ }
+
+ /**
+ * Displays homepage.
+ */
+ public function actionIndex(): string
+ {
+ return $this->render('index');
+ }
+
+ public function actions(): array
+ {
+ return [
+ 'captcha' => [
+ 'class' => CaptchaAction::class,
+ 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
+ 'transparent' => true,
+ ],
+ 'error' => [
+ 'class' => ErrorAction::class,
+ ],
+ ];
+ }
+}
diff --git a/src/controllers/UserController.php b/src/controllers/UserController.php
new file mode 100644
index 000000000..3b7307abc
--- /dev/null
+++ b/src/controllers/UserController.php
@@ -0,0 +1,307 @@
+ $queryParams */
+ $queryParams = Yii::$app->request->queryParams;
+ $dataProvider = $searchModel->search($queryParams);
+
+ return $this->render(
+ 'index',
+ [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ],
+ );
+ }
+
+ /**
+ * Login action.
+ */
+ public function actionLogin(): Response|string
+ {
+ $model = new LoginForm();
+
+ /** @var array $post */
+ $post = $this->request->post();
+
+ if ($model->load($post) && $model->login()) {
+ return $this->goBack();
+ }
+
+ $model->password = '';
+
+ return $this->render('login', ['model' => $model]);
+ }
+
+ /**
+ * Logout action.
+ */
+ public function actionLogout(): Response
+ {
+ Yii::$app->user->logout();
+
+ return $this->goHome();
+ }
+
+ /**
+ * Requests password reset.
+ */
+ public function actionRequestPasswordReset(): Response|string
+ {
+ $model = new PasswordResetRequestForm();
+
+ /** @var array $post */
+ $post = $this->request->post();
+ $params = Yii::$app->params;
+
+ if ($model->load($post) && $model->validate()) {
+ $sent = $model->sendEmail(
+ $this->mailer,
+ $params['supportEmail'],
+ Yii::$app->name,
+ );
+
+ if ($sent) {
+ Yii::$app->session->setFlash('success', 'Check your email for further instructions.');
+
+ return $this->goHome();
+ }
+
+ Yii::$app->session->setFlash(
+ 'error',
+ 'Sorry, we are unable to reset password for the provided email address.',
+ );
+ }
+
+ return $this->render('requestPasswordResetToken', ['model' => $model]);
+ }
+
+ /**
+ * Resends verification email.
+ */
+ public function actionResendVerificationEmail(): Response|string
+ {
+ $model = new ResendVerificationEmailForm();
+
+ /** @var array $post */
+ $post = $this->request->post();
+ $params = Yii::$app->params;
+
+ if ($model->load($post) && $model->validate()) {
+ $sent = $model->sendEmail(
+ $this->mailer,
+ $params['supportEmail'],
+ Yii::$app->name,
+ );
+
+ if ($sent) {
+ Yii::$app->session->setFlash(
+ 'success',
+ 'Check your email for further instructions.',
+ );
+
+ return $this->goHome();
+ }
+
+ Yii::$app->session->setFlash(
+ 'error',
+ 'Sorry, we are unable to resend verification email for the provided email address.',
+ );
+ }
+
+ return $this->render('resendVerificationEmail', ['model' => $model]);
+ }
+
+ /**
+ * Resets password.
+ *
+ * @throws BadRequestHttpException
+ */
+ public function actionResetPassword(string $token): Response|string
+ {
+ try {
+ $model = new ResetPasswordForm($token);
+ } catch (InvalidArgumentException $e) {
+ throw new BadRequestHttpException($e->getMessage());
+ }
+
+ /** @var array $post */
+ $post = $this->request->post();
+
+ if ($model->load($post) && $model->validate() && $model->resetPassword()) {
+ Yii::$app->session->setFlash(
+ 'success',
+ 'New password saved.',
+ );
+
+ return $this->goHome();
+ }
+
+ return $this->render('resetPassword', ['model' => $model]);
+ }
+
+ /**
+ * Signs user up.
+ */
+ public function actionSignup(): Response|string
+ {
+ $model = new SignupForm();
+
+ /** @var array $post */
+ $post = $this->request->post();
+ $params = Yii::$app->params;
+
+ $signed = $model->load($post) && $model->signup(
+ $this->mailer,
+ $params['supportEmail'],
+ Yii::$app->name,
+ ) === true;
+
+ if ($signed) {
+ Yii::$app->session->setFlash(
+ 'success',
+ 'Thank you for registration. Please check your inbox for verification email.',
+ );
+
+ return $this->goHome();
+ }
+
+ return $this->render('signup', ['model' => $model]);
+ }
+
+ /**
+ * Verifies email address.
+ *
+ * @throws BadRequestHttpException
+ */
+ public function actionVerifyEmail(string $token): Response
+ {
+ try {
+ $model = new VerifyEmailForm($token);
+ } catch (InvalidArgumentException $e) {
+ throw new BadRequestHttpException($e->getMessage());
+ }
+
+ if ($model->verifyEmail() !== null) {
+ Yii::$app->session->setFlash(
+ 'success',
+ 'Your email has been confirmed!',
+ );
+
+ return $this->goHome();
+ }
+
+ Yii::$app->session->setFlash(
+ 'error',
+ 'Sorry, we are unable to verify your account with provided token.',
+ );
+
+ return $this->goHome();
+ }
+
+ public function behaviors(): array
+ {
+ return [
+ 'access' => [
+ 'class' => AccessControl::class,
+ 'only' => [
+ 'index',
+ 'login',
+ 'logout',
+ 'request-password-reset',
+ 'resend-verification-email',
+ 'reset-password',
+ 'signup',
+ 'verify-email',
+ ],
+ 'rules' => [
+ [
+ 'actions' => [
+ 'login',
+ 'request-password-reset',
+ 'resend-verification-email',
+ 'reset-password',
+ 'signup',
+ 'verify-email',
+ ],
+ 'allow' => true,
+ 'roles' => [
+ '?',
+ ],
+ ],
+ [
+ 'actions' => [
+ 'index',
+ ],
+ 'allow' => true,
+ 'roles' => [
+ 'admin',
+ ],
+ ],
+ [
+ 'actions' => [
+ 'logout',
+ ],
+ 'allow' => true,
+ 'roles' => [
+ '@',
+ ],
+ ],
+ ],
+ ],
+ 'verbs' => [
+ 'class' => VerbFilter::class,
+ 'actions' => [
+ 'index' => [
+ 'get',
+ ],
+ 'logout' => [
+ 'post',
+ ],
+ ],
+ ],
+ ];
+ }
+}
diff --git a/src/migrations/M260330000000CreateUserTable.php b/src/migrations/M260330000000CreateUserTable.php
new file mode 100644
index 000000000..95edfeec2
--- /dev/null
+++ b/src/migrations/M260330000000CreateUserTable.php
@@ -0,0 +1,37 @@
+dropTable('{{%user}}');
+ }
+
+ public function safeUp(): void
+ {
+ $this->createTable(
+ '{{%user}}',
+ [
+ 'id' => $this->primaryKey(),
+ 'username' => $this->string()->notNull()->unique(),
+ 'auth_key' => $this->string(32)->notNull(),
+ 'password_hash' => $this->string()->notNull(),
+ 'password_reset_token' => $this->string()->unique(),
+ 'email' => $this->string()->notNull()->unique(),
+ 'status' => $this->smallInteger()->notNull()->defaultValue(9),
+ 'created_at' => $this->integer()->notNull(),
+ 'updated_at' => $this->integer()->notNull(),
+ 'verification_token' => $this->string()->unique()->defaultValue(null),
+ ],
+ );
+ }
+}
diff --git a/src/migrations/M260403000000CreateAdminUser.php b/src/migrations/M260403000000CreateAdminUser.php
new file mode 100644
index 000000000..b7836b9f6
--- /dev/null
+++ b/src/migrations/M260403000000CreateAdminUser.php
@@ -0,0 +1,43 @@
+delete('{{%user}}', ['username' => \Yii::$app->params['admin.username']]);
+
+ return true;
+ }
+
+ public function safeUp(): bool
+ {
+ $time = time();
+
+ $this->insert(
+ '{{%user}}',
+ [
+ 'username' => \Yii::$app->params['admin.username'],
+ 'auth_key' => \Yii::$app->security->generateRandomString(),
+ 'password_hash' => \Yii::$app->security->generatePasswordHash(
+ \Yii::$app->params['admin.password'],
+ ),
+ 'email' => \Yii::$app->params['admin.email'],
+ 'status' => User::STATUS_ACTIVE,
+ 'created_at' => $time,
+ 'updated_at' => $time,
+ ],
+ );
+
+ return true;
+ }
+}
diff --git a/src/models/ContactForm.php b/src/models/ContactForm.php
new file mode 100644
index 000000000..ccac8d063
--- /dev/null
+++ b/src/models/ContactForm.php
@@ -0,0 +1,82 @@
+ 'Verification Code',
+ ];
+ }
+
+ /**
+ * Sends an email to the specified email address using the information collected by this model.
+ */
+ public function contact(MailerInterface $mailer, string $email, string $senderEmail, string $senderName): bool
+ {
+ if ($this->validate()) {
+ return $mailer->compose()
+ ->setTo($email)
+ ->setFrom([$senderEmail => $senderName])
+ ->setReplyTo([$this->email => $this->name])
+ ->setSubject($this->subject)
+ ->setTextBody($this->body)
+ ->send();
+ }
+
+ return false;
+ }
+
+ public function rules(): array
+ {
+ return [
+ [
+ [
+ 'name',
+ 'email',
+ 'phone',
+ 'subject',
+ 'body',
+ ],
+ 'required',
+ ],
+ [
+ 'email',
+ 'email',
+ ],
+ [
+ 'phone',
+ 'match',
+ 'pattern' => '/^\(\d{3}\) \d{3}-\d{4}$/',
+ 'message' => 'Phone number must match (999) 999-9999 format.',
+ ],
+ [
+ 'verifyCode',
+ 'captcha',
+ ],
+ ];
+ }
+}
diff --git a/src/models/LoginForm.php b/src/models/LoginForm.php
new file mode 100644
index 000000000..4c0f4ff13
--- /dev/null
+++ b/src/models/LoginForm.php
@@ -0,0 +1,95 @@
+user === null) {
+ $this->user = User::findByUsername($this->username);
+ }
+
+ return $this->user;
+ }
+
+ /**
+ * Logs in a user using the provided username and password.
+ */
+ public function login(): bool
+ {
+ if (!$this->validate()) {
+ return false;
+ }
+
+ $user = $this->getUser();
+
+ if ($user === null) {
+ return false;
+ }
+
+ return Yii::$app->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0);
+ }
+
+ public function rules(): array
+ {
+ return [
+ [
+ [
+ 'username',
+ 'password',
+ ],
+ 'required',
+ ],
+ [
+ 'rememberMe',
+ 'boolean',
+ ],
+ [
+ 'password',
+ 'validatePassword',
+ ],
+ ];
+ }
+
+ /**
+ * Validates the password.
+ *
+ * This method serves as the inline validation for password.
+ */
+ public function validatePassword(string $attribute, mixed $params): void
+ {
+ if (!$this->hasErrors()) {
+ $user = $this->getUser();
+
+ if ($user === null || !$user->validatePassword($this->password)) {
+ $this->addError($attribute, 'Incorrect username or password.');
+ }
+ }
+ }
+}
diff --git a/src/models/PasswordResetRequestForm.php b/src/models/PasswordResetRequestForm.php
new file mode 100644
index 000000000..34f967939
--- /dev/null
+++ b/src/models/PasswordResetRequestForm.php
@@ -0,0 +1,79 @@
+ User::class,
+ 'filter' => ['status' => User::STATUS_ACTIVE],
+ 'message' => 'There is no user with this email address.',
+ ],
+ ];
+ }
+
+ /**
+ * Sends an email with a link, for resetting the password.
+ */
+ public function sendEmail(MailerInterface $mailer, string $supportEmail, string $appName): bool
+ {
+ $user = User::findOne(
+ [
+ 'status' => User::STATUS_ACTIVE,
+ 'email' => $this->email,
+ ],
+ );
+
+ if ($user === null) {
+ return false;
+ }
+
+ if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
+ $user->generatePasswordResetToken();
+
+ if (!$user->save()) {
+ return false;
+ }
+ }
+
+ return $mailer
+ ->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])
+ ->setFrom([$supportEmail => "{$appName} robot"])
+ ->setTo($this->email)
+ ->setSubject("Password reset for {$appName}")
+ ->send();
+ }
+}
diff --git a/src/models/ResendVerificationEmailForm.php b/src/models/ResendVerificationEmailForm.php
new file mode 100644
index 000000000..99744ad39
--- /dev/null
+++ b/src/models/ResendVerificationEmailForm.php
@@ -0,0 +1,108 @@
+
+ * @since 0.1
+ */
+final class ResendVerificationEmailForm extends Model
+{
+ public string $email = '';
+
+ public function rules(): array
+ {
+ return [
+ [
+ 'email',
+ 'trim',
+ ],
+ [
+ 'email',
+ 'required',
+ ],
+ [
+ 'email',
+ 'email',
+ ],
+ [
+ 'email',
+ 'exist',
+ 'targetClass' => User::class,
+ 'filter' => ['status' => User::STATUS_INACTIVE],
+ 'message' => 'There is no user with this email address.',
+ ],
+ ];
+ }
+
+ /**
+ * Sends confirmation email to user.
+ */
+ public function sendEmail(MailerInterface $mailer, string $supportEmail, string $appName): bool
+ {
+ $user = User::findOne(
+ [
+ 'email' => $this->email,
+ 'status' => User::STATUS_INACTIVE,
+ ],
+ );
+
+ if ($user === null) {
+ return false;
+ }
+
+ $transaction = null;
+
+ try {
+ $transaction = Yii::$app->db->beginTransaction();
+
+ $user->generateEmailVerificationToken();
+
+ if (!$user->save(false)) {
+ $transaction->rollBack();
+
+ return false;
+ }
+
+ $sent = $mailer
+ ->compose(['html' => 'emailVerify-html', 'text' => 'emailVerify-text'], ['user' => $user])
+ ->setFrom([$supportEmail => "{$appName} robot"])
+ ->setTo($this->email)
+ ->setSubject("Account registration at {$appName}")
+ ->send();
+
+ if (!$sent) {
+ $transaction->rollBack();
+
+ return false;
+ }
+
+ $transaction->commit();
+
+ return true;
+ } catch (Throwable $e) {
+ if ($transaction !== null && $transaction->isActive) {
+ $transaction->rollBack();
+ }
+
+ Yii::error($e->getMessage(), __METHOD__);
+
+ return false;
+ }
+ }
+}
diff --git a/src/models/ResetPasswordForm.php b/src/models/ResetPasswordForm.php
new file mode 100644
index 000000000..92da8c857
--- /dev/null
+++ b/src/models/ResetPasswordForm.php
@@ -0,0 +1,79 @@
+ $config name-value pairs that will be used to initialize the object properties.
+ *
+ * @throws InvalidArgumentException if token is empty or not valid.
+ */
+ public function __construct(string $token, array $config = [])
+ {
+ if ($token === '') {
+ throw new InvalidArgumentException('Password reset token cannot be blank.');
+ }
+
+ $this->user = User::findByPasswordResetToken($token);
+
+ if ($this->user === null) {
+ throw new InvalidArgumentException('Wrong password reset token.');
+ }
+
+ parent::__construct($config);
+ }
+
+ /**
+ * Resets password.
+ */
+ public function resetPassword(): bool
+ {
+ if ($this->user === null) {
+ return false;
+ }
+
+ $this->user->setPassword($this->password);
+ $this->user->removePasswordResetToken();
+ $this->user->generateAuthKey();
+
+ return $this->user->save(false);
+ }
+
+ public function rules(): array
+ {
+ return [
+ [
+ 'password',
+ 'required',
+ ],
+ [
+ 'password',
+ 'string',
+ 'min' => Yii::$app->params['user.passwordMinLength'],
+ ],
+ ];
+ }
+}
diff --git a/src/models/SignupForm.php b/src/models/SignupForm.php
new file mode 100644
index 000000000..a83ef58a3
--- /dev/null
+++ b/src/models/SignupForm.php
@@ -0,0 +1,150 @@
+ User::class,
+ 'message' => 'This username has already been taken.',
+ ],
+ [
+ 'username',
+ 'string',
+ 'min' => 2,
+ 'max' => 255,
+ ],
+
+ [
+ 'email',
+ 'trim',
+ ],
+ [
+ 'email',
+ 'required',
+ ],
+ [
+ 'email',
+ 'email',
+ ],
+ [
+ 'email',
+ 'string',
+ 'max' => 255,
+ ],
+ [
+ 'email',
+ 'unique',
+ 'targetClass' => User::class,
+ 'message' => 'This email address has already been taken.',
+ ],
+
+ [
+ 'password',
+ 'required',
+ ],
+ [
+ 'password',
+ 'string',
+ 'min' => Yii::$app->params['user.passwordMinLength'],
+ ],
+ ];
+ }
+
+ /**
+ * Signs user up.
+ *
+ * @return bool|null whether the creating new account was successful and email was sent.
+ */
+ public function signup(MailerInterface $mailer, string $supportEmail, string $appName): bool|null
+ {
+ if (!$this->validate()) {
+ return null;
+ }
+
+ $transaction = null;
+
+ try {
+ $transaction = Yii::$app->db->beginTransaction();
+
+ $user = new User();
+
+ $user->username = $this->username;
+ $user->email = $this->email;
+
+ $user->setPassword($this->password);
+ $user->generateAuthKey();
+ $user->generateEmailVerificationToken();
+
+ if (!$user->save()) {
+ $transaction->rollBack();
+
+ return false;
+ }
+
+ if (!$this->sendEmail($mailer, $user, $supportEmail, $appName)) {
+ $transaction->rollBack();
+
+ return false;
+ }
+
+ $transaction->commit();
+
+ return true;
+ } catch (Throwable $e) {
+ if ($transaction !== null && $transaction->isActive) {
+ $transaction->rollBack();
+ }
+
+ Yii::error($e->getMessage(), __METHOD__);
+
+ return false;
+ }
+ }
+
+ /**
+ * Sends confirmation email to user.
+ */
+ protected function sendEmail(MailerInterface $mailer, User $user, string $supportEmail, string $appName): bool
+ {
+ return $mailer
+ ->compose(['html' => 'emailVerify-html', 'text' => 'emailVerify-text'], ['user' => $user])
+ ->setFrom([$supportEmail => "{$appName} robot"])
+ ->setTo($this->email)
+ ->setSubject("Account registration at {$appName}")
+ ->send();
+ }
+}
diff --git a/src/models/User.php b/src/models/User.php
new file mode 100644
index 000000000..7ea4e1105
--- /dev/null
+++ b/src/models/User.php
@@ -0,0 +1,257 @@
+ $token,
+ 'status' => self::STATUS_ACTIVE,
+ ],
+ );
+ }
+
+ /**
+ * Finds user by username.
+ */
+ public static function findByUsername(string $username): self|null
+ {
+ return static::findOne(
+ [
+ 'username' => $username,
+ 'status' => self::STATUS_ACTIVE,
+ ],
+ );
+ }
+
+ /**
+ * Finds user by verification email token.
+ */
+ public static function findByVerificationToken(string $token): self|null
+ {
+ if (!static::isVerificationTokenValid($token)) {
+ return null;
+ }
+
+ return static::findOne(
+ [
+ 'verification_token' => $token,
+ 'status' => self::STATUS_INACTIVE,
+ ],
+ );
+ }
+
+ /**
+ * Finds an identity by the given ID.
+ */
+ public static function findIdentity($id): self|null
+ {
+ return static::findOne(
+ [
+ 'id' => $id,
+ 'status' => self::STATUS_ACTIVE,
+ ],
+ );
+ }
+
+ /**
+ * Finds an identity by the given token.
+ */
+ public static function findIdentityByAccessToken($token, $type = null): never
+ {
+ throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
+ }
+
+ /**
+ * Generates "remember me" authentication key.
+ */
+ public function generateAuthKey(): void
+ {
+ $this->auth_key = Yii::$app->security->generateRandomString();
+ }
+
+ /**
+ * Generates new token for email verification.
+ */
+ public function generateEmailVerificationToken(): void
+ {
+ $this->verification_token = Yii::$app->security->generateRandomString() . '_' . time();
+ }
+
+ /**
+ * Generates new password reset token.
+ */
+ public function generatePasswordResetToken(): void
+ {
+ $this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time();
+ }
+
+ /**
+ * @return string Current user `auth_key` value.
+ */
+ public function getAuthKey(): string
+ {
+ return $this->auth_key;
+ }
+
+ /**
+ * @return int|string Current user ID.
+ */
+ public function getId(): int|string
+ {
+ /* @phpstan-ignore-next-line */
+ return $this->getPrimaryKey();
+ }
+
+ /**
+ * Checks if password reset token is valid.
+ */
+ public static function isPasswordResetTokenValid(string|null $token): bool
+ {
+ return self::isTokenValid($token, 'user.passwordResetTokenExpire', 3600);
+ }
+
+ /**
+ * Checks if verification email token is valid.
+ */
+ public static function isVerificationTokenValid(string|null $token): bool
+ {
+ return self::isTokenValid($token, 'user.emailVerificationTokenExpire', 86400);
+ }
+
+ /**
+ * Removes password reset token.
+ */
+ public function removePasswordResetToken(): void
+ {
+ $this->password_reset_token = null;
+ }
+
+ public function rules(): array
+ {
+ return [
+ [
+ 'status',
+ 'default',
+ 'value' => self::STATUS_INACTIVE,
+ ],
+ [
+ 'status',
+ 'in',
+ 'range' => [
+ self::STATUS_ACTIVE,
+ self::STATUS_INACTIVE,
+ self::STATUS_DELETED,
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Generates password hash from password and sets it to the model.
+ */
+ public function setPassword(string $password): void
+ {
+ $this->password_hash = Yii::$app->security->generatePasswordHash($password);
+ }
+
+ public static function tableName(): string
+ {
+ return '{{%user}}';
+ }
+
+ /**
+ * Validates auth key.
+ */
+ public function validateAuthKey($authKey): bool
+ {
+ return $this->getAuthKey() === $authKey;
+ }
+
+ /**
+ * Validates password.
+ */
+ public function validatePassword(string $password): bool
+ {
+ return Yii::$app->security->validatePassword($password, $this->password_hash);
+ }
+
+ /**
+ * Validates a timestamped token against a configurable expiration period.
+ */
+ private static function isTokenValid(string|null $token, string $paramKey, int $defaultExpire): bool
+ {
+ if ($token === null || $token === '') {
+ return false;
+ }
+
+ $searchToken = strrpos($token, '_');
+
+ if ($searchToken === false) {
+ return false;
+ }
+
+ $timestampPart = substr($token, $searchToken + 1);
+
+ if ($timestampPart === '' || !ctype_digit($timestampPart)) {
+ return false;
+ }
+
+ $timestamp = (int) $timestampPart;
+
+ /** @var int $expire */
+ $expire = Yii::$app->params[$paramKey] ?? $defaultExpire;
+
+ return $timestamp + $expire >= time();
+ }
+}
diff --git a/src/models/UserSearch.php b/src/models/UserSearch.php
new file mode 100644
index 000000000..5ae9d0b97
--- /dev/null
+++ b/src/models/UserSearch.php
@@ -0,0 +1,68 @@
+ $params search parameters from the request.
+ *
+ * @return ActiveDataProvider the data provider with the applied search query.
+ */
+ public function search(array $params): ActiveDataProvider
+ {
+ $query = User::find();
+
+ $dataProvider = new ActiveDataProvider(
+ [
+ 'query' => $query,
+ 'pagination' => [
+ 'pageSize' => 10,
+ ],
+ 'sort' => [
+ 'defaultOrder' => [
+ 'id' => SORT_DESC,
+ ],
+ ],
+ ],
+ );
+
+ $this->load($params);
+
+ if (!$this->validate()) {
+ $query->where('0=1');
+
+ return $dataProvider;
+ }
+
+ $query->andFilterWhere(['id' => $this->id])
+ ->andFilterWhere(['status' => $this->status])
+ ->andFilterWhere(['like', 'username', $this->username])
+ ->andFilterWhere(['like', 'email', $this->email]);
+
+ return $dataProvider;
+ }
+}
diff --git a/src/models/VerifyEmailForm.php b/src/models/VerifyEmailForm.php
new file mode 100644
index 000000000..0a07e4074
--- /dev/null
+++ b/src/models/VerifyEmailForm.php
@@ -0,0 +1,62 @@
+ $config name-value pairs that will be used to initialize the object properties.
+ *
+ * @throws InvalidArgumentException if token is empty or not valid.
+ */
+ public function __construct(string $token, array $config = [])
+ {
+ if ($token === '') {
+ throw new InvalidArgumentException('Verify email token cannot be blank.');
+ }
+
+ $this->user = User::findByVerificationToken($token);
+
+ if ($this->user === null) {
+ throw new InvalidArgumentException('Wrong verify email token.');
+ }
+
+ parent::__construct($config);
+ }
+
+ /**
+ * Verifies email.
+ *
+ * @return User|null the saved model or `null` if saving fails.
+ */
+ public function verifyEmail(): User|null
+ {
+ if ($this->user === null) {
+ return null;
+ }
+
+ $this->user->status = User::STATUS_ACTIVE;
+ $this->user->verification_token = null;
+
+ return $this->user->save(false) ? $this->user : null;
+ }
+}
diff --git a/src/widgets/Alert.php b/src/widgets/Alert.php
new file mode 100644
index 000000000..b94186211
--- /dev/null
+++ b/src/widgets/Alert.php
@@ -0,0 +1,85 @@
+session->setFlash('error', 'This is the message');
+ * Yii::$app->session->setFlash('success', 'This is the message');
+ * Yii::$app->session->setFlash('info', 'This is the message');
+ * ```
+ *
+ * Multiple messages could be set as follows:
+ *
+ * ```php
+ * Yii::$app->session->setFlash('error', ['Error 1', 'Error 2']);
+ * ```
+ */
+final class Alert extends \yii\bootstrap5\Widget
+{
+ /**
+ * @var array the alert types configuration for the flash messages.
+ *
+ * This array is setup as $key => $value, where:
+ * - key: the name of the session flash variable
+ * - value: the bootstrap alert type (i.e. danger, success, info, warning)
+ */
+ public array $alertTypes = [
+ 'error' => 'alert-danger',
+ 'danger' => 'alert-danger',
+ 'success' => 'alert-success',
+ 'info' => 'alert-info',
+ 'warning' => 'alert-warning',
+ ];
+ /**
+ * @var array the options for rendering the close button tag.
+ */
+ public array $closeButton = [];
+
+ public function run(): void
+ {
+ $session = Yii::$app->session;
+
+ if (!$session->getIsActive() && !$session->getHasSessionId()) {
+ return;
+ }
+
+ $appendClass = isset($this->options['class']) && is_string($this->options['class'])
+ ? ' ' . $this->options['class']
+ : '';
+
+ foreach (array_keys($this->alertTypes) as $type) {
+ $flash = $session->getFlash($type);
+
+ foreach ((array) $flash as $i => $message) {
+ echo BootstrapAlert::widget(
+ [
+ 'body' => $message,
+ 'closeButton' => $this->closeButton,
+ 'options' => [
+ ...$this->options,
+ 'id' => $this->getId() . '-' . $type . '-' . $i,
+ 'class' => $this->alertTypes[$type] . $appendClass,
+ ],
+ ],
+ );
+ }
+
+ $session->removeFlash($type);
+ }
+ }
+}
diff --git a/tests/Acceptance/AboutCest.php b/tests/Acceptance/AboutCest.php
deleted file mode 100644
index d2387c3f4..000000000
--- a/tests/Acceptance/AboutCest.php
+++ /dev/null
@@ -1,14 +0,0 @@
-amOnPage(Url::toRoute('/site/about'));
- $I->see('About', 'h1');
- }
-}
diff --git a/tests/Acceptance/HomeCest.php b/tests/Acceptance/HomeCest.php
deleted file mode 100644
index e9e004209..000000000
--- a/tests/Acceptance/HomeCest.php
+++ /dev/null
@@ -1,20 +0,0 @@
-amOnPage(Url::toRoute('/site/index'));
- $I->see('My Company');
-
- $I->seeLink('About');
- $I->click('About');
-
- $I->expectTo('see About page');
- $I->see('This is the About page.');
- }
-}
diff --git a/tests/Acceptance/LoginCest.php b/tests/Acceptance/LoginCest.php
deleted file mode 100644
index 986700a09..000000000
--- a/tests/Acceptance/LoginCest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-amOnPage(Url::toRoute('/site/login'));
- $I->see('Login', 'h1');
-
- $I->amGoingTo('try to login with correct credentials');
- $I->fillField('input[name="LoginForm[username]"]', 'admin');
- $I->fillField('input[name="LoginForm[password]"]', 'admin');
- $I->click('login-button');
-
- $I->expectTo('see user info');
- $I->see('Logout');
-
- $I->amGoingTo('try to login with the user is logged in');
- $I->amOnPage(Url::toRoute('/site/login'));
- $I->dontSee('Login', 'h1');
-
- $I->amGoingTo('logout');
- $I->click('Logout');
-
- $I->expectTo('see home page');
- $I->see('Congratulations!');
- }
-}
diff --git a/tests/Acceptance/_bootstrap.php b/tests/Acceptance/_bootstrap.php
deleted file mode 100644
index b3d9bbc7f..000000000
--- a/tests/Acceptance/_bootstrap.php
+++ /dev/null
@@ -1 +0,0 @@
-amOnRoute('site/contact');
- }
-
- public function openContactPage(FunctionalTester $I): void
- {
- $I->see('Contact', 'h1');
- }
-
- public function submitEmptyForm(FunctionalTester $I): void
- {
- $I->submitForm('#contact-form', []);
- $I->expectTo('see validations errors');
- $I->see('Contact', 'h1');
- $I->see('Name cannot be blank');
- $I->see('Email cannot be blank');
- $I->see('Subject cannot be blank');
- $I->see('Body cannot be blank');
- $I->see('The verification code is incorrect');
- }
-
- public function submitFormWithIncorrectEmail(FunctionalTester $I): void
- {
- $I->submitForm('#contact-form', [
- 'ContactForm[name]' => 'tester',
- 'ContactForm[email]' => 'tester.email',
- 'ContactForm[subject]' => 'test subject',
- 'ContactForm[body]' => 'test content',
- 'ContactForm[verifyCode]' => 'testme',
- ]);
- $I->expectTo('see that email address is wrong');
- $I->dontSee('Name cannot be blank', '.help-inline');
- $I->see('Email is not a valid email address.');
- $I->dontSee('Subject cannot be blank', '.help-inline');
- $I->dontSee('Body cannot be blank', '.help-inline');
- $I->dontSee('The verification code is incorrect', '.help-inline');
- }
-
- public function submitFormSuccessfully(FunctionalTester $I): void
- {
- $I->submitForm('#contact-form', [
- 'ContactForm[name]' => 'tester',
- 'ContactForm[email]' => 'tester@example.com',
- 'ContactForm[subject]' => 'test subject',
- 'ContactForm[body]' => 'test content',
- 'ContactForm[verifyCode]' => 'testme',
- ]);
- $I->seeEmailIsSent();
- $I->dontSeeElement('#contact-form');
- $I->see('Thank you for contacting us. We will respond to you as soon as possible.');
- }
-}
diff --git a/tests/Functional/LoginFormCest.php b/tests/Functional/LoginFormCest.php
deleted file mode 100644
index 6cf78fa2b..000000000
--- a/tests/Functional/LoginFormCest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-amOnRoute('site/login');
- }
-
- public function openLoginPage(FunctionalTester $I): void
- {
- $I->see('Login', 'h1');
- }
-
- // demonstrates `amLoggedInAs` method
- public function internalLoginById(FunctionalTester $I): void
- {
- $I->amLoggedInAs(100);
- $I->amOnPage('/');
- $I->see('Logout (admin)');
- }
-
- // demonstrates `amLoggedInAs` method
- public function internalLoginByInstance(FunctionalTester $I): void
- {
- $I->amLoggedInAs(\app\models\User::findByUsername('admin'));
- $I->amOnPage('/');
- $I->see('Logout (admin)');
- }
-
- public function loginWithEmptyCredentials(FunctionalTester $I): void
- {
- $I->submitForm('#login-form', []);
- $I->expectTo('see validations errors');
- $I->see('Username cannot be blank.');
- $I->see('Password cannot be blank.');
- }
-
- public function loginWithWrongCredentials(FunctionalTester $I): void
- {
- $I->submitForm('#login-form', [
- 'LoginForm[username]' => 'admin',
- 'LoginForm[password]' => 'wrong',
- ]);
- $I->expectTo('see validations errors');
- $I->see('Incorrect username or password.');
- }
-
- public function loginSuccessfully(FunctionalTester $I): void
- {
- $I->submitForm('#login-form', [
- 'LoginForm[username]' => 'admin',
- 'LoginForm[password]' => 'admin',
- ]);
- $I->see('Logout (admin)');
- $I->dontSeeElement('form#login-form');
- }
-}
diff --git a/tests/Functional/_bootstrap.php b/tests/Functional/_bootstrap.php
deleted file mode 100644
index b3d9bbc7f..000000000
--- a/tests/Functional/_bootstrap.php
+++ /dev/null
@@ -1 +0,0 @@
-getScenario()->runStep(new \Codeception\Step\Condition('amInPath', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Opens a file and stores it's content.
- *
- * Usage:
- *
- * ``` php
- * openFile('composer.json');
- * $I->seeInThisFile('codeception/codeception');
- * ```
- * @see \Codeception\Module\Filesystem::openFile()
- */
- public function openFile(string $filename): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('openFile', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Deletes a file
- *
- * ``` php
- * deleteFile('composer.lock');
- * ```
- * @see \Codeception\Module\Filesystem::deleteFile()
- */
- public function deleteFile(string $filename): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('deleteFile', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Deletes directory with all subdirectories
- *
- * ``` php
- * deleteDir('vendor');
- * ```
- * @see \Codeception\Module\Filesystem::deleteDir()
- */
- public function deleteDir(string $dirname): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('deleteDir', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Copies directory with all contents
- *
- * ``` php
- * copyDir('vendor','old_vendor');
- * ```
- * @see \Codeception\Module\Filesystem::copyDir()
- */
- public function copyDir(string $src, string $dst): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('copyDir', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks If opened file has `text` in it.
- *
- * Usage:
- *
- * ``` php
- * openFile('composer.json');
- * $I->seeInThisFile('codeception/codeception');
- * ```
- * @see \Codeception\Module\Filesystem::seeInThisFile()
- */
- public function seeInThisFile(string $text): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInThisFile', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks If opened file has `text` in it.
- *
- * Usage:
- *
- * ``` php
- * openFile('composer.json');
- * $I->seeInThisFile('codeception/codeception');
- * ```
- * @see \Codeception\Module\Filesystem::seeInThisFile()
- */
- public function canSeeInThisFile(string $text): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInThisFile', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks If opened file has the `number` of new lines.
- *
- * Usage:
- *
- * ``` php
- * openFile('composer.json');
- * $I->seeNumberNewLines(5);
- * ```
- *
- * @param int $number New lines
- * @see \Codeception\Module\Filesystem::seeNumberNewLines()
- */
- public function seeNumberNewLines(int $number): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberNewLines', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks If opened file has the `number` of new lines.
- *
- * Usage:
- *
- * ``` php
- * openFile('composer.json');
- * $I->seeNumberNewLines(5);
- * ```
- *
- * @param int $number New lines
- * @see \Codeception\Module\Filesystem::seeNumberNewLines()
- */
- public function canSeeNumberNewLines(int $number): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberNewLines', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that contents of currently opened file matches $regex
- * @see \Codeception\Module\Filesystem::seeThisFileMatches()
- */
- public function seeThisFileMatches(string $regex): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeThisFileMatches', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that contents of currently opened file matches $regex
- * @see \Codeception\Module\Filesystem::seeThisFileMatches()
- */
- public function canSeeThisFileMatches(string $regex): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeThisFileMatches', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks the strict matching of file contents.
- * Unlike `seeInThisFile` will fail if file has something more than expected lines.
- * Better to use with HEREDOC strings.
- * Matching is done after removing "\r" chars from file content.
- *
- * ``` php
- * openFile('process.pid');
- * $I->seeFileContentsEqual('3192');
- * ```
- * @see \Codeception\Module\Filesystem::seeFileContentsEqual()
- */
- public function seeFileContentsEqual(string $text): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeFileContentsEqual', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks the strict matching of file contents.
- * Unlike `seeInThisFile` will fail if file has something more than expected lines.
- * Better to use with HEREDOC strings.
- * Matching is done after removing "\r" chars from file content.
- *
- * ``` php
- * openFile('process.pid');
- * $I->seeFileContentsEqual('3192');
- * ```
- * @see \Codeception\Module\Filesystem::seeFileContentsEqual()
- */
- public function canSeeFileContentsEqual(string $text): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeFileContentsEqual', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks If opened file doesn't contain `text` in it
- *
- * ``` php
- * openFile('composer.json');
- * $I->dontSeeInThisFile('codeception/codeception');
- * ```
- * @see \Codeception\Module\Filesystem::dontSeeInThisFile()
- */
- public function dontSeeInThisFile(string $text): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeInThisFile', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks If opened file doesn't contain `text` in it
- *
- * ``` php
- * openFile('composer.json');
- * $I->dontSeeInThisFile('codeception/codeception');
- * ```
- * @see \Codeception\Module\Filesystem::dontSeeInThisFile()
- */
- public function cantSeeInThisFile(string $text): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInThisFile', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Deletes a file
- * @see \Codeception\Module\Filesystem::deleteThisFile()
- */
- public function deleteThisFile(): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('deleteThisFile', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks if file exists in path.
- * Opens a file when it's exists
- *
- * ``` php
- * seeFileFound('UserModel.php','app/models');
- * ```
- * @see \Codeception\Module\Filesystem::seeFileFound()
- */
- public function seeFileFound(string $filename, string $path = ""): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeFileFound', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks if file exists in path.
- * Opens a file when it's exists
- *
- * ``` php
- * seeFileFound('UserModel.php','app/models');
- * ```
- * @see \Codeception\Module\Filesystem::seeFileFound()
- */
- public function canSeeFileFound(string $filename, string $path = ""): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeFileFound', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks if file does not exist in path
- * @see \Codeception\Module\Filesystem::dontSeeFileFound()
- */
- public function dontSeeFileFound(string $filename, string $path = ""): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeFileFound', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks if file does not exist in path
- * @see \Codeception\Module\Filesystem::dontSeeFileFound()
- */
- public function cantSeeFileFound(string $filename, string $path = ""): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeFileFound', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Erases directory contents
- *
- * ``` php
- * cleanDir('logs');
- * ```
- * @see \Codeception\Module\Filesystem::cleanDir()
- */
- public function cleanDir(string $dirname): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('cleanDir', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Saves contents to file
- * @see \Codeception\Module\Filesystem::writeToFile()
- */
- public function writeToFile(string $filename, string $contents): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('writeToFile', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Authenticates a user on a site without submitting a login form.
- * Use it for fast pragmatic authorization in functional tests.
- *
- * ```php
- * amLoggedInAs(1);
- *
- * // User object is passed as parameter
- * $admin = \app\models\User::findByUsername('admin');
- * $I->amLoggedInAs($admin);
- * ```
- * Requires the `user` component to be enabled and configured.
- *
- * @throws \Codeception\Exception\ModuleException
- * @see \Codeception\Module\Yii2::amLoggedInAs()
- */
- public function amLoggedInAs(\yii\web\IdentityInterface|string|int $user): void {
- $this->getScenario()->runStep(new \Codeception\Step\Condition('amLoggedInAs', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Creates and loads fixtures from a config.
- * The signature is the same as for the `fixtures()` method of `yii\test\FixtureTrait`
- *
- * ```php
- * haveFixtures([
- * 'posts' => PostsFixture::class,
- * 'user' => [
- * 'class' => UserFixture::class,
- * 'dataFile' => '@tests/_data/models/user.php',
- * ],
- * ]);
- * ```
- *
- * Note: if you need to load fixtures before a test (probably before the
- * cleanup transaction is started; `cleanup` option is `true` by default),
- * you can specify the fixtures in the `_fixtures()` method of a test case
- *
- * ```php
- * [
- * 'class' => UserFixture::class,
- * 'dataFile' => codecept_data_dir() . 'user.php'
- * ]
- * ];
- * }
- * ```
- * instead of calling `haveFixtures` in Cest `_before`
- *
- * @param $fixtures
- * @part fixtures
- * @see \Codeception\Module\Yii2::haveFixtures()
- */
- public function haveFixtures($fixtures): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('haveFixtures', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Returns all loaded fixtures.
- * Array of fixture instances
- *
- * @part fixtures
- * @return array
- * @see \Codeception\Module\Yii2::grabFixtures()
- */
- public function grabFixtures() {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFixtures', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Gets a fixture by name.
- * Returns a Fixture instance. If a fixture is an instance of
- * `\yii\test\BaseActiveFixture` a second parameter can be used to return a
- * specific model:
- *
- * ```php
- * haveFixtures(['users' => UserFixture::class]);
- *
- * $users = $I->grabFixture('users');
- *
- * // get first user by key, if a fixture is an instance of ActiveFixture
- * $user = $I->grabFixture('users', 'user1');
- * ```
- *
- * @param $name
- * @return mixed
- * @throws \Codeception\Exception\ModuleException if the fixture is not found
- * @part fixtures
- * @see \Codeception\Module\Yii2::grabFixture()
- */
- public function grabFixture($name, $index = NULL) {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFixture', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Inserts a record into the database.
- *
- * ``` php
- * haveRecord('app\models\User', array('name' => 'Davert'));
- * ?>
- * ```
- * @template T of \yii\db\ActiveRecord
- * @param class-string $model
- * @param array $attributes
- * @return mixed
- * @part orm
- * @see \Codeception\Module\Yii2::haveRecord()
- */
- public function haveRecord(string $model, $attributes = []): mixed {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('haveRecord', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that a record exists in the database.
- *
- * ``` php
- * $I->seeRecord('app\models\User', array('name' => 'davert'));
- * ```
- *
- * @param class-string<\yii\db\ActiveRecord> $model
- * @param array $attributes
- * @part orm
- * @see \Codeception\Module\Yii2::seeRecord()
- */
- public function seeRecord(string $model, array $attributes = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeRecord', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that a record exists in the database.
- *
- * ``` php
- * $I->seeRecord('app\models\User', array('name' => 'davert'));
- * ```
- *
- * @param class-string<\yii\db\ActiveRecord> $model
- * @param array $attributes
- * @part orm
- * @see \Codeception\Module\Yii2::seeRecord()
- */
- public function canSeeRecord(string $model, array $attributes = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeRecord', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that a record does not exist in the database.
- *
- * ``` php
- * $I->dontSeeRecord('app\models\User', array('name' => 'davert'));
- * ```
- *
- * @param class-string<\yii\db\ActiveRecord> $model
- * @param array $attributes
- * @part orm
- * @see \Codeception\Module\Yii2::dontSeeRecord()
- */
- public function dontSeeRecord(string $model, array $attributes = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeRecord', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that a record does not exist in the database.
- *
- * ``` php
- * $I->dontSeeRecord('app\models\User', array('name' => 'davert'));
- * ```
- *
- * @param class-string<\yii\db\ActiveRecord> $model
- * @param array $attributes
- * @part orm
- * @see \Codeception\Module\Yii2::dontSeeRecord()
- */
- public function cantSeeRecord(string $model, array $attributes = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeRecord', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Retrieves a record from the database
- *
- * ``` php
- * $category = $I->grabRecord('app\models\User', array('name' => 'davert'));
- * ```
- *
- * @param class-string<\yii\db\ActiveRecord> $model
- * @param array $attributes
- * @part orm
- * @see \Codeception\Module\Yii2::grabRecord()
- */
- public function grabRecord(string $model, array $attributes = []): \yii\db\ActiveRecord|array|null {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabRecord', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Similar to `amOnPage` but accepts a route as first argument and params as second
- *
- * ```
- * $I->amOnRoute('site/view', ['page' => 'about']);
- * ```
- *
- * @param string $route A route
- * @param array $params Additional route parameters
- * @see \Codeception\Module\Yii2::amOnRoute()
- */
- public function amOnRoute(string $route, array $params = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnRoute', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Gets a component from the Yii container. Throws an exception if the
- * component is not available
- *
- * ```php
- * grabComponent('mailer');
- * ```
- *
- * @throws \Codeception\Exception\ModuleException
- * @deprecated in your tests you can use \Yii::$app directly.
- * @see \Codeception\Module\Yii2::grabComponent()
- */
- public function grabComponent(string $component): ?object {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabComponent', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that an email is sent.
- *
- * ```php
- * seeEmailIsSent();
- *
- * // check that only 3 emails were sent
- * $I->seeEmailIsSent(3);
- * ```
- *
- * @param int|null $num
- * @throws \Codeception\Exception\ModuleException
- * @part email
- * @see \Codeception\Module\Yii2::seeEmailIsSent()
- */
- public function seeEmailIsSent(?int $num = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeEmailIsSent', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that an email is sent.
- *
- * ```php
- * seeEmailIsSent();
- *
- * // check that only 3 emails were sent
- * $I->seeEmailIsSent(3);
- * ```
- *
- * @param int|null $num
- * @throws \Codeception\Exception\ModuleException
- * @part email
- * @see \Codeception\Module\Yii2::seeEmailIsSent()
- */
- public function canSeeEmailIsSent(?int $num = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeEmailIsSent', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that no email was sent
- *
- * @part email
- * @see \Codeception\Module\Yii2::dontSeeEmailIsSent()
- */
- public function dontSeeEmailIsSent(): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeEmailIsSent', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that no email was sent
- *
- * @part email
- * @see \Codeception\Module\Yii2::dontSeeEmailIsSent()
- */
- public function cantSeeEmailIsSent(): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeEmailIsSent', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Returns array of all sent email messages.
- * Each message implements the `yii\mail\MessageInterface` interface.
- * Useful to perform additional checks using the `Asserts` module:
- *
- * ```php
- * seeEmailIsSent();
- * $messages = $I->grabSentEmails();
- * $I->assertEquals('admin@site,com', $messages[0]->getTo());
- * ```
- *
- * @part email
- * @return array
- * @throws \Codeception\Exception\ModuleException
- * @see \Codeception\Module\Yii2::grabSentEmails()
- */
- public function grabSentEmails(): array {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabSentEmails', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Returns the last sent email:
- *
- * ```php
- * seeEmailIsSent();
- * $message = $I->grabLastSentEmail();
- * $I->assertEquals('admin@site,com', $message->getTo());
- * ```
- * @part email
- * @see \Codeception\Module\Yii2::grabLastSentEmail()
- */
- public function grabLastSentEmail(): object {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabLastSentEmail', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Returns a list of regex patterns for recognized domain names
- *
- * @return array
- * @see \Codeception\Module\Yii2::getInternalDomains()
- */
- public function getInternalDomains(): array {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('getInternalDomains', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Sets a cookie and, if validation is enabled, signs it.
- * @param string $name The name of the cookie
- * @param string $val The value of the cookie
- * @param array $params Additional cookie params like `domain`, `path`, `expires` and `secure`.
- * @see \Codeception\Module\Yii2::setCookie()
- */
- public function setCookie($name, $val, $params = []) {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Creates the CSRF Cookie.
- * @param string $val The value of the CSRF token
- * @return string[] Returns an array containing the name of the CSRF param and the masked CSRF token.
- * @see \Codeception\Module\Yii2::createAndSetCsrfCookie()
- */
- public function createAndSetCsrfCookie(string $val): array {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('createAndSetCsrfCookie', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Authenticates user for HTTP_AUTH
- * @see \Codeception\Lib\InnerBrowser::amHttpAuthenticated()
- */
- public function amHttpAuthenticated(string $username, string $password): void {
- $this->getScenario()->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Sets the HTTP header to the passed value - which is used on
- * subsequent HTTP requests through PhpBrowser.
- *
- * Example:
- * ```php
- * haveHttpHeader('X-Requested-With', 'Codeception');
- * $I->amOnPage('test-headers.php');
- * ```
- *
- * To use special chars in Header Key use HTML Character Entities:
- * Example:
- * Header with underscore - 'Client_Id'
- * should be represented as - 'Client_Id' or 'Client_Id'
- *
- * ```php
- * haveHttpHeader('Client_Id', 'Codeception');
- * ```
- *
- * @param string $name the name of the request header
- * @param string $value the value to set it to for subsequent
- * requests
- * @see \Codeception\Lib\InnerBrowser::haveHttpHeader()
- */
- public function haveHttpHeader(string $name, string $value): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('haveHttpHeader', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Unsets a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)),
- * so that subsequent requests will not send it anymore.
- *
- * Example:
- * ```php
- * haveHttpHeader('X-Requested-With', 'Codeception');
- * $I->amOnPage('test-headers.php');
- * // ...
- * $I->unsetHeader('X-Requested-With');
- * $I->amOnPage('some-other-page.php');
- * ```
- *
- * @param string $name the name of the header to unset.
- * @see \Codeception\Lib\InnerBrowser::unsetHttpHeader()
- */
- public function unsetHttpHeader(string $name): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('unsetHttpHeader', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * @deprecated Use [unsetHttpHeader](#unsetHttpHeader) instead
- * @see \Codeception\Lib\InnerBrowser::deleteHeader()
- */
- public function deleteHeader(string $name): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Opens the page for the given relative URI.
- *
- * ```php
- * amOnPage('/');
- * // opens /register page
- * $I->amOnPage('/register');
- * ```
- * @see \Codeception\Lib\InnerBrowser::amOnPage()
- */
- public function amOnPage(string $page): void {
- $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Perform a click on a link or a button, given by a locator.
- * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
- * For buttons, the "value" attribute, "name" attribute, and inner text are searched.
- * For links, the link text is searched.
- * For images, the "alt" attribute and inner text of any parent links are searched.
- *
- * The second parameter is a context (CSS or XPath locator) to narrow the search.
- *
- * Note that if the locator matches a button of type `submit`, the form will be submitted.
- *
- * ```php
- * click('Logout');
- * // button of form
- * $I->click('Submit');
- * // CSS button
- * $I->click('#form input[type=submit]');
- * // XPath
- * $I->click('//form/*[@type="submit"]');
- * // link in context
- * $I->click('Logout', '#nav');
- * // using strict locator
- * $I->click(['link' => 'Login']);
- * ```
- * @param string|array $link
- * @see \Codeception\Lib\InnerBrowser::click()
- */
- public function click($link, $context = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the current page contains the given string (case insensitive).
- *
- * You can specify a specific HTML element (via CSS or XPath) as the second
- * parameter to only search within that element.
- *
- * ```php
- * see('Logout'); // I can suppose user is logged in
- * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
- * $I->see('Sign Up', '//body/h1'); // with XPath
- * $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator
- * ```
- *
- * Note that the search is done after stripping all HTML tags from the body,
- * so `$I->see('strong')` will return true for strings like:
- *
- * - `
I am Stronger than thou
`
- * - ``
- *
- * But will *not* be true for strings like:
- *
- * - `Home`
- * - `
Home`
- * - ``
- *
- * For checking the raw source code, use `seeInSource()`.
- *
- * @param array|string $selector optional
- * @see \Codeception\Lib\InnerBrowser::see()
- */
- public function see(string $text, $selector = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the current page contains the given string (case insensitive).
- *
- * You can specify a specific HTML element (via CSS or XPath) as the second
- * parameter to only search within that element.
- *
- * ```php
- * see('Logout'); // I can suppose user is logged in
- * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
- * $I->see('Sign Up', '//body/h1'); // with XPath
- * $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator
- * ```
- *
- * Note that the search is done after stripping all HTML tags from the body,
- * so `$I->see('strong')` will return true for strings like:
- *
- * - `
I am Stronger than thou
`
- * - ``
- *
- * But will *not* be true for strings like:
- *
- * - `Home`
- * - `
Home`
- * - ``
- *
- * For checking the raw source code, use `seeInSource()`.
- *
- * @param array|string $selector optional
- * @see \Codeception\Lib\InnerBrowser::see()
- */
- public function canSee(string $text, $selector = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the current page doesn't contain the text specified (case insensitive).
- * Give a locator as the second parameter to match a specific region.
- *
- * ```php
- * dontSee('Login'); // I can suppose user is already logged in
- * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
- * $I->dontSee('Sign Up','//body/h1'); // with XPath
- * $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator
- * ```
- *
- * Note that the search is done after stripping all HTML tags from the body,
- * so `$I->dontSee('strong')` will fail on strings like:
- *
- * - `
Home`
- * - ``
- *
- * For checking the raw source code, use `seeInSource()`.
- *
- * @param array|string $selector optional
- * @see \Codeception\Lib\InnerBrowser::dontSee()
- */
- public function dontSee(string $text, $selector = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSee', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the current page doesn't contain the text specified (case insensitive).
- * Give a locator as the second parameter to match a specific region.
- *
- * ```php
- * dontSee('Login'); // I can suppose user is already logged in
- * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
- * $I->dontSee('Sign Up','//body/h1'); // with XPath
- * $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator
- * ```
- *
- * Note that the search is done after stripping all HTML tags from the body,
- * so `$I->dontSee('strong')` will fail on strings like:
- *
- * - `
Home`
- * - ``
- *
- * For checking the raw source code, use `seeInSource()`.
- *
- * @param array|string $selector optional
- * @see \Codeception\Lib\InnerBrowser::dontSee()
- */
- public function cantSee(string $text, $selector = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the current page contains the given string in its
- * raw source code.
- *
- * ```php
- * seeInSource('
Green eggs & ham
');
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeInSource()
- */
- public function seeInSource(string $raw): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the current page contains the given string in its
- * raw source code.
- *
- * ```php
- * seeInSource('
Green eggs & ham
');
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeInSource()
- */
- public function canSeeInSource(string $raw): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the current page contains the given string in its
- * raw source code.
- *
- * ```php
- * dontSeeInSource('
Green eggs & ham
');
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeInSource()
- */
- public function dontSeeInSource(string $raw): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeInSource', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the current page contains the given string in its
- * raw source code.
- *
- * ```php
- * dontSeeInSource('
Green eggs & ham
');
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeInSource()
- */
- public function cantSeeInSource(string $raw): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that there's a link with the specified text.
- * Give a full URL as the second parameter to match links with that exact URL.
- *
- * ```php
- * seeLink('Logout'); // matches Logout
- * $I->seeLink('Logout','/logout'); // matches Logout
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeLink()
- */
- public function seeLink(string $text, ?string $url = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that there's a link with the specified text.
- * Give a full URL as the second parameter to match links with that exact URL.
- *
- * ```php
- * seeLink('Logout'); // matches Logout
- * $I->seeLink('Logout','/logout'); // matches Logout
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeLink()
- */
- public function canSeeLink(string $text, ?string $url = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the page doesn't contain a link with the given string.
- * If the second parameter is given, only links with a matching "href" attribute will be checked.
- *
- * ```php
- * dontSeeLink('Logout'); // I suppose user is not logged in
- * $I->dontSeeLink('Checkout now', '/store/cart.php');
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeLink()
- */
- public function dontSeeLink(string $text, string $url = ""): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeLink', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the page doesn't contain a link with the given string.
- * If the second parameter is given, only links with a matching "href" attribute will be checked.
- *
- * ```php
- * dontSeeLink('Logout'); // I suppose user is not logged in
- * $I->dontSeeLink('Checkout now', '/store/cart.php');
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeLink()
- */
- public function cantSeeLink(string $text, string $url = ""): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that current URI contains the given string.
- *
- * ```php
- * seeInCurrentUrl('home');
- * // to match: /users/1
- * $I->seeInCurrentUrl('/users/');
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl()
- */
- public function seeInCurrentUrl(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that current URI contains the given string.
- *
- * ```php
- * seeInCurrentUrl('home');
- * // to match: /users/1
- * $I->seeInCurrentUrl('/users/');
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl()
- */
- public function canSeeInCurrentUrl(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the current URI doesn't contain the given string.
- *
- * ```php
- * dontSeeInCurrentUrl('/users/');
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl()
- */
- public function dontSeeInCurrentUrl(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeInCurrentUrl', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the current URI doesn't contain the given string.
- *
- * ```php
- * dontSeeInCurrentUrl('/users/');
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl()
- */
- public function cantSeeInCurrentUrl(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the current URL is equal to the given string.
- * Unlike `seeInCurrentUrl`, this only matches the full URL.
- *
- * ```php
- * seeCurrentUrlEquals('/');
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals()
- */
- public function seeCurrentUrlEquals(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the current URL is equal to the given string.
- * Unlike `seeInCurrentUrl`, this only matches the full URL.
- *
- * ```php
- * seeCurrentUrlEquals('/');
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals()
- */
- public function canSeeCurrentUrlEquals(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the current URL doesn't equal the given string.
- * Unlike `dontSeeInCurrentUrl`, this only matches the full URL.
- *
- * ```php
- * dontSeeCurrentUrlEquals('/');
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals()
- */
- public function dontSeeCurrentUrlEquals(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeCurrentUrlEquals', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the current URL doesn't equal the given string.
- * Unlike `dontSeeInCurrentUrl`, this only matches the full URL.
- *
- * ```php
- * dontSeeCurrentUrlEquals('/');
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals()
- */
- public function cantSeeCurrentUrlEquals(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the current URL matches the given regular expression.
- *
- * ```php
- * seeCurrentUrlMatches('~^/users/(\d+)~');
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches()
- */
- public function seeCurrentUrlMatches(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the current URL matches the given regular expression.
- *
- * ```php
- * seeCurrentUrlMatches('~^/users/(\d+)~');
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches()
- */
- public function canSeeCurrentUrlMatches(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that current url doesn't match the given regular expression.
- *
- * ```php
- * dontSeeCurrentUrlMatches('~^/users/(\d+)~');
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches()
- */
- public function dontSeeCurrentUrlMatches(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeCurrentUrlMatches', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that current url doesn't match the given regular expression.
- *
- * ```php
- * dontSeeCurrentUrlMatches('~^/users/(\d+)~');
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches()
- */
- public function cantSeeCurrentUrlMatches(string $uri): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Executes the given regular expression against the current URI and returns the first capturing group.
- * If no parameters are provided, the full URI is returned.
- *
- * ```php
- * grabFromCurrentUrl('~^/user/(\d+)/~');
- * $uri = $I->grabFromCurrentUrl();
- * ```
- * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl()
- */
- public function grabFromCurrentUrl(?string $uri = NULL): mixed {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the specified checkbox is checked.
- *
- * ```php
- * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
- * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
- * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked()
- */
- public function seeCheckboxIsChecked($checkbox): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the specified checkbox is checked.
- *
- * ```php
- * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
- * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
- * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked()
- */
- public function canSeeCheckboxIsChecked($checkbox): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Check that the specified checkbox is unchecked.
- *
- * ```php
- * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
- * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked()
- */
- public function dontSeeCheckboxIsChecked($checkbox): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeCheckboxIsChecked', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Check that the specified checkbox is unchecked.
- *
- * ```php
- * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
- * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked()
- */
- public function cantSeeCheckboxIsChecked($checkbox): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the given input field or textarea *equals* (i.e. not just contains) the given value.
- * Fields are matched by label text, the "name" attribute, CSS, or XPath.
- *
- * ```php
- * seeInField('Body','Type your comment here');
- * $I->seeInField('form textarea[name=body]','Type your comment here');
- * $I->seeInField('form input[type=hidden]','hidden_value');
- * $I->seeInField('#searchform input','Search');
- * $I->seeInField('//form/*[@name=search]','Search');
- * $I->seeInField(['name' => 'search'], 'Search');
- * ```
- *
- * @param string|array $field
- * @see \Codeception\Lib\InnerBrowser::seeInField()
- */
- public function seeInField($field, $value): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the given input field or textarea *equals* (i.e. not just contains) the given value.
- * Fields are matched by label text, the "name" attribute, CSS, or XPath.
- *
- * ```php
- * seeInField('Body','Type your comment here');
- * $I->seeInField('form textarea[name=body]','Type your comment here');
- * $I->seeInField('form input[type=hidden]','hidden_value');
- * $I->seeInField('#searchform input','Search');
- * $I->seeInField('//form/*[@name=search]','Search');
- * $I->seeInField(['name' => 'search'], 'Search');
- * ```
- *
- * @param string|array $field
- * @see \Codeception\Lib\InnerBrowser::seeInField()
- */
- public function canSeeInField($field, $value): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that an input field or textarea doesn't contain the given value.
- * For fuzzy locators, the field is matched by label text, CSS and XPath.
- *
- * ```php
- * dontSeeInField('Body','Type your comment here');
- * $I->dontSeeInField('form textarea[name=body]','Type your comment here');
- * $I->dontSeeInField('form input[type=hidden]','hidden_value');
- * $I->dontSeeInField('#searchform input','Search');
- * $I->dontSeeInField('//form/*[@name=search]','Search');
- * $I->dontSeeInField(['name' => 'search'], 'Search');
- * ```
- * @param string|array $field
- * @see \Codeception\Lib\InnerBrowser::dontSeeInField()
- */
- public function dontSeeInField($field, $value): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeInField', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that an input field or textarea doesn't contain the given value.
- * For fuzzy locators, the field is matched by label text, CSS and XPath.
- *
- * ```php
- * dontSeeInField('Body','Type your comment here');
- * $I->dontSeeInField('form textarea[name=body]','Type your comment here');
- * $I->dontSeeInField('form input[type=hidden]','hidden_value');
- * $I->dontSeeInField('#searchform input','Search');
- * $I->dontSeeInField('//form/*[@name=search]','Search');
- * $I->dontSeeInField(['name' => 'search'], 'Search');
- * ```
- * @param string|array $field
- * @see \Codeception\Lib\InnerBrowser::dontSeeInField()
- */
- public function cantSeeInField($field, $value): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks if the array of form parameters (name => value) are set on the form matched with the
- * passed selector.
- *
- * ```php
- * seeInFormFields('form[name=myform]', [
- * 'input1' => 'value',
- * 'input2' => 'other value',
- * ]);
- * ```
- *
- * For multi-select elements, or to check values of multiple elements with the same name, an
- * array may be passed:
- *
- * ```php
- * seeInFormFields('.form-class', [
- * 'multiselect' => [
- * 'value1',
- * 'value2',
- * ],
- * 'checkbox[]' => [
- * 'a checked value',
- * 'another checked value',
- * ],
- * ]);
- * ```
- *
- * Additionally, checkbox values can be checked with a boolean.
- *
- * ```php
- * seeInFormFields('#form-id', [
- * 'checkbox1' => true, // passes if checked
- * 'checkbox2' => false, // passes if unchecked
- * ]);
- * ```
- *
- * Pair this with submitForm for quick testing magic.
- *
- * ```php
- * 'value',
- * 'field2' => 'another value',
- * 'checkbox1' => true,
- * // ...
- * ];
- * $I->submitForm('//form[@id=my-form]', string $form, 'submitButton');
- * // $I->amOnPage('/path/to/form-page') may be needed
- * $I->seeInFormFields('//form[@id=my-form]', string $form);
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeInFormFields()
- */
- public function seeInFormFields($formSelector, array $params): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks if the array of form parameters (name => value) are set on the form matched with the
- * passed selector.
- *
- * ```php
- * seeInFormFields('form[name=myform]', [
- * 'input1' => 'value',
- * 'input2' => 'other value',
- * ]);
- * ```
- *
- * For multi-select elements, or to check values of multiple elements with the same name, an
- * array may be passed:
- *
- * ```php
- * seeInFormFields('.form-class', [
- * 'multiselect' => [
- * 'value1',
- * 'value2',
- * ],
- * 'checkbox[]' => [
- * 'a checked value',
- * 'another checked value',
- * ],
- * ]);
- * ```
- *
- * Additionally, checkbox values can be checked with a boolean.
- *
- * ```php
- * seeInFormFields('#form-id', [
- * 'checkbox1' => true, // passes if checked
- * 'checkbox2' => false, // passes if unchecked
- * ]);
- * ```
- *
- * Pair this with submitForm for quick testing magic.
- *
- * ```php
- * 'value',
- * 'field2' => 'another value',
- * 'checkbox1' => true,
- * // ...
- * ];
- * $I->submitForm('//form[@id=my-form]', string $form, 'submitButton');
- * // $I->amOnPage('/path/to/form-page') may be needed
- * $I->seeInFormFields('//form[@id=my-form]', string $form);
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeInFormFields()
- */
- public function canSeeInFormFields($formSelector, array $params): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks if the array of form parameters (name => value) are not set on the form matched with
- * the passed selector.
- *
- * ```php
- * dontSeeInFormFields('form[name=myform]', [
- * 'input1' => 'non-existent value',
- * 'input2' => 'other non-existent value',
- * ]);
- * ```
- *
- * To check that an element hasn't been assigned any one of many values, an array can be passed
- * as the value:
- *
- * ```php
- * dontSeeInFormFields('.form-class', [
- * 'fieldName' => [
- * 'This value shouldn\'t be set',
- * 'And this value shouldn\'t be set',
- * ],
- * ]);
- * ```
- *
- * Additionally, checkbox values can be checked with a boolean.
- *
- * ```php
- * dontSeeInFormFields('#form-id', [
- * 'checkbox1' => true, // fails if checked
- * 'checkbox2' => false, // fails if unchecked
- * ]);
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields()
- */
- public function dontSeeInFormFields($formSelector, array $params): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeInFormFields', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks if the array of form parameters (name => value) are not set on the form matched with
- * the passed selector.
- *
- * ```php
- * dontSeeInFormFields('form[name=myform]', [
- * 'input1' => 'non-existent value',
- * 'input2' => 'other non-existent value',
- * ]);
- * ```
- *
- * To check that an element hasn't been assigned any one of many values, an array can be passed
- * as the value:
- *
- * ```php
- * dontSeeInFormFields('.form-class', [
- * 'fieldName' => [
- * 'This value shouldn\'t be set',
- * 'And this value shouldn\'t be set',
- * ],
- * ]);
- * ```
- *
- * Additionally, checkbox values can be checked with a boolean.
- *
- * ```php
- * dontSeeInFormFields('#form-id', [
- * 'checkbox1' => true, // fails if checked
- * 'checkbox2' => false, // fails if unchecked
- * ]);
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields()
- */
- public function cantSeeInFormFields($formSelector, array $params): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Submits the given form on the page, with the given form
- * values. Pass the form field's values as an array in the second
- * parameter.
- *
- * Although this function can be used as a short-hand version of
- * `fillField()`, `selectOption()`, `click()` etc. it has some important
- * differences:
- *
- * * Only field *names* may be used, not CSS/XPath selectors nor field labels
- * * If a field is sent to this function that does *not* exist on the page,
- * it will silently be added to the HTTP request. This is helpful for testing
- * some types of forms, but be aware that you will *not* get an exception
- * like you would if you called `fillField()` or `selectOption()` with
- * a missing field.
- *
- * Fields that are not provided will be filled by their values from the page,
- * or from any previous calls to `fillField()`, `selectOption()` etc.
- * You don't need to click the 'Submit' button afterwards.
- * This command itself triggers the request to form's action.
- *
- * You can optionally specify which button's value to include
- * in the request with the last parameter (as an alternative to
- * explicitly setting its value in the second parameter), as
- * button values are not otherwise included in the request.
- *
- * Examples:
- *
- * ```php
- * submitForm('#login', [
- * 'login' => 'davert',
- * 'password' => '123456'
- * ]);
- * // or
- * $I->submitForm('#login', [
- * 'login' => 'davert',
- * 'password' => '123456'
- * ], 'submitButtonName');
- *
- * ```
- *
- * For example, given this sample "Sign Up" form:
- *
- * ``` html
- *
- * ```
- *
- * You could write the following to submit it:
- *
- * ```php
- * submitForm(
- * '#userForm',
- * [
- * 'user' => [
- * 'login' => 'Davert',
- * 'password' => '123456',
- * 'agree' => true
- * ]
- * ],
- * 'submitButton'
- * );
- * ```
- * Note that "2" will be the submitted value for the "plan" field, as it is
- * the selected option.
- *
- * To uncheck the pre-checked checkbox "newsletter", call `$I->uncheckOption(['name' => 'user[newsletter]']);` *before*,
- * then submit the form as shown here (i.e. without the "newsletter" field in the `$params` array).
- *
- * You can also emulate a JavaScript submission by not specifying any
- * buttons in the third parameter to submitForm.
- *
- * ```php
- * submitForm(
- * '#userForm',
- * [
- * 'user' => [
- * 'login' => 'Davert',
- * 'password' => '123456',
- * 'agree' => true
- * ]
- * ]
- * );
- * ```
- *
- * This function works well when paired with `seeInFormFields()`
- * for quickly testing CRUD interfaces and form validation logic.
- *
- * ```php
- * 'value',
- * 'field2' => 'another value',
- * 'checkbox1' => true,
- * // ...
- * ];
- * $I->submitForm('#my-form', $form, 'submitButton');
- * // $I->amOnPage('/path/to/form-page') may be needed
- * $I->seeInFormFields('#my-form', $form);
- * ```
- *
- * Parameter values can be set to arrays for multiple input fields
- * of the same name, or multi-select combo boxes. For checkboxes,
- * you can use either the string value or boolean `true`/`false` which will
- * be replaced by the checkbox's value in the DOM.
- *
- * ```php
- * submitForm('#my-form', [
- * 'field1' => 'value',
- * 'checkbox' => [
- * 'value of first checkbox',
- * 'value of second checkbox',
- * ],
- * 'otherCheckboxes' => [
- * true,
- * false,
- * false
- * ],
- * 'multiselect' => [
- * 'first option value',
- * 'second option value'
- * ]
- * ]);
- * ```
- *
- * Mixing string and boolean values for a checkbox's value is not supported
- * and may produce unexpected results.
- *
- * Field names ending in `[]` must be passed without the trailing square
- * bracket characters, and must contain an array for its value. This allows
- * submitting multiple values with the same name, consider:
- *
- * ```php
- * submitForm('#my-form', [
- * 'field[]' => 'value',
- * 'field[]' => 'another value', // 'field[]' is already a defined key
- * ]);
- * ```
- *
- * The solution is to pass an array value:
- *
- * ```php
- * submitForm('#my-form', [
- * 'field' => [
- * 'value',
- * 'another value',
- * ]
- * ]);
- * ```
- * @see \Codeception\Lib\InnerBrowser::submitForm()
- */
- public function submitForm($selector, array $params, ?string $button = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Fills a text field or textarea with the given string.
- *
- * ```php
- * fillField("//input[@type='text']", "Hello World!");
- * $I->fillField(['name' => 'email'], 'jon@example.com');
- * ```
- * @see \Codeception\Lib\InnerBrowser::fillField()
- */
- public function fillField($field, $value): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Selects an option in a select tag or in radio button group.
- *
- * ```php
- * selectOption('form select[name=account]', 'Premium');
- * $I->selectOption('form input[name=payment]', 'Monthly');
- * $I->selectOption('//form/select[@name=account]', 'Monthly');
- * ```
- *
- * Provide an array for the second argument to select multiple options:
- *
- * ```php
- * selectOption('Which OS do you use?', ['Windows', 'Linux']);
- * ```
- *
- * Or provide an associative array for the second argument to specifically define which selection method should be used:
- *
- * ```php
- * selectOption('Which OS do you use?', ['text' => 'Windows']); // Only search by text 'Windows'
- * $I->selectOption('Which OS do you use?', ['value' => 'windows']); // Only search by value 'windows'
- * ```
- * @see \Codeception\Lib\InnerBrowser::selectOption()
- */
- public function selectOption($select, $option): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Ticks a checkbox. For radio buttons, use the `selectOption` method instead.
- *
- * ```php
- * checkOption('#agree');
- * ```
- * @see \Codeception\Lib\InnerBrowser::checkOption()
- */
- public function checkOption($option): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Unticks a checkbox.
- *
- * ```php
- * uncheckOption('#notify');
- * ```
- * @see \Codeception\Lib\InnerBrowser::uncheckOption()
- */
- public function uncheckOption($option): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Attaches a file relative to the Codeception `_data` directory to the given file upload field.
- *
- * ```php
- * attachFile('input[@type="file"]', 'prices.xls');
- * ```
- * @see \Codeception\Lib\InnerBrowser::attachFile()
- */
- public function attachFile($field, string $filename): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Sends an ajax GET request with the passed parameters.
- * See `sendAjaxPostRequest()`
- * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest()
- */
- public function sendAjaxGetRequest(string $uri, array $params = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Sends an ajax POST request with the passed parameters.
- * The appropriate HTTP header is added automatically:
- * `X-Requested-With: XMLHttpRequest`
- * Example:
- * ``` php
- * sendAjaxPostRequest('/add-task', ['task' => 'lorem ipsum']);
- * ```
- * Some frameworks (e.g. Symfony) create field names in the form of an "array":
- * ``
- * In this case you need to pass the fields like this:
- * ``` php
- * sendAjaxPostRequest('/add-task', ['form' => [
- * 'task' => 'lorem ipsum',
- * 'category' => 'miscellaneous',
- * ]]);
- * ```
- * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest()
- */
- public function sendAjaxPostRequest(string $uri, array $params = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Sends an ajax request, using the passed HTTP method.
- * See `sendAjaxPostRequest()`
- * Example:
- * ``` php
- * sendAjaxRequest('PUT', '/posts/7', ['title' => 'new title']);
- * ```
- * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest()
- */
- public function sendAjaxRequest(string $method, string $uri, array $params = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Use this method within an [interactive pause](https://codeception.com/docs/02-GettingStarted#Interactive-Pause) to save the HTML source code of the current page.
- *
- * ```php
- * makeHtmlSnapshot('edit_page');
- * // saved to: tests/_output/debug/edit_page.html
- * $I->makeHtmlSnapshot();
- * // saved to: tests/_output/debug/2017-05-26_14-24-11_4b3403665fea6.html
- * ```
- * @see \Codeception\Lib\InnerBrowser::makeHtmlSnapshot()
- */
- public function makeHtmlSnapshot(?string $name = NULL): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('makeHtmlSnapshot', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Finds and returns the text contents of the given element.
- * If a fuzzy locator is used, the element is found using CSS, XPath,
- * and by matching the full page source by regular expression.
- *
- * ```php
- * grabTextFrom('h1');
- * $heading = $I->grabTextFrom('descendant-or-self::h1');
- * $value = $I->grabTextFrom('~getScenario()->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Returns the value of the given attribute value from the given HTML element. For some attributes, the string `true` is returned instead of their literal value (e.g. `disabled="disabled"` or `required="required"`).
- * Fails if the element is not found. Returns `null` if the attribute is not present on the element.
- *
- * ```php
- * grabAttributeFrom('#tooltip', 'title');
- * ```
- * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom()
- */
- public function grabAttributeFrom($cssOrXpath, string $attribute): mixed {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Grabs either the text content, or attribute values, of nodes
- * matched by $cssOrXpath and returns them as an array.
- *
- * ```html
- * First
- * Second
- * Third
- * ```
- *
- * ```php
- * grabMultiple('a');
- *
- * // would return ['#first', '#second', '#third']
- * $aLinks = $I->grabMultiple('a', 'href');
- * ```
- *
- * @return string[]
- * @see \Codeception\Lib\InnerBrowser::grabMultiple()
- */
- public function grabMultiple($cssOrXpath, ?string $attribute = NULL): array {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabMultiple', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Finds the value for the given form field.
- * If a fuzzy locator is used, the field is found by field name, CSS, and XPath.
- *
- * ```php
- * grabValueFrom('Name');
- * $name = $I->grabValueFrom('input[name=username]');
- * $name = $I->grabValueFrom('descendant-or-self::form/descendant::input[@name = 'username']');
- * $name = $I->grabValueFrom(['name' => 'username']);
- * ```
- * @see \Codeception\Lib\InnerBrowser::grabValueFrom()
- */
- public function grabValueFrom($field): mixed {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Grabs a cookie value.
- * You can set additional cookie params like `domain`, `path` in array passed as last argument.
- * If the cookie is set by an ajax request (XMLHttpRequest), there might be some delay caused by the browser, so try `$I->wait(0.1)`.
- * @see \Codeception\Lib\InnerBrowser::grabCookie()
- */
- public function grabCookie(string $cookie, array $params = []): mixed {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabCookie', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Grabs current page source code.
- *
- * @throws \Codeception\Exception\ModuleException if no page was opened.
- * @return string Current page source code.
- * @see \Codeception\Lib\InnerBrowser::grabPageSource()
- */
- public function grabPageSource(): string {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('grabPageSource', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that a cookie with the given name is set.
- * You can set additional cookie params like `domain`, `path` as array passed in last argument.
- *
- * ```php
- * seeCookie('PHPSESSID');
- * ```
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::seeCookie()
- */
- public function seeCookie($cookie, $params = []) {
- return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that a cookie with the given name is set.
- * You can set additional cookie params like `domain`, `path` as array passed in last argument.
- *
- * ```php
- * seeCookie('PHPSESSID');
- * ```
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::seeCookie()
- */
- public function canSeeCookie($cookie, $params = []) {
- return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that there isn't a cookie with the given name.
- * You can set additional cookie params like `domain`, `path` as array passed in last argument.
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::dontSeeCookie()
- */
- public function dontSeeCookie($cookie, $params = []) {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeCookie', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that there isn't a cookie with the given name.
- * You can set additional cookie params like `domain`, `path` as array passed in last argument.
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::dontSeeCookie()
- */
- public function cantSeeCookie($cookie, $params = []) {
- return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Unsets cookie with the given name.
- * You can set additional cookie params like `domain`, `path` in array passed as last argument.
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::resetCookie()
- */
- public function resetCookie($cookie, $params = []) {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the given element exists on the page and is visible.
- * You can also specify expected attributes of this element.
- * Only works if `` tag is present.
- *
- * ```php
- * seeElement('.error');
- * $I->seeElement('//form/input[1]');
- * $I->seeElement('input', ['name' => 'login']);
- * $I->seeElement('input', ['value' => '123456']);
- *
- * // strict locator in first arg, attributes in second
- * $I->seeElement(['css' => 'form input'], ['name' => 'login']);
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeElement()
- */
- public function seeElement($selector, array $attributes = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the given element exists on the page and is visible.
- * You can also specify expected attributes of this element.
- * Only works if `` tag is present.
- *
- * ```php
- * seeElement('.error');
- * $I->seeElement('//form/input[1]');
- * $I->seeElement('input', ['name' => 'login']);
- * $I->seeElement('input', ['value' => '123456']);
- *
- * // strict locator in first arg, attributes in second
- * $I->seeElement(['css' => 'form input'], ['name' => 'login']);
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeElement()
- */
- public function canSeeElement($selector, array $attributes = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the given element is invisible or not present on the page.
- * You can also specify expected attributes of this element.
- *
- * ```php
- * dontSeeElement('.error');
- * $I->dontSeeElement('//form/input[1]');
- * $I->dontSeeElement('input', ['name' => 'login']);
- * $I->dontSeeElement('input', ['value' => '123456']);
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeElement()
- */
- public function dontSeeElement($selector, array $attributes = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeElement', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the given element is invisible or not present on the page.
- * You can also specify expected attributes of this element.
- *
- * ```php
- * dontSeeElement('.error');
- * $I->dontSeeElement('//form/input[1]');
- * $I->dontSeeElement('input', ['name' => 'login']);
- * $I->dontSeeElement('input', ['value' => '123456']);
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeElement()
- */
- public function cantSeeElement($selector, array $attributes = []): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that there are a certain number of elements matched by the given locator on the page.
- *
- * ```php
- * seeNumberOfElements('tr', 10);
- * $I->seeNumberOfElements('tr', [0,10]); // between 0 and 10 elements
- * ```
- *
- * @param int|int[] $expected
- * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements()
- */
- public function seeNumberOfElements($selector, $expected): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that there are a certain number of elements matched by the given locator on the page.
- *
- * ```php
- * seeNumberOfElements('tr', 10);
- * $I->seeNumberOfElements('tr', [0,10]); // between 0 and 10 elements
- * ```
- *
- * @param int|int[] $expected
- * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements()
- */
- public function canSeeNumberOfElements($selector, $expected): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the given option is selected.
- *
- * ```php
- * seeOptionIsSelected('#form input[name=payment]', 'Visa');
- * ```
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected()
- */
- public function seeOptionIsSelected($selector, $optionText) {
- return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the given option is selected.
- *
- * ```php
- * seeOptionIsSelected('#form input[name=payment]', 'Visa');
- * ```
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected()
- */
- public function canSeeOptionIsSelected($selector, $optionText) {
- return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the given option is not selected.
- *
- * ```php
- * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa');
- * ```
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected()
- */
- public function dontSeeOptionIsSelected($selector, $optionText) {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeOptionIsSelected', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the given option is not selected.
- *
- * ```php
- * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa');
- * ```
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected()
- */
- public function cantSeeOptionIsSelected($selector, $optionText) {
- return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Asserts that current page has 404 response status code.
- * @see \Codeception\Lib\InnerBrowser::seePageNotFound()
- */
- public function seePageNotFound(): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Asserts that current page has 404 response status code.
- * @see \Codeception\Lib\InnerBrowser::seePageNotFound()
- */
- public function canSeePageNotFound(): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that response code is equal to value provided.
- *
- * ```php
- * seeResponseCodeIs(200);
- *
- * // recommended \Codeception\Util\HttpCode
- * $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs()
- */
- public function seeResponseCodeIs(int $code): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that response code is equal to value provided.
- *
- * ```php
- * seeResponseCodeIs(200);
- *
- * // recommended \Codeception\Util\HttpCode
- * $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
- * ```
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs()
- */
- public function canSeeResponseCodeIs(int $code): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that response code is between a certain range. Between actually means [from <= CODE <= to]
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIsBetween()
- */
- public function seeResponseCodeIsBetween(int $from, int $to): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIsBetween', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that response code is between a certain range. Between actually means [from <= CODE <= to]
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIsBetween()
- */
- public function canSeeResponseCodeIsBetween(int $from, int $to): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIsBetween', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that response code is equal to value provided.
- *
- * ```php
- * dontSeeResponseCodeIs(200);
- *
- * // recommended \Codeception\Util\HttpCode
- * $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK);
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeResponseCodeIs()
- */
- public function dontSeeResponseCodeIs(int $code): void {
- $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeResponseCodeIs', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that response code is equal to value provided.
- *
- * ```php
- * dontSeeResponseCodeIs(200);
- *
- * // recommended \Codeception\Util\HttpCode
- * $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK);
- * ```
- * @see \Codeception\Lib\InnerBrowser::dontSeeResponseCodeIs()
- */
- public function cantSeeResponseCodeIs(int $code): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeResponseCodeIs', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the response code 2xx
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIsSuccessful()
- */
- public function seeResponseCodeIsSuccessful(): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIsSuccessful', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the response code 2xx
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIsSuccessful()
- */
- public function canSeeResponseCodeIsSuccessful(): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIsSuccessful', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the response code 3xx
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIsRedirection()
- */
- public function seeResponseCodeIsRedirection(): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIsRedirection', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the response code 3xx
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIsRedirection()
- */
- public function canSeeResponseCodeIsRedirection(): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIsRedirection', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the response code is 4xx
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIsClientError()
- */
- public function seeResponseCodeIsClientError(): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIsClientError', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the response code is 4xx
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIsClientError()
- */
- public function canSeeResponseCodeIsClientError(): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIsClientError', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the response code is 5xx
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIsServerError()
- */
- public function seeResponseCodeIsServerError(): void {
- $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIsServerError', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the response code is 5xx
- * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIsServerError()
- */
- public function canSeeResponseCodeIsServerError(): void {
- $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIsServerError', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the page title contains the given string.
- *
- * ```php
- * seeInTitle('Blog - Post #1');
- * ```
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::seeInTitle()
- */
- public function seeInTitle($title) {
- return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the page title contains the given string.
- *
- * ```php
- * seeInTitle('Blog - Post #1');
- * ```
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::seeInTitle()
- */
- public function canSeeInTitle($title) {
- return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Checks that the page title does not contain the given string.
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle()
- */
- public function dontSeeInTitle($title) {
- return $this->getScenario()->runStep(new \Codeception\Step\Action('dontSeeInTitle', func_get_args()));
- }
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * [!] Conditional Assertion: Test won't be stopped on fail
- * Checks that the page title does not contain the given string.
- *
- * @return mixed|void
- * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle()
- */
- public function cantSeeInTitle($title) {
- return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args()));
- }
-
-
- /**
- * [!] Method is generated. Documentation taken from corresponding module.
- *
- * Switch to iframe or frame on the page.
- *
- * Example:
- * ``` html
- *