Commit b50f5ce323f775896f0223cfd51c42ced70e5670
1 parent
fdc1c9de
test
Showing
12 changed files
with
221 additions
and
1 deletions
Show diff stats
console/migrations/m160406_133247_create_junction_portfolio_and_user.php
0 โ 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use yii\db\Migration; | ||
| 4 | + | ||
| 5 | + /** | ||
| 6 | + * Handles the creation for table `portfolio_user`. | ||
| 7 | + * Has foreign keys to the tables: | ||
| 8 | + * - `portfolio` | ||
| 9 | + * - `user` | ||
| 10 | + */ | ||
| 11 | + class m160406_133247_create_junction_portfolio_and_user extends Migration | ||
| 12 | + { | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * @inheritdoc | ||
| 16 | + */ | ||
| 17 | + public function up() | ||
| 18 | + { | ||
| 19 | + $this->createTable('portfolio_user', [ | ||
| 20 | + 'portfolio_user_id' => $this->primaryKey(), | ||
| 21 | + 'portfolio_id' => $this->integer() | ||
| 22 | + ->notNull(), | ||
| 23 | + 'user_id' => $this->integer() | ||
| 24 | + ->notNull(), | ||
| 25 | + 'position' => $this->string(), | ||
| 26 | + 'time' => $this->integer(), | ||
| 27 | + 'status' => $this->integer() | ||
| 28 | + ->defaultValue(2) | ||
| 29 | + ->notNull(), | ||
| 30 | + ]); | ||
| 31 | + | ||
| 32 | + // add foreign key for table `portfolio` | ||
| 33 | + $this->addForeignKey('fk-portfolio_user-portfolio_id', 'portfolio_user', 'portfolio_id', 'portfolio', 'portfolio_id', 'CASCADE'); | ||
| 34 | + | ||
| 35 | + // add foreign key for table `user` | ||
| 36 | + $this->addForeignKey('fk-portfolio_user-user_id', 'portfolio_user', 'user_id', 'user', 'id', 'CASCADE'); | ||
| 37 | + | ||
| 38 | + $this->createIndex('unique_portfolio_user_key', 'portfolio_user', ['portfolio_id', 'user_id'], true); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * @inheritdoc | ||
| 43 | + */ | ||
| 44 | + public function down() | ||
| 45 | + { | ||
| 46 | + | ||
| 47 | + $this->dropIndex('unique_portfolio_user_key', 'portfolio_user'); | ||
| 48 | + | ||
| 49 | + // drops foreign key for table `portfolio` | ||
| 50 | + $this->dropForeignKey('fk-portfolio_user-portfolio_id', 'portfolio_user'); | ||
| 51 | + | ||
| 52 | + // drops foreign key for table `user` | ||
| 53 | + $this->dropForeignKey('fk-portfolio_user-user_id', 'portfolio_user'); | ||
| 54 | + | ||
| 55 | + $this->dropTable('portfolio_user'); | ||
| 56 | + } | ||
| 57 | + } |
frontend/views/accounts/_portfolio_form.php
| @@ -214,7 +214,7 @@ | @@ -214,7 +214,7 @@ | ||
| 214 | } | 214 | } |
| 215 | ); | 215 | ); |
| 216 | $.fancybox.open( | 216 | $.fancybox.open( |
| 217 | - {href : 'http://mfp.dev/ajax/project-user'}, { | 217 | + {href : '/ajax/project-user'}, { |
| 218 | type : 'ajax', maxWidth : 750, | 218 | type : 'ajax', maxWidth : 750, |
| 219 | ajax : {dataType : 'html', data : {ids : JSON.stringify(ids)}}, | 219 | ajax : {dataType : 'html', data : {ids : JSON.stringify(ids)}}, |
| 220 | tpl : {wrap : '<div class="fancybox-wrap" tabIndex="-1" data-model="common\\models\\PortfolioUser" data-component="' + component + '"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>'} | 220 | tpl : {wrap : '<div class="fancybox-wrap" tabIndex="-1" data-model="common\\models\\PortfolioUser" data-component="' + component + '"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>'} |
1.62 KB
tests/_support/Step/Acceptance/CRMOperatorSteps.php
0 โ 100644
| 1 | +<?php | ||
| 2 | +namespace Step\Acceptance; | ||
| 3 | + | ||
| 4 | +class CRMOperatorSteps extends \AcceptanceTester | ||
| 5 | +{ | ||
| 6 | + public function amInAddCustomerUi(){ | ||
| 7 | + $I = $this; | ||
| 8 | + $I->amOnPage('site/signup'); | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + public function imagineCustomer(){ | ||
| 12 | + $fake = \Faker\Factory::create(); | ||
| 13 | + return [ | ||
| 14 | + 'SignupForm[username]' => $fake->name, | ||
| 15 | + 'SignupForm[email]' => $fake->email, | ||
| 16 | + 'SignupForm[password]' => $fake->password(19), | ||
| 17 | + ]; | ||
| 18 | + | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public function fillCustomerDataForm($fieldData){ | ||
| 22 | + $I = $this; | ||
| 23 | + foreach ($fieldData as $key=>$value) { | ||
| 24 | + $I->fillField($key,$value); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public function submitCustomerDataForm(){ | ||
| 30 | + $I = $this; | ||
| 31 | + $I->click('signup-button'); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + | ||
| 36 | +} | ||
| 0 | \ No newline at end of file | 37 | \ No newline at end of file |
| 1 | +<?php |
| 1 | +<?php | ||
| 2 | +namespace tests\unit; | ||
| 3 | + | ||
| 4 | +use Codeception\TestCase\Test; | ||
| 5 | +use yii\validators\EmailValidator; | ||
| 6 | + | ||
| 7 | +class EmailValidatorTest extends Test{ | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * @dataProvider getEmailVariants | ||
| 11 | + */ | ||
| 12 | + public function testEmail($email, $result){ | ||
| 13 | + $validator = new EmailValidator(); | ||
| 14 | + $this->assertEquals($validator->validate($email), $result); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public function getEmailVariants(){ | ||
| 18 | + return [ | ||
| 19 | + ['test@test.com', true], | ||
| 20 | + ['test@test', false], | ||
| 21 | + ['testtest.com', false] | ||
| 22 | + ]; | ||
| 23 | + } | ||
| 24 | +} | ||
| 0 | \ No newline at end of file | 25 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | +namespace tests\unit; | ||
| 3 | +use common\components\UserStore; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +class UserStoreTest extends \Codeception\TestCase\Test | ||
| 8 | +{ | ||
| 9 | + /** | ||
| 10 | + * @var \UnitTester | ||
| 11 | + */ | ||
| 12 | + protected $tester; | ||
| 13 | + | ||
| 14 | + private $store; | ||
| 15 | + | ||
| 16 | + public function _before() | ||
| 17 | + { | ||
| 18 | + $this->store = new UserStore(); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public function imagineCustomer(){ | ||
| 22 | + $fake = \Faker\Factory::create(); | ||
| 23 | + return [ | ||
| 24 | + 'name' => $fake->name, | ||
| 25 | + 'email' => $fake->email, | ||
| 26 | + 'pass' => $fake->password(19), | ||
| 27 | + ]; | ||
| 28 | + | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public function testGetUser(){ | ||
| 32 | + $imagineUser = $this->imagineCustomer(); | ||
| 33 | + $this->store->addUser($imagineUser['name'],$imagineUser['email'],$imagineUser['pass']); | ||
| 34 | + $user = $this->store->getUser($imagineUser['email']); | ||
| 35 | + $this->assertEquals($user['name'], $imagineUser['name']); | ||
| 36 | + $this->assertEquals($user['email'], $imagineUser['email']); | ||
| 37 | + $this->assertEquals($user['pass'], $imagineUser['pass']); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public function testAddUser_ShortPass(){ | ||
| 41 | + $this->setExpectedException('\yii\base\Exception'); | ||
| 42 | + $this->store->addUser('Some Name','collmail@gig.com','ff'); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + protected function _after() | ||
| 46 | + { | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + // tests | ||
| 50 | +// public function testMe() | ||
| 51 | +// { | ||
| 52 | +// | ||
| 53 | +// } | ||
| 54 | +} | ||
| 0 | \ No newline at end of file | 55 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | +namespace tests\unit; | ||
| 3 | +use common\components\UserStore; | ||
| 4 | + | ||
| 5 | +use common\components\Validator; | ||
| 6 | +use Yii; | ||
| 7 | + | ||
| 8 | +class ValidatorTest extends \Codeception\TestCase\Test | ||
| 9 | +{ | ||
| 10 | + public function testValidate_FalsePass(){ | ||
| 11 | + $store = $this->getMock('common\components\UserStore'); | ||
| 12 | + $this->validator = new Validator($store); | ||
| 13 | + $store->expects($this->once()) | ||
| 14 | + ->method('notifyPasswordFailure') | ||
| 15 | + ->with($this->equalTo("test@emails.com")); | ||
| 16 | + | ||
| 17 | + $store->expects($this->any()) | ||
| 18 | + ->method("getUser") | ||
| 19 | + ->will($this->returnValue([ | ||
| 20 | + "name"=>"fdsfdf", | ||
| 21 | + "email"=>"test@emails.com", | ||
| 22 | + "pass"=>"rihfhh" | ||
| 23 | + ])); | ||
| 24 | + | ||
| 25 | + $this->assertFalse($this->validator->validateUser("test@emails.com", "wrong")); | ||
| 26 | + } | ||
| 27 | +} | ||
| 0 | \ No newline at end of file | 28 | \ No newline at end of file |