Can anybody say me how configure php files to run simple test’s in frontend of Yiinitializr Intermediate?
IDE: PhpStorm
I get error: Alias "frontend.modules.users.extensions.behaviors.password.*" is invalid. Make sure it points to an existing directory or file.
common/config/test.php
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'params' => array(
'yii.handleErrors' => false,
)
);
[b]
frontend/tests/WebTestCase.php[/b]
define('TEST_BASE_URL','http://frontend.l-wolq.net/index.php/');
/**
* The base class for functional test cases.
* In this class, we set the base URL for the test application.
* We also provide some common methods to be used by concrete test classes.
*/
class WebTestCase extends CWebTestCase
{
/**
* Sets up before each test method runs.
* This mainly sets the base URL for the test application.
*/
protected function setUp()
{
parent::setUp();
$this->setBrowserUrl(TEST_BASE_URL);
}
}
frontend/tests/bootstrap.php
<?
// change the following paths if necessary
require_once(__DIR__.'/../../common/lib/vendor/yiisoft/yii/framework/yiit.php');
require_once(dirname(__FILE__).'/WebTestCase.php');
Yii::createWebApplication(__DIR__.'/../../common/config/test.php');
frontend/tests/extensions/behaviors/password/ABcryptPasswordStrategyTest.php
<?php
Yii::import("frontend.modules.users.extensions.behaviors.password.*");
Yii::import("frontend.modules.users.models.*");
/**
* Tests for the {@link ABcryptPasswordStrategy} class.
* @author Charles Pick
* @package packages.passwordStrategy
*/
class ABcryptPasswordStrategyTest extends CTestCase
{
public function testEncode()
{
$strategy = new ABcryptPasswordStrategy();
$strategy->getSalt(true);
$password = "qwerty1";
$this->assertFalse($strategy->compare("test",$strategy->encode($password)));
$this->assertTrue($strategy->compare("qwerty1",$strategy->encode($password)));
}
}
files from extension YiiPassword saved here:
frontend/modules/users/extensions/behaviors/password/ABcryptPasswordStrategy.php
frontend/modules/users/extensions/behaviors/password/AHashPasswordStrategy.php
frontend/modules/users/extensions/behaviors/password/ALegacyMd5PasswordStrategy.php
frontend/modules/users/extensions/behaviors/password/ALegacySha1PasswordStrategy.php
frontend/modules/users/extensions/behaviors/password/APasswordBehavior.php
frontend/modules/users/extensions/behaviors/password/APasswordStrategy.php
frontend/modules/users/extensions/behaviors/password/composer.json
frontend/modules/users/extensions/behaviors/password/README.md