diff --git a/.gitignore b/.gitignore
index 5ac7134..06abf75 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/tests
/frontend/web/js/Validation.ts
/frontend/web/js/typescript.ts
/node_modules
diff --git a/codeception.yml b/codeception.yml
index 3a8fca8..5e0f37d 100644
--- a/codeception.yml
+++ b/codeception.yml
@@ -7,7 +7,7 @@ paths:
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
- colors: true
+ colors: false
memory_limit: 1024M
extensions:
enabled:
diff --git a/common/behaviors/MapsBehavior.php b/common/behaviors/MapsBehavior.php
new file mode 100644
index 0000000..aeb3924
--- /dev/null
+++ b/common/behaviors/MapsBehavior.php
@@ -0,0 +1,78 @@
+ 'beforeSave',
+ ActiveRecord::EVENT_BEFORE_UPDATE => 'beforeSave',
+ ];
+ }
+
+ /**
+ * After saving model get latitude (lat) and longitude (lng) from Google Map Api and insert
+ * to the database
+ *
+ * @param Event $event
+ *
+ * @return bool
+ * @throws ErrorException
+ */
+ public function beforeSave($event)
+ {
+ /**
+ * @var ActiveRecord $owner
+ */
+ $owner = $this->owner;
+ foreach($this->required_attributes as $required_attribute) {
+ if(empty( $owner->$required_attribute )) {
+ return true;
+ }
+ }
+ $location = '';
+ $first = true;
+ foreach($this->location_attributes as $location_attribute) {
+ if(!$first) {
+ $location .= '+';
+ }
+ $location .= $owner->$location_attribute;
+ $first = false;
+ }
+ $location = Html::encode($location);
+ $ch = curl_init();
+ if(!$ch) {
+ throw new ErrorException('Curl error');
+ }
+ curl_setopt($ch, CURLOPT_URL, "https://maps.googleapis.com/maps/api/geocode/json?address=" . $location);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ $result = json_decode(curl_exec($ch));
+ curl_close($ch);
+ if(!empty($result->results)) {
+ $owner->lat = $result->results[0]->geometry->location->lat;
+ $owner->lng = $result->results[0]->geometry->location->lng;
+ }
+ return true;
+ }
+ }
\ No newline at end of file
diff --git a/common/models/Project.php b/common/models/Project.php
index 29b230e..b08e196 100644
--- a/common/models/Project.php
+++ b/common/models/Project.php
@@ -2,6 +2,7 @@
namespace common\models;
+ use common\behaviors\MapsBehavior;
use common\modules\comment\models\CommentProject;
use common\modules\fileloader\behaviors\FileloaderBehavior;
use Yii;
@@ -76,6 +77,17 @@
'fileloader' => [
'class' => FileloaderBehavior::className(),
],
+ 'maps' => [
+ 'class' => MapsBehavior::className(),
+ 'location_attributes' => [
+ 'city',
+ 'street',
+ 'house',
+ ],
+ 'required_attributes' => [
+ 'city',
+ ],
+ ],
];
}
@@ -160,7 +172,11 @@
'boolean',
],
[
- [ 'hidden', 'budget', 'total_budget' ],
+ [
+ 'hidden',
+ 'budget',
+ 'total_budget',
+ ],
'default',
'value' => 0,
],
diff --git a/console/migrations/m160504_145135_add_coordinates_columns_to_project_and_portfolio.php b/console/migrations/m160504_145135_add_coordinates_columns_to_project_and_portfolio.php
new file mode 100644
index 0000000..c3c4342
--- /dev/null
+++ b/console/migrations/m160504_145135_add_coordinates_columns_to_project_and_portfolio.php
@@ -0,0 +1,31 @@
+addColumn('{{%project}}', 'lat', $this->string());
+ $this->addColumn('{{%project}}', 'lng', $this->string());
+ $this->addColumn('{{%portfolio}}', 'lat', $this->string());
+ $this->addColumn('{{%portfolio}}', 'lng', $this->string());
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function down()
+ {
+ $this->dropColumn('{{%project}}', 'lat');
+ $this->dropColumn('{{%project}}', 'lng');
+ $this->dropColumn('{{%portfolio}}', 'lat');
+ $this->dropColumn('{{%portfolio}}', 'lng');
+ }
+}
diff --git a/frontend/views/performer/portfolio-view.php b/frontend/views/performer/portfolio-view.php
index 3a645d8..a37ba95 100644
--- a/frontend/views/performer/portfolio-view.php
+++ b/frontend/views/performer/portfolio-view.php
@@ -120,7 +120,7 @@
ShowGallery($portfolio->gallery->photo) as $one_photo) {
?>
-
+
diff --git a/frontend/views/site/index.php b/frontend/views/site/index.php
index 2953c56..be7b7a9 100755
--- a/frontend/views/site/index.php
+++ b/frontend/views/site/index.php
@@ -10,6 +10,26 @@
$this->title = 'My Yii Application';
?>
+
+
+
+
+
+ */
+ ?>
@@ -97,121 +117,121 @@
diff --git a/tests/README.md b/tests/README.md
deleted file mode 100755
index ad7f016..0000000
--- a/tests/README.md
+++ /dev/null
@@ -1,58 +0,0 @@
-This directory contains various tests for the advanced applications.
-
-Tests in `codeception` directory are developed with [Codeception PHP Testing Framework](http://codeception.com/).
-
-After creating and setting up the advanced application, follow these steps to prepare for the tests:
-
-1. Install Codeception if it's not yet installed:
-
- ```
- composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*"
- ```
-
- If you've never used Composer for global packages run `composer global status`. It should output:
-
- ```
- Changed current directory to
- ```
-
- Then add `/vendor/bin` to you `PATH` environment variable. Now you're able to use `codecept` from command
- line globally.
-
-2. Install faker extension by running the following from template root directory where `composer.json` is:
-
- ```
- composer require --dev yiisoft/yii2-faker:*
- ```
-
-3. Create `yii2_advanced_tests` database then update it by applying migrations:
-
- ```
- codeception/bin/yii migrate
- ```
-
-4. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in
- webserver. In the root directory where `common`, `frontend` etc. are execute the following:
-
- ```
- php -S localhost:8080
- ```
-
-5. Now you can run the tests with the following commands, assuming you are in the `tests/codeception` directory:
-
- ```
- # frontend tests
- cd frontend
- codecept build
- codecept run
-
- # backend tests
-
- cd backend
- codecept build
- codecept run
-
- # etc.
- ```
-
- If you already have run `codecept build` for each application, you can skip that step and run all tests by a single `codecept run`.
diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php
index db43290..243f9c8 100644
--- a/tests/_bootstrap.php
+++ b/tests/_bootstrap.php
@@ -1,19 +1,2 @@
amOnPage('site/signup');
- }
-
- public function imagineCustomer(){
- $fake = \Faker\Factory::create();
- return [
- 'SignupForm[username]' => $fake->name,
- 'SignupForm[email]' => $fake->email,
- 'SignupForm[password]' => $fake->password(19),
- ];
-
- }
-
- public function fillCustomerDataForm($fieldData){
- $I = $this;
- foreach ($fieldData as $key=>$value) {
- $I->fillField($key,$value);
- }
-
- }
-
- public function submitCustomerDataForm(){
- $I = $this;
- $I->click('signup-button');
- }
-
-
-
-}
\ No newline at end of file
diff --git a/tests/_support/UnitTester.php b/tests/_support/UnitTester.php
index 68c09cf..2835357 100644
--- a/tests/_support/UnitTester.php
+++ b/tests/_support/UnitTester.php
@@ -12,7 +12,7 @@
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
- * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
+ * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
diff --git a/tests/_support/_generated/AcceptanceTesterActions.php b/tests/_support/_generated/AcceptanceTesterActions.php
index 90a76e6..69ab371 100644
--- a/tests/_support/_generated/AcceptanceTesterActions.php
+++ b/tests/_support/_generated/AcceptanceTesterActions.php
@@ -1,4 +1,4 @@
-wantTo('perform actions and see result');
-$I->amOnPage('/');
-$I->canSee('Проектантам');
-$I->click('Вход');
-$I->waitForElement('#modal_form_login', 15);
-$I->canSee('Авторизация');
-$I->fillField('#loginform-username','admin');
-$I->fillField('#loginform-password','112233');
-$I->click('.login-button');
-$I->wait(1);
-$I->canSee('admin@admin.com');
-$I->wait(1);
-$I->amOnPage('/accounts/portfolio');
-$I->wait(1);
-$I->click('Добавить');
-$I->wait(1);
-$I->attachFile('input[type="file"]', 'ViewIllustrator_2001.jpg');
-$I->fillField('#portfolio-name','');
-$I->click('Добавить', '.input-blocks-wrapper');
-$I->see('Необходимо заполнить «name».','div');
diff --git a/tests/codeception.yml b/tests/codeception.yml
deleted file mode 100755
index 1a793ed..0000000
--- a/tests/codeception.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-include:
- - codeception/common
- - codeception/console
- - codeception/backend
- - codeception/frontend
-
-paths:
- log: codeception/_output
-
-settings:
- colors: true
diff --git a/tests/codeception/_output/.gitignore b/tests/codeception/_output/.gitignore
deleted file mode 100755
index d6b7ef3..0000000
--- a/tests/codeception/_output/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!.gitignore
diff --git a/tests/codeception/backend/.gitignore b/tests/codeception/backend/.gitignore
deleted file mode 100755
index 985dbb4..0000000
--- a/tests/codeception/backend/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-# these files are auto generated by codeception build
-/unit/UnitTester.php
-/functional/FunctionalTester.php
-/acceptance/AcceptanceTester.php
diff --git a/tests/codeception/backend/_bootstrap.php b/tests/codeception/backend/_bootstrap.php
deleted file mode 100755
index a28a3d2..0000000
--- a/tests/codeception/backend/_bootstrap.php
+++ /dev/null
@@ -1,23 +0,0 @@
-wantTo('ensure login page works');
-
-$loginPage = LoginPage::openBy($I);
-
-$I->amGoingTo('submit login form with no data');
-$loginPage->login('', '');
-if (method_exists($I, 'wait')) {
- $I->wait(3); // only for selenium
-}
-$I->expectTo('see validations errors');
-$I->see('Username cannot be blank.', '.help-block');
-$I->see('Password cannot be blank.', '.help-block');
-
-$I->amGoingTo('try to login with wrong credentials');
-$I->expectTo('see validations errors');
-$loginPage->login('admin', 'wrong');
-if (method_exists($I, 'wait')) {
- $I->wait(3); // only for selenium
-}
-$I->expectTo('see validations errors');
-$I->see('Incorrect username or password.', '.help-block');
-
-$I->amGoingTo('try to login with correct credentials');
-$loginPage->login('erau', 'password_0');
-if (method_exists($I, 'wait')) {
- $I->wait(3); // only for selenium
-}
-$I->expectTo('see that user is logged');
-$I->seeLink('Logout (erau)');
-$I->dontSeeLink('Login');
-$I->dontSeeLink('Signup');
-/** Uncomment if using WebDriver
- * $I->click('Logout (erau)');
- * $I->dontSeeLink('Logout (erau)');
- * $I->seeLink('Login');
- */
diff --git a/tests/codeception/backend/acceptance/_bootstrap.php b/tests/codeception/backend/acceptance/_bootstrap.php
deleted file mode 100755
index 411855e..0000000
--- a/tests/codeception/backend/acceptance/_bootstrap.php
+++ /dev/null
@@ -1,2 +0,0 @@
-wantTo('ensure login page works');
-
-$loginPage = LoginPage::openBy($I);
-
-$I->amGoingTo('submit login form with no data');
-$loginPage->login('', '');
-$I->expectTo('see validations errors');
-$I->see('Username cannot be blank.', '.help-block');
-$I->see('Password cannot be blank.', '.help-block');
-
-$I->amGoingTo('try to login with wrong credentials');
-$I->expectTo('see validations errors');
-$loginPage->login('admin', 'wrong');
-$I->expectTo('see validations errors');
-$I->see('Incorrect username or password.', '.help-block');
-
-$I->amGoingTo('try to login with correct credentials');
-$loginPage->login('erau', 'password_0');
-$I->expectTo('see that user is logged');
-$I->seeLink('Logout (erau)');
-$I->dontSeeLink('Login');
-$I->dontSeeLink('Signup');
diff --git a/tests/codeception/backend/functional/_bootstrap.php b/tests/codeception/backend/functional/_bootstrap.php
deleted file mode 100755
index 94f3fbd..0000000
--- a/tests/codeception/backend/functional/_bootstrap.php
+++ /dev/null
@@ -1,2 +0,0 @@
-run();
-exit($exitCode);
diff --git a/tests/codeception/bin/yii.bat b/tests/codeception/bin/yii.bat
deleted file mode 100755
index d516b3a..0000000
--- a/tests/codeception/bin/yii.bat
+++ /dev/null
@@ -1,20 +0,0 @@
-@echo off
-
-rem -------------------------------------------------------------
-rem Yii command line bootstrap script for Windows.
-rem
-rem @author Qiang Xue
-rem @link http://www.yiiframework.com/
-rem @copyright Copyright (c) 2008 Yii Software LLC
-rem @license http://www.yiiframework.com/license/
-rem -------------------------------------------------------------
-
-@setlocal
-
-set YII_PATH=%~dp0
-
-if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
-
-"%PHP_COMMAND%" "%YII_PATH%yii" %*
-
-@endlocal
diff --git a/tests/codeception/common/.gitignore b/tests/codeception/common/.gitignore
deleted file mode 100755
index 985dbb4..0000000
--- a/tests/codeception/common/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-# these files are auto generated by codeception build
-/unit/UnitTester.php
-/functional/FunctionalTester.php
-/acceptance/AcceptanceTester.php
diff --git a/tests/codeception/common/_bootstrap.php b/tests/codeception/common/_bootstrap.php
deleted file mode 100755
index cea3ee5..0000000
--- a/tests/codeception/common/_bootstrap.php
+++ /dev/null
@@ -1,15 +0,0 @@
-actor->fillField('input[name="LoginForm[username]"]', $username);
- $this->actor->fillField('input[name="LoginForm[password]"]', $password);
- $this->actor->click('login-button');
- }
-}
diff --git a/tests/codeception/common/_support/FixtureHelper.php b/tests/codeception/common/_support/FixtureHelper.php
deleted file mode 100755
index c5ebcf1..0000000
--- a/tests/codeception/common/_support/FixtureHelper.php
+++ /dev/null
@@ -1,72 +0,0 @@
-loadFixtures();
- }
-
- /**
- * Method is called after all suite tests run
- */
- public function _afterSuite()
- {
- $this->unloadFixtures();
- }
-
- /**
- * @inheritdoc
- */
- public function globalFixtures()
- {
- return [
- InitDbFixture::className(),
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function fixtures()
- {
- return [
- 'user' => [
- 'class' => UserFixture::className(),
- 'dataFile' => '@tests/codeception/common/fixtures/data/init_login.php',
- ],
- ];
- }
-}
diff --git a/tests/codeception/common/codeception.yml b/tests/codeception/common/codeception.yml
deleted file mode 100755
index e8a3407..0000000
--- a/tests/codeception/common/codeception.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace: tests\codeception\common
-actor: Tester
-paths:
- tests: .
- log: _output
- data: _data
- helpers: _support
-settings:
- bootstrap: _bootstrap.php
- suite_class: \PHPUnit_Framework_TestSuite
- colors: true
- memory_limit: 1024M
- log: true
diff --git a/tests/codeception/common/fixtures/UserFixture.php b/tests/codeception/common/fixtures/UserFixture.php
deleted file mode 100755
index 7153c8c..0000000
--- a/tests/codeception/common/fixtures/UserFixture.php
+++ /dev/null
@@ -1,13 +0,0 @@
- 'erau',
- 'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI',
- // password_0
- 'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne',
- 'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490',
- 'created_at' => '1392559490',
- 'updated_at' => '1392559490',
- 'email' => 'sfriesen@jenkins.info',
- ],
-];
diff --git a/tests/codeception/common/templates/fixtures/user.php b/tests/codeception/common/templates/fixtures/user.php
deleted file mode 100755
index d3f83b5..0000000
--- a/tests/codeception/common/templates/fixtures/user.php
+++ /dev/null
@@ -1,17 +0,0 @@
-getSecurity();
-
-return [
- 'username' => $faker->userName,
- 'email' => $faker->email,
- 'auth_key' => $security->generateRandomString(),
- 'password_hash' => $security->generatePasswordHash('password_' . $index),
- 'password_reset_token' => $security->generateRandomString() . '_' . time(),
- 'created_at' => time(),
- 'updated_at' => time(),
-];
diff --git a/tests/codeception/common/unit.suite.yml b/tests/codeception/common/unit.suite.yml
deleted file mode 100755
index a0582a5..0000000
--- a/tests/codeception/common/unit.suite.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Codeception Test Suite Configuration
-
-# suite for unit (internal) tests.
-# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
-
-class_name: UnitTester
diff --git a/tests/codeception/common/unit/DbTestCase.php b/tests/codeception/common/unit/DbTestCase.php
deleted file mode 100755
index 2159a69..0000000
--- a/tests/codeception/common/unit/DbTestCase.php
+++ /dev/null
@@ -1,11 +0,0 @@
- 'bayer.hudson',
- 'auth_key' => 'HP187Mvq7Mmm3CTU80dLkGmni_FUH_lR',
- //password_0
- 'password_hash' => '$2y$13$EjaPFBnZOQsHdGuHI.xvhuDp1fHpo8hKRSk6yshqa9c5EG8s3C3lO',
- 'password_reset_token' => 'ExzkCOaYc1L8IOBs4wdTGGbgNiG3Wz1I_1402312317',
- 'created_at' => '1402312317',
- 'updated_at' => '1402312317',
- 'email' => 'nicole.paucek@schultz.info',
- ],
-];
diff --git a/tests/codeception/common/unit/models/LoginFormTest.php b/tests/codeception/common/unit/models/LoginFormTest.php
deleted file mode 100755
index 54c8209..0000000
--- a/tests/codeception/common/unit/models/LoginFormTest.php
+++ /dev/null
@@ -1,93 +0,0 @@
- [
- 'user' => [
- 'class' => 'yii\web\User',
- 'identityClass' => 'common\models\User',
- ],
- ],
- ]);
- }
-
- protected function tearDown()
- {
- Yii::$app->user->logout();
- parent::tearDown();
- }
-
- public function testLoginNoUser()
- {
- $model = new LoginForm([
- 'username' => 'not_existing_username',
- 'password' => 'not_existing_password',
- ]);
-
- $this->specify('user should not be able to login, when there is no identity', function () use ($model) {
- expect('model should not login user', $model->login())->false();
- expect('user should not be logged in', Yii::$app->user->isGuest)->true();
- });
- }
-
- public function testLoginWrongPassword()
- {
- $model = new LoginForm([
- 'username' => 'bayer.hudson',
- 'password' => 'wrong_password',
- ]);
-
- $this->specify('user should not be able to login with wrong password', function () use ($model) {
- expect('model should not login user', $model->login())->false();
- expect('error message should be set', $model->errors)->hasKey('password');
- expect('user should not be logged in', Yii::$app->user->isGuest)->true();
- });
- }
-
- public function testLoginCorrect()
- {
-
- $model = new LoginForm([
- 'username' => 'bayer.hudson',
- 'password' => 'password_0',
- ]);
-
- $this->specify('user should be able to login with correct credentials', function () use ($model) {
- expect('model should login user', $model->login())->true();
- expect('error message should not be set', $model->errors)->hasntKey('password');
- expect('user should be logged in', Yii::$app->user->isGuest)->false();
- });
- }
-
- /**
- * @inheritdoc
- */
- public function fixtures()
- {
- return [
- 'user' => [
- 'class' => UserFixture::className(),
- 'dataFile' => '@tests/codeception/common/unit/fixtures/data/models/user.php'
- ],
- ];
- }
-}
diff --git a/tests/codeception/config/acceptance.php b/tests/codeception/config/acceptance.php
deleted file mode 100755
index 9318da5..0000000
--- a/tests/codeception/config/acceptance.php
+++ /dev/null
@@ -1,7 +0,0 @@
- 'app-common',
- 'basePath' => dirname(__DIR__),
- ]
-);
diff --git a/tests/codeception/config/config.php b/tests/codeception/config/config.php
deleted file mode 100755
index b478679..0000000
--- a/tests/codeception/config/config.php
+++ /dev/null
@@ -1,26 +0,0 @@
- 'en-US',
- 'controllerMap' => [
- 'fixture' => [
- 'class' => 'yii\faker\FixtureController',
- 'fixtureDataPath' => '@tests/codeception/common/fixtures/data',
- 'templatePath' => '@tests/codeception/common/templates/fixtures',
- 'namespace' => 'tests\codeception\common\fixtures',
- ],
- ],
- 'components' => [
- 'db' => [
- 'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_tests',
- ],
- 'mailer' => [
- 'useFileTransport' => true,
- ],
- 'urlManager' => [
- 'showScriptName' => true,
- ],
- ],
-];
diff --git a/tests/codeception/config/console/unit.php b/tests/codeception/config/console/unit.php
deleted file mode 100755
index 4d3aeb0..0000000
--- a/tests/codeception/config/console/unit.php
+++ /dev/null
@@ -1,14 +0,0 @@
- [
- 'request' => [
- // it's not recommended to run functional tests with CSRF validation enabled
- 'enableCsrfValidation' => false,
- // but if you absolutely need it set cookie domain to localhost
- /*
- 'csrfCookie' => [
- 'domain' => 'localhost',
- ],
- */
- ],
- ],
-];
\ No newline at end of file
diff --git a/tests/codeception/config/unit.php b/tests/codeception/config/unit.php
deleted file mode 100755
index 6bd08d3..0000000
--- a/tests/codeception/config/unit.php
+++ /dev/null
@@ -1,7 +0,0 @@
- $value) {
- $inputType = $field === 'body' ? 'textarea' : 'input';
- $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
- }
- $this->actor->click('contact-button');
- }
-}
diff --git a/tests/codeception/frontend/_pages/SignupPage.php b/tests/codeception/frontend/_pages/SignupPage.php
deleted file mode 100755
index 0e1cefa..0000000
--- a/tests/codeception/frontend/_pages/SignupPage.php
+++ /dev/null
@@ -1,27 +0,0 @@
- $value) {
- $inputType = $field === 'body' ? 'textarea' : 'input';
- $this->actor->fillField($inputType . '[name="SignupForm[' . $field . ']"]', $value);
- }
- $this->actor->click('signup-button');
- }
-}
diff --git a/tests/codeception/frontend/acceptance.suite.yml b/tests/codeception/frontend/acceptance.suite.yml
deleted file mode 100755
index 1828a04..0000000
--- a/tests/codeception/frontend/acceptance.suite.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-# Codeception Test Suite Configuration
-
-# suite for acceptance tests.
-# perform tests in browser using the Selenium-like tools.
-# powered by Mink (http://mink.behat.org).
-# (tip: that's what your customer will see).
-# (tip: test your ajax and javascript by one of Mink drivers).
-
-# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
-
-class_name: AcceptanceTester
-modules:
- enabled:
- - PhpBrowser
- - tests\codeception\common\_support\FixtureHelper
-# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
-# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
-# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
-# it is useful if you want to login in your app in each test.
-# - WebDriver
- config:
- PhpBrowser:
-# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO
- url: http://localhost:8080
-# WebDriver:
-# url: http://localhost:8080
-# browser: firefox
-# restart: true
diff --git a/tests/codeception/frontend/acceptance/AboutCept.php b/tests/codeception/frontend/acceptance/AboutCept.php
deleted file mode 100755
index 50bf9ba..0000000
--- a/tests/codeception/frontend/acceptance/AboutCept.php
+++ /dev/null
@@ -1,10 +0,0 @@
-wantTo('ensure that about works');
-AboutPage::openBy($I);
-$I->see('About', 'h1');
diff --git a/tests/codeception/frontend/acceptance/ContactCept.php b/tests/codeception/frontend/acceptance/ContactCept.php
deleted file mode 100755
index f7a6bc8..0000000
--- a/tests/codeception/frontend/acceptance/ContactCept.php
+++ /dev/null
@@ -1,56 +0,0 @@
-wantTo('ensure that contact works');
-
-$contactPage = ContactPage::openBy($I);
-
-$I->see('Contact', 'h1');
-
-$I->amGoingTo('submit contact form with no data');
-$contactPage->submit([]);
-if (method_exists($I, 'wait')) {
- $I->wait(3); // only for selenium
-}
-$I->expectTo('see validations errors');
-$I->see('Contact', 'h1');
-$I->see('Name cannot be blank', '.help-block');
-$I->see('Email cannot be blank', '.help-block');
-$I->see('Subject cannot be blank', '.help-block');
-$I->see('Body cannot be blank', '.help-block');
-$I->see('The verification code is incorrect', '.help-block');
-
-$I->amGoingTo('submit contact form with not correct email');
-$contactPage->submit([
- 'name' => 'tester',
- 'email' => 'tester.email',
- 'subject' => 'test subject',
- 'body' => 'test content',
- 'verifyCode' => 'testme',
-]);
-if (method_exists($I, 'wait')) {
- $I->wait(3); // only for selenium
-}
-$I->expectTo('see that email adress is wrong');
-$I->dontSee('Name cannot be blank', '.help-block');
-$I->see('Email is not a valid email address.', '.help-block');
-$I->dontSee('Subject cannot be blank', '.help-block');
-$I->dontSee('Body cannot be blank', '.help-block');
-$I->dontSee('The verification code is incorrect', '.help-block');
-
-$I->amGoingTo('submit contact form with correct data');
-$contactPage->submit([
- 'name' => 'tester',
- 'email' => 'tester@example.com',
- 'subject' => 'test subject',
- 'body' => 'test content',
- 'verifyCode' => 'testme',
-]);
-if (method_exists($I, 'wait')) {
- $I->wait(3); // only for selenium
-}
-$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
diff --git a/tests/codeception/frontend/acceptance/HomeCept.php b/tests/codeception/frontend/acceptance/HomeCept.php
deleted file mode 100755
index 9566a2e..0000000
--- a/tests/codeception/frontend/acceptance/HomeCept.php
+++ /dev/null
@@ -1,12 +0,0 @@
-wantTo('ensure that home page works');
-$I->amOnPage(Yii::$app->homeUrl);
-$I->see('My Company');
-$I->seeLink('About');
-$I->click('About');
-$I->see('This is the About page.');
diff --git a/tests/codeception/frontend/acceptance/LoginCept.php b/tests/codeception/frontend/acceptance/LoginCept.php
deleted file mode 100755
index 599e24f..0000000
--- a/tests/codeception/frontend/acceptance/LoginCept.php
+++ /dev/null
@@ -1,34 +0,0 @@
-wantTo('ensure login page works');
-
-$loginPage = LoginPage::openBy($I);
-
-$I->amGoingTo('submit login form with no data');
-$loginPage->login('', '');
-$I->expectTo('see validations errors');
-$I->see('Username cannot be blank.', '.help-block');
-$I->see('Password cannot be blank.', '.help-block');
-
-$I->amGoingTo('try to login with wrong credentials');
-$I->expectTo('see validations errors');
-$loginPage->login('admin', 'wrong');
-$I->expectTo('see validations errors');
-$I->see('Incorrect username or password.', '.help-block');
-
-$I->amGoingTo('try to login with correct credentials');
-$loginPage->login('erau', 'password_0');
-$I->expectTo('see that user is logged');
-$I->seeLink('Logout (erau)');
-$I->dontSeeLink('Login');
-$I->dontSeeLink('Signup');
-/** Uncomment if using WebDriver
- * $I->click('Logout (erau)');
- * $I->dontSeeLink('Logout (erau)');
- * $I->seeLink('Login');
- */
diff --git a/tests/codeception/frontend/acceptance/SignupCest.php b/tests/codeception/frontend/acceptance/SignupCest.php
deleted file mode 100755
index ab4b7bb..0000000
--- a/tests/codeception/frontend/acceptance/SignupCest.php
+++ /dev/null
@@ -1,82 +0,0 @@
- 'tester.email@example.com',
- 'username' => 'tester',
- ]);
- }
-
- /**
- * This method is called when test fails.
- * @param \Codeception\Event\FailEvent $event
- */
- public function _fail($event)
- {
- }
-
- /**
- * @param \codeception_frontend\AcceptanceTester $I
- * @param \Codeception\Scenario $scenario
- */
- public function testUserSignup($I, $scenario)
- {
- $I->wantTo('ensure that signup works');
-
- $signupPage = SignupPage::openBy($I);
- $I->see('Signup', 'h1');
- $I->see('Please fill out the following fields to signup:');
-
- $I->amGoingTo('submit signup form with no data');
-
- $signupPage->submit([]);
-
- $I->expectTo('see validation errors');
- $I->see('Username cannot be blank.', '.help-block');
- $I->see('Email cannot be blank.', '.help-block');
- $I->see('Password cannot be blank.', '.help-block');
-
- $I->amGoingTo('submit signup form with not correct email');
- $signupPage->submit([
- 'username' => 'tester',
- 'email' => 'tester.email',
- 'password' => 'tester_password',
- ]);
-
- $I->expectTo('see that email address is wrong');
- $I->dontSee('Username cannot be blank.', '.help-block');
- $I->dontSee('Password cannot be blank.', '.help-block');
- $I->see('Email is not a valid email address.', '.help-block');
-
- $I->amGoingTo('submit signup form with correct email');
- $signupPage->submit([
- 'username' => 'tester',
- 'email' => 'tester.email@example.com',
- 'password' => 'tester_password',
- ]);
-
- $I->expectTo('see that user logged in');
- $I->seeLink('Logout (tester)');
- }
-}
diff --git a/tests/codeception/frontend/acceptance/_bootstrap.php b/tests/codeception/frontend/acceptance/_bootstrap.php
deleted file mode 100755
index b0a40ef..0000000
--- a/tests/codeception/frontend/acceptance/_bootstrap.php
+++ /dev/null
@@ -1,2 +0,0 @@
-wantTo('ensure that about works');
-AboutPage::openBy($I);
-$I->see('About', 'h1');
diff --git a/tests/codeception/frontend/functional/ContactCept.php b/tests/codeception/frontend/functional/ContactCept.php
deleted file mode 100755
index c61d4c2..0000000
--- a/tests/codeception/frontend/functional/ContactCept.php
+++ /dev/null
@@ -1,47 +0,0 @@
-wantTo('ensure that contact works');
-
-$contactPage = ContactPage::openBy($I);
-
-$I->see('Contact', 'h1');
-
-$I->amGoingTo('submit contact form with no data');
-$contactPage->submit([]);
-$I->expectTo('see validations errors');
-$I->see('Contact', 'h1');
-$I->see('Name cannot be blank', '.help-block');
-$I->see('Email cannot be blank', '.help-block');
-$I->see('Subject cannot be blank', '.help-block');
-$I->see('Body cannot be blank', '.help-block');
-$I->see('The verification code is incorrect', '.help-block');
-
-$I->amGoingTo('submit contact form with not correct email');
-$contactPage->submit([
- 'name' => 'tester',
- 'email' => 'tester.email',
- 'subject' => 'test subject',
- 'body' => 'test content',
- 'verifyCode' => 'testme',
-]);
-$I->expectTo('see that email adress is wrong');
-$I->dontSee('Name cannot be blank', '.help-block');
-$I->see('Email is not a valid email address.', '.help-block');
-$I->dontSee('Subject cannot be blank', '.help-block');
-$I->dontSee('Body cannot be blank', '.help-block');
-$I->dontSee('The verification code is incorrect', '.help-block');
-
-$I->amGoingTo('submit contact form with correct data');
-$contactPage->submit([
- 'name' => 'tester',
- 'email' => 'tester@example.com',
- 'subject' => 'test subject',
- 'body' => 'test content',
- 'verifyCode' => 'testme',
-]);
-$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
diff --git a/tests/codeception/frontend/functional/HomeCept.php b/tests/codeception/frontend/functional/HomeCept.php
deleted file mode 100755
index f340061..0000000
--- a/tests/codeception/frontend/functional/HomeCept.php
+++ /dev/null
@@ -1,12 +0,0 @@
-wantTo('ensure that home page works');
-$I->amOnPage(Yii::$app->homeUrl);
-$I->see('My Company');
-$I->seeLink('About');
-$I->click('About');
-$I->see('This is the About page.');
diff --git a/tests/codeception/frontend/functional/LoginCept.php b/tests/codeception/frontend/functional/LoginCept.php
deleted file mode 100755
index daca12c..0000000
--- a/tests/codeception/frontend/functional/LoginCept.php
+++ /dev/null
@@ -1,29 +0,0 @@
-wantTo('ensure login page works');
-
-$loginPage = LoginPage::openBy($I);
-
-$I->amGoingTo('submit login form with no data');
-$loginPage->login('', '');
-$I->expectTo('see validations errors');
-$I->see('Username cannot be blank.', '.help-block');
-$I->see('Password cannot be blank.', '.help-block');
-
-$I->amGoingTo('try to login with wrong credentials');
-$I->expectTo('see validations errors');
-$loginPage->login('admin', 'wrong');
-$I->expectTo('see validations errors');
-$I->see('Incorrect username or password.', '.help-block');
-
-$I->amGoingTo('try to login with correct credentials');
-$loginPage->login('erau', 'password_0');
-$I->expectTo('see that user is logged');
-$I->seeLink('Logout (erau)');
-$I->dontSeeLink('Login');
-$I->dontSeeLink('Signup');
diff --git a/tests/codeception/frontend/functional/SignupCest.php b/tests/codeception/frontend/functional/SignupCest.php
deleted file mode 100755
index 525b037..0000000
--- a/tests/codeception/frontend/functional/SignupCest.php
+++ /dev/null
@@ -1,90 +0,0 @@
- 'tester.email@example.com',
- 'username' => 'tester',
- ]);
- }
-
- /**
- * This method is called when test fails.
- * @param \Codeception\Event\FailEvent $event
- */
- public function _fail($event)
- {
-
- }
-
- /**
- *
- * @param \codeception_frontend\FunctionalTester $I
- * @param \Codeception\Scenario $scenario
- */
- public function testUserSignup($I, $scenario)
- {
- $I->wantTo('ensure that signup works');
-
- $signupPage = SignupPage::openBy($I);
- $I->see('Signup', 'h1');
- $I->see('Please fill out the following fields to signup:');
-
- $I->amGoingTo('submit signup form with no data');
-
- $signupPage->submit([]);
-
- $I->expectTo('see validation errors');
- $I->see('Username cannot be blank.', '.help-block');
- $I->see('Email cannot be blank.', '.help-block');
- $I->see('Password cannot be blank.', '.help-block');
-
- $I->amGoingTo('submit signup form with not correct email');
- $signupPage->submit([
- 'username' => 'tester',
- 'email' => 'tester.email',
- 'password' => 'tester_password',
- ]);
-
- $I->expectTo('see that email address is wrong');
- $I->dontSee('Username cannot be blank.', '.help-block');
- $I->dontSee('Password cannot be blank.', '.help-block');
- $I->see('Email is not a valid email address.', '.help-block');
-
- $I->amGoingTo('submit signup form with correct email');
- $signupPage->submit([
- 'username' => 'tester',
- 'email' => 'tester.email@example.com',
- 'password' => 'tester_password',
- ]);
-
- $I->expectTo('see that user is created');
- $I->seeRecord('common\models\User', [
- 'username' => 'tester',
- 'email' => 'tester.email@example.com',
- ]);
-
- $I->expectTo('see that user logged in');
- $I->seeLink('Logout (tester)');
- }
-}
diff --git a/tests/codeception/frontend/functional/_bootstrap.php b/tests/codeception/frontend/functional/_bootstrap.php
deleted file mode 100755
index 1abc491..0000000
--- a/tests/codeception/frontend/functional/_bootstrap.php
+++ /dev/null
@@ -1,3 +0,0 @@
- 'okirlin',
- 'auth_key' => 'iwTNae9t34OmnK6l4vT4IeaTk-YWI2Rv',
- 'password_hash' => '$2y$13$CXT0Rkle1EMJ/c1l5bylL.EylfmQ39O5JlHJVFpNn618OUS1HwaIi',
- 'password_reset_token' => 't5GU9NwpuGYSfb7FEZMAxqtuz2PkEvv_' . time(),
- 'created_at' => '1391885313',
- 'updated_at' => '1391885313',
- 'email' => 'brady.renner@rutherford.com',
- ],
- [
- 'username' => 'troy.becker',
- 'auth_key' => 'EdKfXrx88weFMV0vIxuTMWKgfK2tS3Lp',
- 'password_hash' => '$2y$13$g5nv41Px7VBqhS3hVsVN2.MKfgT3jFdkXEsMC4rQJLfaMa7VaJqL2',
- 'password_reset_token' => '4BSNyiZNAuxjs5Mty990c47sVrgllIi_' . time(),
- 'created_at' => '1391885313',
- 'updated_at' => '1391885313',
- 'email' => 'nicolas.dianna@hotmail.com',
- 'status' => '0',
- ],
-];
diff --git a/tests/codeception/frontend/unit/models/ContactFormTest.php b/tests/codeception/frontend/unit/models/ContactFormTest.php
deleted file mode 100755
index 9aaf595..0000000
--- a/tests/codeception/frontend/unit/models/ContactFormTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
-mailer->fileTransportCallback = function ($mailer, $message) {
- return 'testing_message.eml';
- };
- }
-
- protected function tearDown()
- {
- unlink($this->getMessageFile());
- parent::tearDown();
- }
-
- public function testContact()
- {
- $model = new ContactForm();
-
- $model->attributes = [
- 'name' => 'Tester',
- 'email' => 'tester@example.com',
- 'subject' => 'very important letter subject',
- 'body' => 'body of current message',
- ];
-
- $model->sendEmail('admin@example.com');
-
- $this->specify('email should be send', function () {
- expect('email file should exist', file_exists($this->getMessageFile()))->true();
- });
-
- $this->specify('message should contain correct data', function () use ($model) {
- $emailMessage = file_get_contents($this->getMessageFile());
-
- expect('email should contain user name', $emailMessage)->contains($model->name);
- expect('email should contain sender email', $emailMessage)->contains($model->email);
- expect('email should contain subject', $emailMessage)->contains($model->subject);
- expect('email should contain body', $emailMessage)->contains($model->body);
- });
- }
-
- private function getMessageFile()
- {
- return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml';
- }
-}
diff --git a/tests/codeception/frontend/unit/models/PasswordResetRequestFormTest.php b/tests/codeception/frontend/unit/models/PasswordResetRequestFormTest.php
deleted file mode 100755
index ced8cce..0000000
--- a/tests/codeception/frontend/unit/models/PasswordResetRequestFormTest.php
+++ /dev/null
@@ -1,87 +0,0 @@
-mailer->fileTransportCallback = function ($mailer, $message) {
- return 'testing_message.eml';
- };
- }
-
- protected function tearDown()
- {
- @unlink($this->getMessageFile());
-
- parent::tearDown();
- }
-
- public function testSendEmailWrongUser()
- {
- $this->specify('no user with such email, message should not be sent', function () {
-
- $model = new PasswordResetRequestForm();
- $model->email = 'not-existing-email@example.com';
-
- expect('email not sent', $model->sendEmail())->false();
-
- });
-
- $this->specify('user is not active, message should not be sent', function () {
-
- $model = new PasswordResetRequestForm();
- $model->email = $this->user[1]['email'];
-
- expect('email not sent', $model->sendEmail())->false();
-
- });
- }
-
- public function testSendEmailCorrectUser()
- {
- $model = new PasswordResetRequestForm();
- $model->email = $this->user[0]['email'];
- $user = User::findOne(['password_reset_token' => $this->user[0]['password_reset_token']]);
-
- expect('email sent', $model->sendEmail())->true();
- expect('user has valid token', $user->password_reset_token)->notNull();
-
- $this->specify('message has correct format', function () use ($model) {
-
- expect('message file exists', file_exists($this->getMessageFile()))->true();
-
- $message = file_get_contents($this->getMessageFile());
- expect('message "from" is correct', $message)->contains(Yii::$app->params['supportEmail']);
- expect('message "to" is correct', $message)->contains($model->email);
-
- });
- }
-
- public function fixtures()
- {
- return [
- 'user' => [
- 'class' => UserFixture::className(),
- 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php'
- ],
- ];
- }
-
- private function getMessageFile()
- {
- return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml';
- }
-}
diff --git a/tests/codeception/frontend/unit/models/ResetPasswordFormTest.php b/tests/codeception/frontend/unit/models/ResetPasswordFormTest.php
deleted file mode 100755
index a4dd021..0000000
--- a/tests/codeception/frontend/unit/models/ResetPasswordFormTest.php
+++ /dev/null
@@ -1,43 +0,0 @@
-user[0]['password_reset_token']);
- expect('password should be resetted', $form->resetPassword())->true();
- }
-
- public function fixtures()
- {
- return [
- 'user' => [
- 'class' => UserFixture::className(),
- 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php'
- ],
- ];
- }
-}
diff --git a/tests/codeception/frontend/unit/models/SignupFormTest.php b/tests/codeception/frontend/unit/models/SignupFormTest.php
deleted file mode 100755
index 4d08e8c..0000000
--- a/tests/codeception/frontend/unit/models/SignupFormTest.php
+++ /dev/null
@@ -1,52 +0,0 @@
- 'some_username',
- 'email' => 'some_email@example.com',
- 'password' => 'some_password',
- ]);
-
- $user = $model->signup();
-
- $this->assertInstanceOf('common\models\User', $user, 'user should be valid');
-
- expect('username should be correct', $user->username)->equals('some_username');
- expect('email should be correct', $user->email)->equals('some_email@example.com');
- expect('password should be correct', $user->validatePassword('some_password'))->true();
- }
-
- public function testNotCorrectSignup()
- {
- $model = new SignupForm([
- 'username' => 'troy.becker',
- 'email' => 'nicolas.dianna@hotmail.com',
- 'password' => 'some_password',
- ]);
-
- expect('username and email are in use, user should not be created', $model->signup())->null();
- }
-
- public function fixtures()
- {
- return [
- 'user' => [
- 'class' => UserFixture::className(),
- 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php',
- ],
- ];
- }
-}
diff --git a/tests/config/.gitignore b/tests/config/.gitignore
deleted file mode 100644
index 20da318..0000000
--- a/tests/config/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-main-local.php
-params-local.php
\ No newline at end of file
diff --git a/tests/config/bootstrap.php b/tests/config/bootstrap.php
deleted file mode 100644
index b3d9bbc..0000000
--- a/tests/config/bootstrap.php
+++ /dev/null
@@ -1 +0,0 @@
- 'app-test',
- 'basePath' => dirname(__DIR__),
- 'bootstrap' => ['log'],
-];
diff --git a/tests/config/params.php b/tests/config/params.php
deleted file mode 100644
index 7f754b9..0000000
--- a/tests/config/params.php
+++ /dev/null
@@ -1,4 +0,0 @@
- 'admin@example.com',
-];
diff --git a/tests/config/unit.php b/tests/config/unit.php
deleted file mode 100644
index 4a98b44..0000000
--- a/tests/config/unit.php
+++ /dev/null
@@ -1,9 +0,0 @@
-assertEquals($validator->validate($email), $result);
- }
-
- public function getEmailVariants(){
- return [
- ['test@test.com', true],
- ['test@test', false],
- ['testtest.com', false]
- ];
- }
-}
\ No newline at end of file
diff --git a/tests/unit/UserStoreTest.php b/tests/unit/UserStoreTest.php
deleted file mode 100644
index 0a4e142..0000000
--- a/tests/unit/UserStoreTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
-store = new UserStore();
- }
-
- public function imagineCustomer(){
- $fake = \Faker\Factory::create();
- return [
- 'name' => $fake->name,
- 'email' => $fake->email,
- 'pass' => $fake->password(19),
- ];
-
- }
-
- public function testGetUser(){
- $imagineUser = $this->imagineCustomer();
- $this->store->addUser($imagineUser['name'],$imagineUser['email'],$imagineUser['pass']);
- $user = $this->store->getUser($imagineUser['email']);
- $this->assertEquals($user['name'], $imagineUser['name']);
- $this->assertEquals($user['email'], $imagineUser['email']);
- $this->assertEquals($user['pass'], $imagineUser['pass']);
- }
-
- public function testAddUser_ShortPass(){
- $this->setExpectedException('\yii\base\Exception');
- $this->store->addUser('Some Name','collmail@gig.com','ff');
- }
-
- protected function _after()
- {
- }
-
- // tests
-// public function testMe()
-// {
-//
-// }
-}
\ No newline at end of file
diff --git a/tests/unit/ValidatorTest.php b/tests/unit/ValidatorTest.php
deleted file mode 100644
index 0505723..0000000
--- a/tests/unit/ValidatorTest.php
+++ /dev/null
@@ -1,27 +0,0 @@
-getMock('common\components\UserStore');
- $this->validator = new Validator($store);
- $store->expects($this->once())
- ->method('notifyPasswordFailure')
- ->with($this->equalTo("test@emails.com"));
-
- $store->expects($this->any())
- ->method("getUser")
- ->will($this->returnValue([
- "name"=>"fdsfdf",
- "email"=>"test@emails.com",
- "pass"=>"rihfhh"
- ]));
-
- $this->assertFalse($this->validator->validateUser("test@emails.com", "wrong"));
- }
-}
\ No newline at end of file
--
libgit2 0.21.4