mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-17 07:10:48 +03:00
fixed problem with same fixtures orders. addded check to exist config/config.test.php.
created baseFeatureContext for use it in plugins. added config option to disable registration captcha (for tests)
This commit is contained in:
parent
e811db62b2
commit
263a743aef
|
@ -22,6 +22,19 @@
|
|||
* @since 1.0
|
||||
*/
|
||||
class ModuleUser_EntityUser extends Entity {
|
||||
/**
|
||||
* Определяем дополнительные правила валидации
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
public function __construct($aParam = false) {
|
||||
if (Config::Get('module.user.captcha_use_registration')) {
|
||||
$this->aValidateRules[] = array('captcha', 'captcha', 'on' => array('registration'));
|
||||
}
|
||||
|
||||
parent::__construct($aParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* Определяем правила валидации
|
||||
*
|
||||
|
@ -32,7 +45,6 @@ class ModuleUser_EntityUser extends Entity {
|
|||
array('login','login_exists','on'=>array('registration')),
|
||||
array('mail','email','allowEmpty'=>false,'on'=>array('registration','')),
|
||||
array('mail','mail_exists','on'=>array('registration')),
|
||||
array('captcha','captcha','on'=>array('registration')),
|
||||
array('password','string','allowEmpty'=>false,'min'=>5,'on'=>array('registration')),
|
||||
array('password_confirm','compare','compareField'=>'password','on'=>array('registration')),
|
||||
);
|
||||
|
|
|
@ -58,7 +58,12 @@ $config['pagination']['pages']['count'] = 4; // количес
|
|||
* и возможно придёться увеличить значение $config['path']['offset_request_url'] на число вложенных директорий,
|
||||
* например, для директории первой вложенности www.site.ru/livestreet/ поставить значение равное 1
|
||||
*/
|
||||
$config['path']['root']['web'] = 'http://'.$_SERVER['HTTP_HOST']; // полный WEB адрес сайта
|
||||
if (isset($_SERVER['HTTP_HOST'])) {
|
||||
$config['path']['root']['web'] = 'http://'.$_SERVER['HTTP_HOST']; // полный WEB адрес сайта
|
||||
} else {
|
||||
// for CLI scripts. or you can append "HTTP_HOST=http://yoursite.url" before script run command
|
||||
$config['path']['root']['web'] = null;
|
||||
}
|
||||
$config['path']['root']['server'] = dirname(dirname(__FILE__)); // полный путь до сайта в файловой системе
|
||||
/**
|
||||
* Для CLI режима использовать
|
||||
|
@ -205,6 +210,8 @@ $config['module']['user']['usernote_per_page'] = 20; // Число зам
|
|||
$config['module']['user']['userfield_max_identical'] = 2; // Максимальное число контактов одного типа
|
||||
$config['module']['user']['profile_photo_width'] = 250; // ширина квадрата фотографии в профиле, px
|
||||
$config['module']['user']['name_max'] = 30; // максимальная длинна имени в профиле пользователя
|
||||
$config['module']['user']['captcha_use_registration'] = true; // проверять поле капчи при регистрации пользователя
|
||||
|
||||
// Модуль Comment
|
||||
$config['module']['comment']['per_page'] = 20; // Число комментариев на одну страницу(это касается только полного списка комментариев прямого эфира)
|
||||
$config['module']['comment']['bad'] = -5; // Рейтинг комментария, начиная с которого он будет скрыт
|
||||
|
@ -524,7 +531,7 @@ $config['head']['default']['js'] = array(
|
|||
$config['head']['default']['css'] = array(
|
||||
"___path.static.skin___/css/reset.css",
|
||||
"___path.root.engine_lib___/external/jquery/markitup/skins/simple/style.css",
|
||||
"___path.root.engine_lib___/external/jquery/markitup/sets/default/style.css",
|
||||
"___path.root.engine_lib___/external/jquery/markitup/sets/default/style.css",
|
||||
"___path.root.engine_lib___/external/jquery/jcrop/jquery.Jcrop.css",
|
||||
"___path.root.engine_lib___/external/prettify/prettify.css",
|
||||
"___path.static.skin___/css/main.css",
|
||||
|
|
|
@ -34,5 +34,7 @@ $config['db']['table']['prefix'] = 'prefix_';
|
|||
$config['sys']['cache']['use'] = false; // использовать кеширование или нет
|
||||
$config['sys']['cache']['solid'] = false;
|
||||
|
||||
$config['module']['user']['captcha_use_registration'] = false; // проверять поле капчи при регистрации пользователя
|
||||
|
||||
return $config;
|
||||
?>
|
|
@ -130,6 +130,10 @@ if(isset($_SERVER['HTTP_APP_ENV']) && $_SERVER['HTTP_APP_ENV']=='test') {
|
|||
*/
|
||||
if(file_exists(Config::Get('path.root.server').'/config/config.test.php')) {
|
||||
Config::LoadFromFile(Config::Get('path.root.server').'/config/config.test.php',false);
|
||||
} else {
|
||||
throw new Exception("Config for test envirenment is not found.
|
||||
Rename /config/config.test.php.dist to /config/config.test.php and rewrite DB settings.
|
||||
After that check base_url in /test/behat/behat.yml it option must be correct site url.");
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
|
|
|
@ -17,8 +17,8 @@ class LoadFixtures
|
|||
private $aReferences = array();
|
||||
|
||||
/**
|
||||
* @var Engine
|
||||
*/
|
||||
* @var Engine
|
||||
*/
|
||||
private $oEngine;
|
||||
|
||||
/**
|
||||
|
@ -29,10 +29,6 @@ class LoadFixtures
|
|||
private $sDirFixtures;
|
||||
|
||||
public function __construct() {
|
||||
if (file_exists(Config::Get('path.root.server') . '/config/config.test.php')) {
|
||||
Config::LoadFromFile(Config::Get('path.root.server') . '/config/config.test.php', false);
|
||||
}
|
||||
|
||||
$this->oEngine = Engine::getInstance();
|
||||
$this->oEngine->Init();
|
||||
$this->sDirFixtures = realpath((dirname(__FILE__)) . "/fixtures/");
|
||||
|
@ -47,40 +43,58 @@ class LoadFixtures
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function purgeDB() {
|
||||
public function purgeDB() {
|
||||
$sDbname = Config::Get('db.params.dbname');
|
||||
|
||||
if (mysql_select_db($sDbname)) {
|
||||
mysql_query("DROP DATABASE $sDbname");
|
||||
echo "DROP DATABASE $sDbname \n";
|
||||
|
||||
$result = mysql_query("SELECT concat('TRUNCATE TABLE ', TABLE_NAME)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = '" . $sDbname . "'");
|
||||
|
||||
mysql_query('SET FOREIGN_KEY_CHECKS = 0');
|
||||
echo "TRUNCATE TABLE FROM TEST BASE";
|
||||
while ($row = mysql_fetch_row($result)) {
|
||||
if (!mysql_query($row[0])) {
|
||||
// exception
|
||||
throw new Exception("TRUNCATE TABLE FROM TEST BASE - Exception");
|
||||
}
|
||||
}
|
||||
mysql_query('SET FOREIGN_KEY_CHECKS = 1');
|
||||
|
||||
mysql_free_result($result);
|
||||
} else {
|
||||
|
||||
if (mysql_query("CREATE DATABASE IF NOT EXISTS $sDbname") === false) {
|
||||
// exception
|
||||
throw new Exception("DB \"$sDbname\" is not Created");
|
||||
echo "CREATE DATABASE $sDbname \n";
|
||||
return mysql_error();
|
||||
} else {
|
||||
|
||||
mysql_select_db($sDbname);
|
||||
|
||||
// Load dump from install_base.sql
|
||||
$result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/install_base.sql');
|
||||
|
||||
if (!$result['result']) {
|
||||
// exception
|
||||
throw new Exception("DB is not exported with file install_base.sql");
|
||||
return $result['errors'];
|
||||
}
|
||||
echo "ExportSQL DATABASE $sDbname -> install_base.sql \n";
|
||||
// Load dump from geo_base.sql
|
||||
$result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/geo_base.sql');
|
||||
|
||||
if (!$result['result']) {
|
||||
// exception
|
||||
throw new Exception("DB is not exported with file geo_base.sql");
|
||||
return $result['errors'];
|
||||
}
|
||||
echo "ExportSQL DATABASE $sDbname -> geo_base \n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (mysql_query("CREATE DATABASE $sDbname") === false) {
|
||||
return mysql_error();
|
||||
}
|
||||
echo "CREATE DATABASE $sDbname \n";
|
||||
|
||||
if (mysql_select_db($sDbname) === false) {
|
||||
return mysql_error();
|
||||
}
|
||||
|
||||
echo "SELECTED DATABASE $sDbname \n";
|
||||
// Load dump from install_base.sql
|
||||
$result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/install_base.sql');
|
||||
|
||||
if (!$result['result']) {
|
||||
return $result['errors'];
|
||||
}
|
||||
// Load dump from geo_base.sql
|
||||
$result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/geo_base.sql');
|
||||
|
||||
if (!$result['result']) {
|
||||
return $result['errors'];
|
||||
}
|
||||
|
||||
echo "ExportSQL DATABASE $sDbname \n";
|
||||
echo "ExportSQL DATABASE $sDbname -> geo_base \n";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -101,22 +115,19 @@ class LoadFixtures
|
|||
preg_match("/([a-zA-Z]+Fixtures).php$/", $sFilePath, $matches);
|
||||
$sClassName = $matches[1];
|
||||
$iOrder = forward_static_call(array($sClassName, 'getOrder'));
|
||||
if (!array_key_exists($iOrder, $aFixtures)) {
|
||||
$aFixtures[$iOrder] = $sClassName;
|
||||
} else {
|
||||
//@todo разруливание одинаковых ордеров
|
||||
throw new Exception("Duplicated order number $iOrder in $sClassName");
|
||||
}
|
||||
$aFixtures[$iOrder][] = $sClassName;
|
||||
}
|
||||
ksort($aFixtures);
|
||||
|
||||
if (count($aFixtures)) {
|
||||
foreach ($aFixtures as $iOrder => $sClassName) {
|
||||
// @todo референсы дублируются в каждом объекте фиксту + в этом объекте
|
||||
$oFixtures = new $sClassName($this->oEngine, $this->aReferences);
|
||||
$oFixtures->load();
|
||||
$aFixtureReference = $oFixtures->getReferences();
|
||||
$this->aReferences = array_merge($this->aReferences, $aFixtureReference);
|
||||
foreach ($aFixtures as $iOrder => $aClassNames) {
|
||||
foreach ($aClassNames as $sClassName) {
|
||||
// @todo референсы дублируются в каждом объекте фиксту + в этом объекте
|
||||
$oFixtures = new $sClassName($this->oEngine, $this->aReferences);
|
||||
$oFixtures->load();
|
||||
$aFixtureReference = $oFixtures->getReferences();
|
||||
$this->aReferences = array_merge($this->aReferences, $aFixtureReference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,8 +138,8 @@ class LoadFixtures
|
|||
* @param string $plugin
|
||||
* @return void
|
||||
*/
|
||||
public function loadPluginFixtures($plugin){
|
||||
$sPath = Config::Get('path.root.server').'/plugins/' . $plugin . '/tests/fixtures';
|
||||
public function loadPluginFixtures($plugin) {
|
||||
$sPath = Config::Get('path.root.server') . '/plugins/' . $plugin . '/tests/fixtures';
|
||||
if (!is_dir($sPath)) {
|
||||
throw new InvalidArgumentException('Plugin not found by LS directory: ' . $sPath, 10);
|
||||
}
|
||||
|
@ -137,5 +148,14 @@ class LoadFixtures
|
|||
$this->loadFixtures();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function of activate plugin
|
||||
*
|
||||
* @param string $plugin
|
||||
*/
|
||||
public function activationPlugin($plugin){
|
||||
$this->oEngine->ModulePlugin_Toggle($plugin,'Activate');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
|
||||
2) В конфиге для Behat (tests/behat/behat.yml) сменить значение опции base_url на хост, под которым проект доступен локально.
|
||||
|
||||
3) Выполнить команду ```cd tests/behat; php behat.phar```. Примерный вывод результата работы команды:
|
||||
3) Выполнить команду ```cd tests/behat; HTTP_APP_ENV=test php behat.phar```. Примерный вывод результата работы команды:
|
||||
|
||||
```
|
||||
DROP DATABASE social_test
|
||||
CREATE DATABASE social_test
|
||||
SELECTED DATABASE social_test
|
||||
ExportSQL DATABASE social_test
|
||||
ExportSQL DATABASE social_test -> geo_base
|
||||
DROP DATABASE social_test
|
||||
CREATE DATABASE social_test
|
||||
SELECTED DATABASE social_test
|
||||
ExportSQL DATABASE social_test
|
||||
ExportSQL DATABASE social_test -> geo_base
|
||||
Feature: LiveStreet standart features
|
||||
Test base functionality of LiveStreet
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class FeatureContext extends MinkContext
|
|||
/**
|
||||
* Purge DB and load fixtures before running each test
|
||||
*
|
||||
* @BeforeSuite
|
||||
* @BeforeScenario
|
||||
*/
|
||||
public static function prepare($event){
|
||||
$fixturesLoader = self::getFixturesLoader();
|
||||
|
@ -56,4 +56,14 @@ class FeatureContext extends MinkContext
|
|||
$fixturesLoader->loadPluginFixtures($plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Given /^I am activated plugin "([^"]*)"$/
|
||||
*/
|
||||
public function ActivatedPlugin($plugin)
|
||||
{
|
||||
$pluginActivation = new LoadFixtures();
|
||||
$pluginActivation->activationPlugin($plugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
14
tests/fixtures/TopicFixtures.php
vendored
14
tests/fixtures/TopicFixtures.php
vendored
|
@ -18,20 +18,20 @@ class TopicFixtures extends AbstractFixtures
|
|||
$oTopicToshiba = $this->_createTopic($oBlogGadgets->getBlogId(), $oUserGolfer->getId(),
|
||||
'Toshiba unveils 13.3-inch AT330 Android ICS 4.0 tablet',
|
||||
'Toshiba is to add a new Android 4.0 ICS to the mass which is known as Toshiba AT330. The device is equipped with a multi-touch capacitive touch display that packs a resolution of 1920 x 1200 pixels. The Toshiba AT330 tablet is currently at its prototype stage. We have very little details about the tablet, knowing that it’ll come equipped with HDMI port, on-board 32GB storage that’s expandable via an full-sized SD card slot. It’ll also have a built-in TV tuner and a collapsible antenna.It’ll also run an NVIDIA Tegra 3 quad-core processor. Other goodies will be a 1.3MP front-facing camera and a 5MP rear-facing camera. Currently, there is no information about its price and availability. A clip is included below showing it in action.',
|
||||
'gadget');
|
||||
'gadget', '2012-10-21 00:10:20');
|
||||
$this->addReference('topic-toshiba', $oTopicToshiba);
|
||||
|
||||
$oTopicIpad = $this->_createTopic($oBlogGadgets->getBlogId(), $oUserGolfer->getId(),
|
||||
'iPad 3 rumored to come this March with quad-core chip and 4G LTE',
|
||||
'Another rumor for the iPad 3 has surfaced with some details given by Bloomberg, claiming that the iPad 3 production is already underway and will be ready for a launch as early as March.',
|
||||
'apple, ipad');
|
||||
'apple, ipad', '2012-10-21 1:20:30');
|
||||
$this->addReference('topic-ipad', $oTopicIpad);
|
||||
|
||||
$oPersonalBlogGolfer = $this->oEngine->Blog_GetPersonalBlogByUserId($oUserGolfer->getId());
|
||||
$oTopicSony = $this->_createTopic($oPersonalBlogGolfer->getBlogId(), $oUserGolfer->getId(),
|
||||
'Sony MicroVault Mach USB 3.0 flash drive',
|
||||
'Want more speeds and better protection for your data? The Sony MicroVault Mach flash USB 3.0 drive is what you need. It offers the USB 3.0 interface that delivers data at super high speeds of up to 5Gbps. It’s also backward compatible with USB 2.0.',
|
||||
'sony, flash, gadget');
|
||||
'sony, flash, gadget', '2012-10-21 2:30:40');
|
||||
$this->addReference('topic-sony', $oTopicSony);
|
||||
}
|
||||
|
||||
|
@ -43,10 +43,11 @@ class TopicFixtures extends AbstractFixtures
|
|||
* @param string $sTitle
|
||||
* @param string $sText
|
||||
* @param string $sTags
|
||||
* @param string $sDate
|
||||
*
|
||||
* @return ModuleTopic_EntityTopic
|
||||
*/
|
||||
private function _createTopic($iBlogId, $iUserId, $sTitle, $sText, $sTags)
|
||||
private function _createTopic($iBlogId, $iUserId, $sTitle, $sText, $sTags, $sDate)
|
||||
{
|
||||
$oTopic = Engine::GetEntity('Topic');
|
||||
/* @var $oTopic ModuleTopic_EntityTopic */
|
||||
|
@ -59,7 +60,7 @@ class TopicFixtures extends AbstractFixtures
|
|||
$oTopic->setPublish(true);
|
||||
$oTopic->setPublishIndex(true);
|
||||
$oTopic->setPublishDraft(true);
|
||||
$oTopic->setDateAdd(date("Y-m-d H:i:s")); // @todo freeze
|
||||
$oTopic->setDateAdd($sDate);
|
||||
$oTopic->setTextSource($sText);
|
||||
list($sTextShort, $sTextNew, $sTextCut) = $this->oEngine->Text_Cut($oTopic->getTextSource());
|
||||
|
||||
|
@ -74,5 +75,4 @@ class TopicFixtures extends AbstractFixtures
|
|||
|
||||
return $oTopic;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue