mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 06:37:55 +08:00 
			
		
		
		
	apps code style fixes
This commit is contained in:
		@ -32,7 +32,7 @@ class FixtureHelper extends Module
 | 
				
			|||||||
	 * to use in acceptance and functional tests.
 | 
						 * to use in acceptance and functional tests.
 | 
				
			||||||
	 * @param array $settings
 | 
						 * @param array $settings
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public function _beforeSuite($settings = array())
 | 
						public function _beforeSuite($settings = [])
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		$this->loadFixtures();
 | 
							$this->loadFixtures();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -54,5 +54,4 @@ class FixtureHelper extends Module
 | 
				
			|||||||
			],
 | 
								],
 | 
				
			||||||
		];
 | 
							];
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -18,5 +18,4 @@ class LoginPage extends BasePage
 | 
				
			|||||||
		$this->guy->fillField('input[name="LoginForm[password]"]', $password);
 | 
							$this->guy->fillField('input[name="LoginForm[password]"]', $password);
 | 
				
			||||||
		$this->guy->click('login-button');
 | 
							$this->guy->click('login-button');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -25,7 +25,7 @@ class LoginFormTest extends TestCase
 | 
				
			|||||||
		$model->username = 'some_username';
 | 
							$model->username = 'some_username';
 | 
				
			||||||
		$model->password = 'some_password';
 | 
							$model->password = 'some_password';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$this->specify('user should not be able to login, when there is no identity' , function () use ($model) {
 | 
							$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('model should not login user', $model->login())->false();
 | 
				
			||||||
			expect('user should not be logged in', Yii::$app->user->isGuest)->true();
 | 
								expect('user should not be logged in', Yii::$app->user->isGuest)->true();
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
@ -52,7 +52,7 @@ class LoginFormTest extends TestCase
 | 
				
			|||||||
		$model->username = 'demo';
 | 
							$model->username = 'demo';
 | 
				
			||||||
		$model->password = 'demo';
 | 
							$model->password = 'demo';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$this->specify('user should be able to login with correct credentials', function() use ($model) {
 | 
							$this->specify('user should be able to login with correct credentials', function () use ($model) {
 | 
				
			||||||
			expect('model should login user', $model->login())->true();
 | 
								expect('model should login user', $model->login())->true();
 | 
				
			||||||
			expect('error message should not be set', $model->errors)->hasntKey('password');
 | 
								expect('error message should not be set', $model->errors)->hasntKey('password');
 | 
				
			||||||
			expect('user should be logged in', Yii::$app->user->isGuest)->false();
 | 
								expect('user should be logged in', Yii::$app->user->isGuest)->false();
 | 
				
			||||||
@ -61,9 +61,8 @@ class LoginFormTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	private function mockUser($user)
 | 
						private function mockUser($user)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		$loginForm = $this->getMock('common\models\LoginForm',['getUser']);
 | 
							$loginForm = $this->getMock('common\models\LoginForm', ['getUser']);
 | 
				
			||||||
		$loginForm->expects($this->any())->method('getUser')->will($this->returnValue($user));
 | 
							$loginForm->expects($this->any())->method('getUser')->will($this->returnValue($user));
 | 
				
			||||||
		return $loginForm;
 | 
							return $loginForm;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -20,5 +20,4 @@ class SignupPage extends BasePage
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		$this->guy->click('signup-button');
 | 
							$this->guy->click('signup-button');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -79,5 +79,4 @@ class SignupCest
 | 
				
			|||||||
		$I->expectTo('see that user logged in');
 | 
							$I->expectTo('see that user logged in');
 | 
				
			||||||
		$I->see('Logout (tester)');
 | 
							$I->see('Logout (tester)');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -79,5 +79,4 @@ class SignupCest
 | 
				
			|||||||
		$I->expectTo('see that user logged in');
 | 
							$I->expectTo('see that user logged in');
 | 
				
			||||||
		$I->see('Logout (tester)');
 | 
							$I->see('Logout (tester)');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -42,7 +42,7 @@ class ContactFormTest extends TestCase
 | 
				
			|||||||
			expect('email file should exist', file_exists($this->getMessageFile()))->true();
 | 
								expect('email file should exist', file_exists($this->getMessageFile()))->true();
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$this->specify('message should contain correct data', function () use($model) {
 | 
							$this->specify('message should contain correct data', function () use ($model) {
 | 
				
			||||||
			$emailMessage = file_get_contents($this->getMessageFile());
 | 
								$emailMessage = file_get_contents($this->getMessageFile());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			expect('email should contain user name', $emailMessage)->contains($model->name);
 | 
								expect('email should contain user name', $emailMessage)->contains($model->name);
 | 
				
			||||||
@ -56,5 +56,4 @@ class ContactFormTest extends TestCase
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
 | 
							return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -28,14 +28,14 @@ class PasswordResetRequestFormTest extends DbTestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	public function testSendEmailWrongUser()
 | 
						public function testSendEmailWrongUser()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		$this->specify('no user with such email, message should not be send', function() {
 | 
							$this->specify('no user with such email, message should not be send', function () {
 | 
				
			||||||
			$model = new PasswordResetRequestForm();
 | 
								$model = new PasswordResetRequestForm();
 | 
				
			||||||
			$model->email = 'not-existing-email@example.com';
 | 
								$model->email = 'not-existing-email@example.com';
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			expect('email not send', $model->sendEmail())->false();
 | 
								expect('email not send', $model->sendEmail())->false();
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$this->specify('user is not active, message should not be send', function() {
 | 
							$this->specify('user is not active, message should not be send', function () {
 | 
				
			||||||
			$model = new PasswordResetRequestForm();
 | 
								$model = new PasswordResetRequestForm();
 | 
				
			||||||
			$model->email = $this->user[1]['email'];
 | 
								$model->email = $this->user[1]['email'];
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
@ -52,8 +52,8 @@ class PasswordResetRequestFormTest extends DbTestCase
 | 
				
			|||||||
		expect('email sent', $model->sendEmail())->true();
 | 
							expect('email sent', $model->sendEmail())->true();
 | 
				
			||||||
		expect('user has valid token', $user->password_reset_token)->notNull();
 | 
							expect('user has valid token', $user->password_reset_token)->notNull();
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
		$this->specify('message has correct format', function() use ($model) {
 | 
							$this->specify('message has correct format', function () use ($model) {
 | 
				
			||||||
			expect('message file exists',  file_exists($this->getMessageFile()))->true();
 | 
								expect('message file exists', file_exists($this->getMessageFile()))->true();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			$message = file_get_contents($this->getMessageFile());
 | 
								$message = file_get_contents($this->getMessageFile());
 | 
				
			||||||
			expect('message "from" is correct', $message)->contains(Yii::$app->params['supportEmail']);
 | 
								expect('message "from" is correct', $message)->contains(Yii::$app->params['supportEmail']);
 | 
				
			||||||
@ -75,5 +75,4 @@ class PasswordResetRequestFormTest extends DbTestCase
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
 | 
							return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -13,13 +13,13 @@ class ResetPasswordFormTest extends DbTestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	public function testResetPassword()
 | 
						public function testResetPassword()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		$this->specify('wrong reset token', function() {
 | 
							$this->specify('wrong reset token', function () {
 | 
				
			||||||
			$this->setExpectedException('\Exception','Wrong password reset token.');
 | 
								$this->setExpectedException('\Exception', 'Wrong password reset token.');
 | 
				
			||||||
			new ResetPasswordForm('notexistingtoken_1391882543');
 | 
								new ResetPasswordForm('notexistingtoken_1391882543');
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$this->specify('not correct token', function() {
 | 
							$this->specify('not correct token', function () {
 | 
				
			||||||
			$this->setExpectedException('yii\base\InvalidParamException','Password reset token cannot be blank.');
 | 
								$this->setExpectedException('yii\base\InvalidParamException', 'Password reset token cannot be blank.');
 | 
				
			||||||
			new ResetPasswordForm('');
 | 
								new ResetPasswordForm('');
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -33,5 +33,4 @@ class ResetPasswordFormTest extends DbTestCase
 | 
				
			|||||||
			],
 | 
								],
 | 
				
			||||||
		];
 | 
							];
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@ class SignupFormTest extends DbTestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	public function testCorrectSignup()
 | 
						public function testCorrectSignup()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		$model = $this->getMock('frontend\models\SignupForm',['validate']);
 | 
							$model = $this->getMock('frontend\models\SignupForm', ['validate']);
 | 
				
			||||||
		$model->expects($this->once())->method('validate')->will($this->returnValue(true));
 | 
							$model->expects($this->once())->method('validate')->will($this->returnValue(true));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$model->username = 'some_username';
 | 
							$model->username = 'some_username';
 | 
				
			||||||
@ -28,7 +28,7 @@ class SignupFormTest extends DbTestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	public function testNotCorrectSignup()
 | 
						public function testNotCorrectSignup()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		$model = $this->getMock('frontend\models\SignupForm',['validate']);
 | 
							$model = $this->getMock('frontend\models\SignupForm', ['validate']);
 | 
				
			||||||
		$model->expects($this->once())->method('validate')->will($this->returnValue(false));
 | 
							$model->expects($this->once())->method('validate')->will($this->returnValue(false));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		expect('user should not be created', $model->signup())->null();
 | 
							expect('user should not be created', $model->signup())->null();
 | 
				
			||||||
@ -43,5 +43,4 @@ class SignupFormTest extends DbTestCase
 | 
				
			|||||||
			],
 | 
								],
 | 
				
			||||||
		];
 | 
							];
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user