Beispiel #1
0
 public function testGroup(FunctionalTester $I)
 {
     $I->wantTo('ensure that setting works');
     $I->amOnPage(Url::to(['/setting/group', 'id' => 'general']));
     $I->see('General Settings', 'h1');
     $I->amGoingTo('update site title and tag line');
     $I->fillField('input[name="Option[sitetitle][option_value]"]', 'My New Website');
     $I->fillField('input[name="Option[tagline][option_value]"]', 'My New Website Tagline');
     $I->click('Save');
     $I->expectTo('see success message');
     $I->see('Settings successfully saved.');
     Option::up('sitetitle', 'WritesDown');
     Option::up('tagline', 'CMS Built with Yii Framework');
 }
Beispiel #2
0
 /**
  * @param AcceptanceTester $I
  */
 public function testIndex(AcceptanceTester $I)
 {
     $I->wantTo('ensure that index theme works');
     $I->amOnPage(Url::to(['/theme/index']));
     $I->see('Themes', 'h1');
     $I->seeLink('Available Themes');
     $I->seeLink('Add New Theme');
     if (method_exists($I, 'acceptPopup') && method_exists($I, 'wait')) {
         $I->amGoingTo('activate theme');
         $I->click('a[href="' . Url::to(['/theme/install', 'theme' => 'writesdown']) . '"]');
         $I->acceptPopup();
         $I->wait(3);
         $I->expectTo('see theme installed');
         $I->see('Installed');
         Option::up('theme', 'default');
     }
 }
Beispiel #3
0
 /**
  * @param AcceptanceTester $I
  */
 public function testSignup(AcceptanceTester $I)
 {
     Option::up('allow_signup', '1');
     $I->wantTo('ensure that signup works');
     $signupPage = SignupPage::openBy($I);
     $I->see('Register a new membership', 'p');
     $I->amGoingTo('submit signup form with no data');
     $signupPage->submit([]);
     $I->expectTo('see validations error');
     $I->see('Username cannot be blank.', '.help-block');
     $I->see('Email cannot be blank.', '.help-block');
     $I->see('Password cannot be blank.', '.help-block');
     $I->amGoingTo('submit signup form with no correct email and password');
     $signupPage->submit(['username' => 'newuser', 'email' => 'newuser.email', 'password' => 'pass']);
     $I->expectTo('see that email and password are not correct.');
     $I->dontSee('Username cannot be blank.', '.help-block');
     $I->see('Email is not a valid email address.', '.help-block');
     $I->see('Password should contain at least 6 characters.', '.help-block');
     $I->amGoingTo('submit signup form with correct data');
     $signupPage->submit(['username' => 'newuser', 'email' => '*****@*****.**', 'password' => 'password']);
     $I->expect('new user saved.');
     $I->dontSee('Username cannot be blank.', '.help-block');
     $I->dontSee('Email is not a valid email address.', '.help-block');
     $I->dontSee('Password should contain at least 6 characters.', '.help-block');
     User::deleteAll(['username' => 'newuser']);
     Option::up('allow_signup', '0');
 }
Beispiel #4
0
 /**
  * Render option page for specific group of option.
  * It will use group file if exist.
  *
  * @param string $id
  *
  * @return mixed
  */
 public function actionGroup($id)
 {
     $model = $this->findModelByGroup($id);
     if ($options = Yii::$app->request->post('Option')) {
         foreach ($options as $optionName => $option) {
             Option::up($optionName, $option['option_value']);
         }
         Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', 'Settings successfully saved.'));
         return $this->redirect(['group', 'id' => $id]);
     }
     if (is_file($this->getViewPath() . '/' . strtolower($id) . '.php')) {
         return $this->render(strtolower($id), ['model' => (object) $model, 'group' => $id]);
     }
     return $this->redirect(['index']);
 }
Beispiel #5
0
 /**
  * Render option page for specific group of option.
  * It will use group file if exist.
  *
  * @param string $id group name
  *
  * @return string|\yii\web\Response
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionGroup($id)
 {
     $model = Option::find()->where(['option_group' => $id])->indexBy('option_name')->all();
     if ($options = Yii::$app->request->post('Option')) {
         foreach ($options as $option_name => $option) {
             Option::up($option_name, $option['option_value']);
         }
         Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', 'Settings successfully saved.'));
         return $this->redirect(['group', 'id' => $id]);
     }
     if ($model) {
         if (is_file($viewFile = $this->getViewPath() . '/' . strtolower($id) . '.php')) {
             return $this->render(strtolower($id), ['model' => (object) $model, 'group' => $id]);
         } else {
             return $this->redirect(['index']);
         }
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }