mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-30 21:45:01 +03:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5dd5d876e5
14
.gitignore
vendored
14
.gitignore
vendored
|
@ -1,6 +1,8 @@
|
|||
/uploads/
|
||||
/templates/cache/
|
||||
/templates/compiled/
|
||||
/logs/
|
||||
/tmp/
|
||||
/config/config.local.php
|
||||
config/config.local.php
|
||||
config/config.test.php
|
||||
logs/*
|
||||
plugins/*
|
||||
templates/cache/*
|
||||
templates/compiled/*
|
||||
tmp/*
|
||||
uploads/*
|
||||
|
|
46
.travis.yml
Normal file
46
.travis.yml
Normal file
|
@ -0,0 +1,46 @@
|
|||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
|
||||
before_script:
|
||||
# export virtual display
|
||||
- export DISPLAY=:99
|
||||
|
||||
# change application working folders for write access
|
||||
- chmod -R 0777 ./tmp
|
||||
- chmod -R 0777 ./uploads
|
||||
- chmod -R 0777 ./templates/cache/
|
||||
- chmod -R 0777 ./templates/compiled/
|
||||
|
||||
# install required PHP stuff
|
||||
- sudo apt-get install php5 php5-cli php5-mysql php5-mcrypt php5-xsl php5-xdebug php-apc php5-gd php5-curl php5-intl
|
||||
|
||||
# launch apache, MySQL and PHPUnit Selenium installers
|
||||
- ./tests/travis/apache_setup.sh
|
||||
- ./tests/travis/mysql_setup.sh
|
||||
- mysql -u root -e "USE social_test; SHOW TABLES;"
|
||||
- cp ./config/config.test.php.dist config/config.test.php
|
||||
- cp ./config/config.test.php.dist config/config.local.php
|
||||
- sudo sed -i s/sql-mode/#sql-mode/ /etc/mysql/my.cnf
|
||||
- sudo /etc/init.d/mysql restart
|
||||
- sleep 5
|
||||
|
||||
# get HTML of main page (for debug)
|
||||
- firefox --version
|
||||
- wget -O /tmp/livestreet.test http://livestreet.test
|
||||
- cat /tmp/livestreet.test
|
||||
|
||||
# start virtual display
|
||||
- sh -e /etc/init.d/xvfb start
|
||||
- sleep 5
|
||||
|
||||
# download and launch Selenium
|
||||
- wget -O /tmp/selenium-server-standalone.jar http://selenium.googlecode.com/files/selenium-server-standalone-2.25.0.jar
|
||||
- java -jar /tmp/selenium-server-standalone.jar > /dev/null &
|
||||
- sleep 5
|
||||
|
||||
# goto test's folder
|
||||
- cd tests/behat/
|
||||
|
||||
script: HTTP_APP_ENV=test php behat.phar
|
7
README.md
Normal file
7
README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
[![Build Status](https://secure.travis-ci.org/stfalcon-studio/livestreet.png?branch=master)](https://travis-ci.org/stfalcon-studio/livestreet)
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
* [English README](https://github.com/livestreet/livestreet/blob/master/Readme.EN.txt)
|
||||
* [Russian README](https://github.com/livestreet/livestreet/blob/master/Readme.RU.txt)
|
|
@ -35,7 +35,7 @@ class HookMain extends Hook {
|
|||
/**
|
||||
* Проверяем наличие директории install
|
||||
*/
|
||||
if(is_dir(rtrim(Config::Get('path.root.server'),'/').'/install')){
|
||||
if(is_dir(rtrim(Config::Get('path.root.server'),'/').'/install') && $_SERVER['HTTP_APP_ENV']!='test'){
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('install_directory_exists'));
|
||||
Router::Action('error');
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
43
config/config.test.php.dist
Normal file
43
config/config.test.php.dist
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* Настройки для тестового сервера.
|
||||
* Для использования - переименовать файл в config.test.php
|
||||
* Более детальная информация о запуске тестов в tests/README.RU.md
|
||||
*/
|
||||
|
||||
/**
|
||||
* Настройка базы данных
|
||||
*/
|
||||
$config['db']['params']['host'] = 'localhost';
|
||||
$config['db']['params']['port'] = '3306';
|
||||
$config['db']['params']['user'] = 'root';
|
||||
$config['db']['params']['pass'] = '';
|
||||
$config['db']['params']['type'] = 'mysql';
|
||||
$config['db']['params']['dbname'] = 'social_test';
|
||||
$config['db']['table']['prefix'] = 'prefix_';
|
||||
|
||||
$config['sys']['cache']['use'] = false; // использовать кеширование или нет
|
||||
$config['sys']['cache']['solid'] = false;
|
||||
|
||||
$config['module']['user']['captcha_use_registration'] = false; // проверять поле капчи при регистрации пользователя
|
||||
|
||||
$config['lang']['current'] = 'english';
|
||||
$config['lang']['default'] = 'english';
|
||||
|
||||
return $config;
|
||||
?>
|
|
@ -48,7 +48,7 @@ if ($hDirConfig = opendir($sDirConfig)) {
|
|||
// то сливаем старые и новое значения ассоциативно
|
||||
Config::Set(
|
||||
$sKey,
|
||||
func_array_merge_assoc(Config::Get($sKey), $aConfig)
|
||||
func_array_merge_assoc(Config::Get($sKey), $aConfig)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ if ($hDirConfig = opendir($sDirConfig)) {
|
|||
// то сливаем старые и новое значения ассоциативно
|
||||
Config::Set(
|
||||
$sKey,
|
||||
func_array_merge_assoc(Config::Get($sKey), $aConfig)
|
||||
func_array_merge_assoc(Config::Get($sKey), $aConfig)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -124,14 +124,27 @@ if ($hDirConfig = opendir($sDirConfig)) {
|
|||
closedir($hDirConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Подгружаем файлы локального и продакшн-конфига
|
||||
*/
|
||||
if(file_exists(Config::Get('path.root.server').'/config/config.local.php')) {
|
||||
Config::LoadFromFile(Config::Get('path.root.server').'/config/config.local.php',false);
|
||||
}
|
||||
if(file_exists(Config::Get('path.root.server').'/config/config.stable.php')) {
|
||||
Config::LoadFromFile(Config::Get('path.root.server').'/config/config.stable.php',false);
|
||||
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 {
|
||||
/**
|
||||
* Подгружаем файлы локального и продакшн-конфига
|
||||
*/
|
||||
if(file_exists(Config::Get('path.root.server').'/config/config.local.php')) {
|
||||
Config::LoadFromFile(Config::Get('path.root.server').'/config/config.local.php',false);
|
||||
}
|
||||
if(file_exists(Config::Get('path.root.server').'/config/config.stable.php')) {
|
||||
Config::LoadFromFile(Config::Get('path.root.server').'/config/config.stable.php',false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,7 +170,7 @@ if($aPluginsList=@file($sPluginsListFile)) {
|
|||
// то сливаем старые и новое значения ассоциативно
|
||||
Config::Set(
|
||||
$sKey,
|
||||
func_array_merge_assoc(Config::Get($sKey), $aConfig)
|
||||
func_array_merge_assoc(Config::Get($sKey), $aConfig)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +183,7 @@ if($aPluginsList=@file($sPluginsListFile)) {
|
|||
if($aIncludeFiles and count($aIncludeFiles)) {
|
||||
foreach ($aIncludeFiles as $sPath) {
|
||||
require_once($sPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
tests/.htaccess
Normal file
2
tests/.htaccess
Normal file
|
@ -0,0 +1,2 @@
|
|||
Order Deny,Allow
|
||||
Deny from all
|
87
tests/AbstractFixtures.php
Normal file
87
tests/AbstractFixtures.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Abstract class for LiveStreet fixtures
|
||||
*/
|
||||
abstract class AbstractFixtures
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Engine
|
||||
*/
|
||||
protected $oEngine;
|
||||
|
||||
/**
|
||||
* Objects references
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $aReferences = array();
|
||||
|
||||
/**
|
||||
* @param Engine $oEngine
|
||||
* @param array $aReferences
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Engine $oEngine, $aReferences)
|
||||
{
|
||||
$this->oEngine = $oEngine;
|
||||
$this->aReferences = $aReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add reference
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
public function addReference($name, $data)
|
||||
{
|
||||
$this->aReferences[$name] = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get reference by key
|
||||
*
|
||||
* @param string $key
|
||||
* @throws Exception if reference is not exist
|
||||
* @return array aReferences
|
||||
* @return void
|
||||
*/
|
||||
public function getReference($key)
|
||||
{
|
||||
if (isset($this->aReferences[$key])) {
|
||||
return $this->aReferences[$key];
|
||||
}
|
||||
|
||||
throw new Exception("Fixture reference \"$key\" is not exist");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all references
|
||||
*
|
||||
* @return array aReferences
|
||||
*/
|
||||
public function getReferences()
|
||||
{
|
||||
return $this->aReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating entities and saving them to DB
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function load();
|
||||
|
||||
/**
|
||||
* Get order number for fixture
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getOrder() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
161
tests/LoadFixtures.php
Normal file
161
tests/LoadFixtures.php
Normal file
|
@ -0,0 +1,161 @@
|
|||
<?php
|
||||
|
||||
require_once("config/loader.php");
|
||||
require_once("engine/classes/Engine.class.php");
|
||||
|
||||
/**
|
||||
* Class for load fixtures
|
||||
*/
|
||||
class LoadFixtures
|
||||
{
|
||||
|
||||
/**
|
||||
* Main objects references array
|
||||
*
|
||||
* @var array $aReferences
|
||||
*/
|
||||
private $aReferences = array();
|
||||
|
||||
/**
|
||||
* @var Engine
|
||||
*/
|
||||
private $oEngine;
|
||||
|
||||
/**
|
||||
* The directory of the fixtures for tests
|
||||
*
|
||||
* @var string $sDirFixtures
|
||||
*/
|
||||
private $sDirFixtures;
|
||||
|
||||
public function __construct() {
|
||||
$this->oEngine = Engine::getInstance();
|
||||
$this->oEngine->Init();
|
||||
$this->sDirFixtures = realpath((dirname(__FILE__)) . "/fixtures/");
|
||||
}
|
||||
|
||||
public function load() {
|
||||
$this->loadFixtures();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recreate database from SQL dumps
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function purgeDB() {
|
||||
$sDbname = Config::Get('db.params.dbname');
|
||||
|
||||
if (mysql_select_db($sDbname)) {
|
||||
|
||||
$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 sql.sql
|
||||
$result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/sql.sql');
|
||||
|
||||
if (!$result['result']) {
|
||||
// exception
|
||||
throw new Exception("DB is not exported with file sql.sql");
|
||||
return $result['errors'];
|
||||
}
|
||||
echo "ExportSQL DATABASE $sDbname -> sql.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";
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function of loading fixtures from tests/fixtures/
|
||||
*
|
||||
* @var array $aFiles
|
||||
* @var array $iOrder
|
||||
* @return void
|
||||
*/
|
||||
private function loadFixtures() {
|
||||
$aFiles = glob("{$this->sDirFixtures}/*Fixtures.php");
|
||||
$aFixtures = array();
|
||||
foreach ($aFiles as $sFilePath) {
|
||||
require_once "{$sFilePath}";
|
||||
$iOrder = BlogFixtures::getOrder();
|
||||
|
||||
preg_match("/([a-zA-Z]+Fixtures).php$/", $sFilePath, $matches);
|
||||
$sClassName = $matches[1];
|
||||
$iOrder = forward_static_call(array($sClassName, 'getOrder'));
|
||||
$aFixtures[$iOrder][] = $sClassName;
|
||||
}
|
||||
ksort($aFixtures);
|
||||
|
||||
if (count($aFixtures)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function of loading plugin fixtures
|
||||
*
|
||||
* @param string $plugin
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
$this->sDirFixtures = $sPath;
|
||||
$this->loadFixtures();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function of activate plugin
|
||||
*
|
||||
* @param string $plugin
|
||||
*/
|
||||
public function activationPlugin($plugin){
|
||||
$this->oEngine->ModulePlugin_Toggle($plugin,'Activate');
|
||||
}
|
||||
|
||||
}
|
||||
|
49
tests/README.md
Normal file
49
tests/README.md
Normal file
|
@ -0,0 +1,49 @@
|
|||
Запуск функциональных тестов
|
||||
============================
|
||||
|
||||
Для запуска тестов проекта нужно:
|
||||
|
||||
1) Переименовать файл config/config.test.php.dist в config/config.test.php и изменить настройки подключения к тестовой БД.
|
||||
ВАЖНО! Информация в этой БД будет перезаписываться при каждом запуске теста.
|
||||
|
||||
2) В конфиге для Behat (tests/behat/behat.yml) сменить значение опции base_url на хост, под которым проект доступен локально.
|
||||
|
||||
3) Выполнить команду ```HTTP_APP_ENV=test php tests/behat/behat.phar -c tests/behat/behat.yml```. Примерный вывод результата работы команды:
|
||||
|
||||
```
|
||||
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
|
||||
|
||||
Scenario: See main page # features/base.feature:4
|
||||
Given I am on homepage # FeatureContext::iAmOnHomepage()
|
||||
When I press "Войти" # FeatureContext::pressButton()
|
||||
Then the response status code should be 200 # FeatureContext::assertResponseStatus()
|
||||
|
||||
Scenario: See Colective Blog # features/base.feature:9
|
||||
Given I am on "/blog/gadgets" # FeatureContext::visit()
|
||||
Then I should see "Gadgets" # FeatureContext::assertPageContainsText()
|
||||
Then I should see "Offers latest gadget reviews" # FeatureContext::assertPageContainsText()
|
||||
|
||||
Scenario: See list of blogs # features/base.feature:14
|
||||
Given I am on "/blogs/" # FeatureContext::visit()
|
||||
Then I should see "Gadgets" # FeatureContext::assertPageContainsText()
|
||||
|
||||
Scenario: See All Topic # features/base.feature:18
|
||||
Given I am on "/index/newall/" # FeatureContext::visit()
|
||||
Then I should see "iPad 3 rumored to come this March with quad-core chip and 4G LTE " # FeatureContext::assertPageContainsText()
|
||||
Then I should see "Toshiba unveils 13.3-inch AT330 Android ICS 4.0 tablet" # FeatureContext::assertPageContainsText()
|
||||
|
||||
Scenario: See User Profile # features/base.feature:23
|
||||
Given I am on "/profile/Golfer/" # FeatureContext::visit()
|
||||
Then I should see "Sergey Doryba" # FeatureContext::assertPageContainsText()
|
||||
Then I should see "... Sergey Doryba profile description" # FeatureContext::assertPageContainsText()
|
||||
|
||||
5 scenarios (5 passed)
|
||||
14 steps (14 passed)
|
||||
0m2.225s
|
||||
```
|
BIN
tests/behat/behat.phar
Normal file
BIN
tests/behat/behat.phar
Normal file
Binary file not shown.
13
tests/behat/behat.yml
Normal file
13
tests/behat/behat.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
# behat.yml
|
||||
default:
|
||||
extensions:
|
||||
mink_extension.phar:
|
||||
base_url: http://livestreet.test/
|
||||
default_session: goutte
|
||||
mink_loader: mink.phar
|
||||
goutte:
|
||||
server_parameters:
|
||||
APP_ENV: test
|
||||
selenium2:
|
||||
wd_host: 'http://127.0.0.1:4444/wd/hub'
|
||||
capabilities: { "browser": "firefox", "browserVersion": "10", "browserName": "firefox", "version": "10"}
|
42
tests/behat/features/base.feature
Normal file
42
tests/behat/features/base.feature
Normal file
|
@ -0,0 +1,42 @@
|
|||
Feature: LiveStreet standart features
|
||||
Test base functionality of LiveStreet
|
||||
|
||||
Scenario: See main page
|
||||
Given I am on homepage
|
||||
Then the response status code should be 200
|
||||
|
||||
Then I should see "Sony MicroVault Mach USB 3.0 flash drive"
|
||||
Then I should see "Blogger's name golfer"
|
||||
|
||||
Then I should see "iPad 3 rumored to come this March with quad-core chip and 4G LTE "
|
||||
Then I should see "Toshiba unveils 13.3-inch AT330 Android ICS 4.0 tablet"
|
||||
Then I should see "Gadgets"
|
||||
|
||||
Scenario: See colective blog
|
||||
Given I am on "/blog/gadgets"
|
||||
Then the response status code should be 200
|
||||
|
||||
Then I should see "Gadgets"
|
||||
Then I should see "Offers latest gadget reviews"
|
||||
|
||||
Scenario: See list of all blogs
|
||||
Given I am on "/blogs/"
|
||||
Then the response status code should be 200
|
||||
|
||||
Then I should see "Gadgets"
|
||||
Then I should see "golfer"
|
||||
|
||||
Scenario: See all new topics
|
||||
Given I am on "/index/newall/"
|
||||
Then the response status code should be 200
|
||||
|
||||
Then I should see "Sony MicroVault Mach USB 3.0 flash drive"
|
||||
Then I should see "iPad 3 rumored to come this March with quad-core chip and 4G LTE "
|
||||
Then I should see "Toshiba unveils 13.3-inch AT330 Android ICS 4.0 tablet"
|
||||
|
||||
Scenario: See user profile
|
||||
Given I am on "/profile/Golfer/"
|
||||
Then the response status code should be 200
|
||||
|
||||
Then I should see "Sergey Doryba"
|
||||
Then I should see "... Sergey Doryba profile description"
|
77
tests/behat/features/bootstrap/BaseFeatureContext.php
Normal file
77
tests/behat/features/bootstrap/BaseFeatureContext.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
use Behat\Behat\Context\ClosuredContextInterface,
|
||||
Behat\Behat\Context\TranslatedContextInterface,
|
||||
Behat\Behat\Context\BehatContext,
|
||||
Behat\MinkExtension\Context\MinkContext,
|
||||
Behat\Behat\Exception\PendingException;
|
||||
use Behat\Gherkin\Node\PyStringNode,
|
||||
Behat\Gherkin\Node\TableNode;
|
||||
|
||||
$sDirRoot = dirname(realpath((dirname(__FILE__)) . "/../../../"));
|
||||
set_include_path(get_include_path().PATH_SEPARATOR.$sDirRoot);
|
||||
|
||||
require_once("tests/LoadFixtures.php");
|
||||
|
||||
/**
|
||||
* LiveStreet custom feature context
|
||||
*/
|
||||
class BaseFeatureContext extends MinkContext
|
||||
{
|
||||
|
||||
protected static $fixturesLoader = null;
|
||||
|
||||
/**
|
||||
* Get fixtures loader
|
||||
* @return LoadFixtures
|
||||
*/
|
||||
protected static function getFixturesLoader()
|
||||
{
|
||||
if (is_null(self::$fixturesLoader)) {
|
||||
self::$fixturesLoader = new LoadFixtures();
|
||||
}
|
||||
|
||||
return self::$fixturesLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge DB and load fixtures before running each test
|
||||
*
|
||||
* @BeforeScenario
|
||||
*/
|
||||
public static function prepare($event){
|
||||
$fixturesLoader = self::getFixturesLoader();
|
||||
$fixturesLoader->purgeDB();
|
||||
$fixturesLoader->load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loading fixture for plugin
|
||||
*
|
||||
* @Given /^I load fixtures for plugin "([^"]*)"$/
|
||||
*/
|
||||
public function loadFixturesForPlugin($plugin)
|
||||
{
|
||||
$fixturesLoader = $this->getFixturesLoader();
|
||||
$fixturesLoader->loadPluginFixtures($plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Given /^I am activated plugin "([^"]*)"$/
|
||||
*/
|
||||
public function ActivatedPlugin($plugin)
|
||||
{
|
||||
$pluginActivation = new LoadFixtures();
|
||||
$pluginActivation->activationPlugin($plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^I wait "([^"]*)"$/
|
||||
*/
|
||||
public function iWait($time_wait)
|
||||
{
|
||||
$this->getSession()->wait($time_wait);
|
||||
}
|
||||
|
||||
}
|
11
tests/behat/features/bootstrap/FeatureContext.php
Normal file
11
tests/behat/features/bootstrap/FeatureContext.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
require_once("BaseFeatureContext.php");
|
||||
|
||||
/**
|
||||
* LiveStreet custom feature context
|
||||
*/
|
||||
class FeatureContext extends BaseFeatureContext
|
||||
{
|
||||
|
||||
}
|
BIN
tests/behat/mink.phar
Normal file
BIN
tests/behat/mink.phar
Normal file
Binary file not shown.
BIN
tests/behat/mink_extension.phar
Normal file
BIN
tests/behat/mink_extension.phar
Normal file
Binary file not shown.
31
tests/fixtures/BlogFixtures.php
vendored
Normal file
31
tests/fixtures/BlogFixtures.php
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
require_once(realpath((dirname(__FILE__)) . "/../AbstractFixtures.php"));
|
||||
|
||||
class BlogFixtures extends AbstractFixtures
|
||||
{
|
||||
public static function getOrder()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function load()
|
||||
{
|
||||
$oUserStfalcon = $this->getReference('user-golfer');
|
||||
|
||||
/* @var $oBlogGadgets ModuleBlog_EntityBlog */
|
||||
$oBlogGadgets = Engine::GetEntity('Blog');
|
||||
$oBlogGadgets->setOwnerId($oUserStfalcon->getId());
|
||||
$oBlogGadgets->setTitle("Gadgets");
|
||||
$oBlogGadgets->setDescription('Offers latest gadget reviews');
|
||||
$oBlogGadgets->setType('open');
|
||||
$oBlogGadgets->setDateAdd(date("Y-m-d H:i:s")); // @todo freeze
|
||||
$oBlogGadgets->setUrl('gadgets');
|
||||
$oBlogGadgets->setLimitRatingTopic(0);
|
||||
|
||||
$this->oEngine->Blog_AddBlog($oBlogGadgets);
|
||||
|
||||
$this->addReference('blog-gadgets', $oBlogGadgets);
|
||||
}
|
||||
}
|
||||
|
78
tests/fixtures/TopicFixtures.php
vendored
Normal file
78
tests/fixtures/TopicFixtures.php
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
require_once(realpath((dirname(__FILE__)) . "/../AbstractFixtures.php"));
|
||||
|
||||
class TopicFixtures extends AbstractFixtures
|
||||
{
|
||||
|
||||
public static function getOrder()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function load()
|
||||
{
|
||||
$oUserGolfer = $this->getReference('user-golfer');
|
||||
$oBlogGadgets = $this->getReference('blog-gadgets');
|
||||
|
||||
$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', '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', '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', '2012-10-21 2:30:40');
|
||||
$this->addReference('topic-sony', $oTopicSony);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create topic with default values
|
||||
*
|
||||
* @param int $iBlogId
|
||||
* @param int $iUserId
|
||||
* @param string $sTitle
|
||||
* @param string $sText
|
||||
* @param string $sTags
|
||||
* @param string $sDate
|
||||
*
|
||||
* @return ModuleTopic_EntityTopic
|
||||
*/
|
||||
private function _createTopic($iBlogId, $iUserId, $sTitle, $sText, $sTags, $sDate)
|
||||
{
|
||||
$oTopic = Engine::GetEntity('Topic');
|
||||
/* @var $oTopic ModuleTopic_EntityTopic */
|
||||
$oTopic->setBlogId($iBlogId);
|
||||
$oTopic->setUserId($iUserId);
|
||||
$oTopic->setUserIp('127.0.0.1');
|
||||
$oTopic->setForbidComment(false);
|
||||
$oTopic->setType('topic');
|
||||
$oTopic->setTitle($sTitle);
|
||||
$oTopic->setPublish(true);
|
||||
$oTopic->setPublishIndex(true);
|
||||
$oTopic->setPublishDraft(true);
|
||||
$oTopic->setDateAdd($sDate);
|
||||
$oTopic->setTextSource($sText);
|
||||
list($sTextShort, $sTextNew, $sTextCut) = $this->oEngine->Text_Cut($oTopic->getTextSource());
|
||||
|
||||
$oTopic->setCutText($sTextCut);
|
||||
$oTopic->setText($this->oEngine->Text_Parser($sTextNew));
|
||||
$oTopic->setTextShort($this->oEngine->Text_Parser($sTextShort));
|
||||
|
||||
$oTopic->setTextHash(md5($oTopic->getType() . $oTopic->getTextSource() . $oTopic->getTitle()));
|
||||
$oTopic->setTags($sTags);
|
||||
|
||||
$this->oEngine->Topic_AddTopic($oTopic);
|
||||
|
||||
return $oTopic;
|
||||
}
|
||||
}
|
36
tests/fixtures/UserFixtures.php
vendored
Normal file
36
tests/fixtures/UserFixtures.php
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
require_once(realpath((dirname(__FILE__)) . "/../AbstractFixtures.php"));
|
||||
|
||||
class UserFixtures extends AbstractFixtures
|
||||
{
|
||||
public static function getOrder()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function load()
|
||||
{
|
||||
|
||||
$oUserGolfer = Engine::GetEntity('User');
|
||||
$oUserGolfer->setLogin('golfer');
|
||||
$oUserGolfer->setPassword(md5('qwerty'));
|
||||
$oUserGolfer->setMail('golfer@gmail.com');
|
||||
|
||||
$oUserGolfer->setUserDateRegister(date("Y-m-d H:i:s")); // @todo freeze
|
||||
$oUserGolfer->setUserIpRegister('127.0.0.1');
|
||||
$oUserGolfer->setUserActivate('1');
|
||||
$oUserGolfer->setUserActivateKey('0');
|
||||
|
||||
$this->oEngine->User_Add($oUserGolfer);
|
||||
|
||||
$oUserGolfer->setProfileName('Sergey Doryba');
|
||||
$oUserGolfer->setProfileAbout('... Sergey Doryba profile description');
|
||||
$oUserGolfer->setProfileSex('man');
|
||||
|
||||
$this->oEngine->User_Update($oUserGolfer);
|
||||
$this->addReference('user-golfer', $oUserGolfer);
|
||||
}
|
||||
|
||||
}
|
||||
|
1
tests/fixtures/sql/geo_base.sql
vendored
Symbolic link
1
tests/fixtures/sql/geo_base.sql
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../install/geo_base.sql
|
1
tests/fixtures/sql/sql.sql
vendored
Symbolic link
1
tests/fixtures/sql/sql.sql
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../install/sql.sql
|
7
tests/travis/apache_setup.sh
Executable file
7
tests/travis/apache_setup.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
sudo apt-get install apache2 libapache2-mod-php5 curl
|
||||
sudo a2enmod rewrite
|
||||
echo "$(curl -fsSL https://raw.github.com/stfalcon-studio/livestreet/master/tests/travis/configs/apache_vhost)" | sed -e "s,PATH,`pwd`,g" | sudo tee -a /etc/apache2/sites-available/default > /dev/null
|
||||
echo "$(curl -fsSL https://raw.github.com/stfalcon-studio/livestreet/master/tests/travis/configs/hosts)" | sudo tee -a /etc/hosts > /dev/null
|
||||
sudo service apache2 restart
|
29
tests/travis/configs/apache_vhost
Normal file
29
tests/travis/configs/apache_vhost
Normal file
|
@ -0,0 +1,29 @@
|
|||
<VirtualHost *:80>
|
||||
ServerAdmin webmaster@localhost
|
||||
|
||||
DocumentRoot PATH
|
||||
ServerName livestreet.test
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/livestreet.log
|
||||
|
||||
# Possible values include: debug, info, notice, warn, error, crit,
|
||||
# alert, emerg.
|
||||
LogLevel warn
|
||||
|
||||
CustomLog ${APACHE_LOG_DIR}/livestreet.log combined
|
||||
</VirtualHost>
|
||||
|
||||
<VirtualHost *:80>
|
||||
ServerAdmin webmaster@localhost
|
||||
|
||||
DocumentRoot PATH
|
||||
ServerName livestreet.test
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/livestreet.log
|
||||
|
||||
# Possible values include: debug, info, notice, warn, error, crit,
|
||||
# alert, emerg.
|
||||
LogLevel warn
|
||||
|
||||
CustomLog ${APACHE_LOG_DIR}/livestreet.log combined
|
||||
</VirtualHost>
|
1
tests/travis/configs/hosts
Normal file
1
tests/travis/configs/hosts
Normal file
|
@ -0,0 +1 @@
|
|||
127.0.0.1 livestreet.test
|
6
tests/travis/mysql_setup.sh
Executable file
6
tests/travis/mysql_setup.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
sudo apt-get install mysql-server mysql-client
|
||||
mysql -u root -e 'CREATE DATABASE social_test;'
|
||||
mysql -u root -B social_test < ./tests/fixtures/sql/sql.sql
|
||||
mysql -u root -B social_test < ./tests/fixtures/sql/geo_base.sql
|
Loading…
Reference in a new issue