mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-17 07:10:48 +03:00
test commits optimization
This commit is contained in:
parent
77ae613a53
commit
f85f1c5597
|
@ -13,9 +13,12 @@ before_script:
|
|||
- chmod -R 0777 ./uploads
|
||||
- chmod -R 0777 ./templates/cache/
|
||||
- chmod -R 0777 ./templates/compiled/
|
||||
- cp ./install/*.sql tests/fixtures/sql/
|
||||
- rm -rf ./install
|
||||
|
||||
# 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
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install php5 php5-cli php5-mysql php5-mcrypt php5-xsl php5-xdebug php-apc php5-gd php5-curl php5-intl mysql-server mysql-client
|
||||
|
||||
# launch apache, MySQL and PHPUnit Selenium installers
|
||||
- ./tests/travis/apache_setup.sh
|
||||
|
@ -28,6 +31,7 @@ before_script:
|
|||
- sleep 5
|
||||
|
||||
# get HTML of main page (for debug)
|
||||
|
||||
- firefox --version
|
||||
- wget -S http://livestreet.test -O /dev/null
|
||||
|
||||
|
@ -36,7 +40,7 @@ before_script:
|
|||
- sleep 5
|
||||
|
||||
# download and launch Selenium
|
||||
- wget -O /tmp/selenium-server-standalone.jar http://selenium.googlecode.com/files/selenium-server-standalone-2.31.0.jar
|
||||
- wget -O /tmp/selenium-server-standalone.jar http://selenium.dev.stfalcon.com/selenium-server-standalone-latest.jar
|
||||
- java -jar /tmp/selenium-server-standalone.jar > /dev/null &
|
||||
- sleep 5
|
||||
|
||||
|
|
19561
install/geo_base.sql
19561
install/geo_base.sql
File diff suppressed because it is too large
Load diff
1031
install/sql.sql
1031
install/sql.sql
File diff suppressed because it is too large
Load diff
|
@ -18,6 +18,8 @@ abstract class AbstractFixtures
|
|||
*/
|
||||
private $aReferences = array();
|
||||
|
||||
private $aActivePlugins = array();
|
||||
|
||||
/**
|
||||
* @param Engine $oEngine
|
||||
* @param array $aReferences
|
||||
|
@ -27,6 +29,7 @@ abstract class AbstractFixtures
|
|||
{
|
||||
$this->oEngine = $oEngine;
|
||||
$this->aReferences = $aReferences;
|
||||
$this->aActivePlugins = $oEngine->Plugin_GetActivePlugins();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,8 +83,162 @@ abstract class AbstractFixtures
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getOrder() {
|
||||
public static function getOrder()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Active Plugins
|
||||
*
|
||||
* @return Active Plugins
|
||||
*/
|
||||
protected function getActivePlugins()
|
||||
{
|
||||
return $this->aActivePlugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create topic with default values
|
||||
*
|
||||
* @param int $iBlogId
|
||||
* @param int $iUserId
|
||||
* @param string $sTitle
|
||||
* @param string $sText
|
||||
* @param string $sTags
|
||||
* @param string $sDate
|
||||
* @param bool $bPublish
|
||||
* @param bool $bPublishMain
|
||||
* @param bool $bPublishDraft
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return ModuleTopic_EntityTopic
|
||||
*/
|
||||
protected function _createTopic($iBlogId, $iUserId, $sTitle, $sText, $sTags, $sDate, $bPublish = true, $bPublishMain = true, $bPublishDraft = true)
|
||||
{
|
||||
$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($bPublish);//
|
||||
$oTopic->setPublishIndex($bPublishMain);//
|
||||
$oTopic->setPublishDraft($bPublishDraft);
|
||||
$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);
|
||||
//with active plugin l10n added a field topic_lang
|
||||
if (in_array('l10n', $this->getActivePlugins())) {
|
||||
$oTopic->setTopicLang(Config::Get('lang.current'));
|
||||
}
|
||||
// @todo refact this
|
||||
$oTopic->_setValidateScenario('topic');
|
||||
$bValid = $oTopic->_Validate();
|
||||
|
||||
if (!$bValid) {
|
||||
throw new Exception("Create topic - validation error");
|
||||
}
|
||||
|
||||
$this->oEngine->Topic_AddTopic($oTopic);
|
||||
|
||||
return $oTopic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user with default values
|
||||
*
|
||||
* @param string $sUserName
|
||||
* @param string $sPassword
|
||||
* @param string $sMail
|
||||
* @param string $sDate
|
||||
*
|
||||
* @return ModuleTopic_EntityUser
|
||||
*/
|
||||
protected function _createUser($sUserName, $sPassword, $sMail, $sDate)
|
||||
{
|
||||
$oUser = Engine::GetEntity('User');
|
||||
$oUser->setLogin($sUserName);
|
||||
$oUser->setPassword(md5($sPassword));
|
||||
$oUser->setMail($sMail);
|
||||
$oUser->setUserDateRegister($sDate);
|
||||
$oUser->setUserIpRegister('127.0.0.1');
|
||||
$oUser->setUserActivate('1');
|
||||
$oUser->setUserActivateKey('0');
|
||||
|
||||
$this->oEngine->User_Add($oUser);
|
||||
|
||||
return $oUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create topic comment with default values
|
||||
*
|
||||
* @param object $oTopic
|
||||
* @param object $oUser
|
||||
* @param integer $iParentId
|
||||
* @param string $sText
|
||||
*
|
||||
* @return ModuleComment_EntityComment
|
||||
*/
|
||||
protected function _createComment($oTopic, $oUser, $iParentId = null, $sText = 'fixture comment text')
|
||||
{
|
||||
$oComment = Engine::GetEntity('Comment');
|
||||
$oComment->setTargetId($oTopic->getId());
|
||||
$oComment->setTargetType('topic');
|
||||
$oComment->setTargetParentId($oTopic->getBlogId());
|
||||
$oComment->setUserId($oUser->getId());
|
||||
$oComment->setText($sText);
|
||||
$oComment->setDate(date('Y-m-d H:i:s', time()));
|
||||
$oComment->setUserIp(func_getIp());
|
||||
$oComment->setPid($iParentId);
|
||||
$oComment->setTextHash(md5($sText));
|
||||
$oComment->setPublish(true);
|
||||
|
||||
$oComment = $this->oEngine->Comment_AddComment($oComment);
|
||||
|
||||
return $oComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Blog Category
|
||||
*
|
||||
* @param string $sTitle
|
||||
* @param string $sUrl
|
||||
* @param integer $iSort
|
||||
* @param integer $iPid
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return ModuleBlog_EntityBlogCategory
|
||||
*/
|
||||
protected function _createCategory($sTitle, $sUrl, $iSort = 0, $iPid = null)
|
||||
{
|
||||
$oCategory = Engine::GetEntity('ModuleBlog_EntityBlogCategory');
|
||||
$oCategory->setTitle($sTitle);
|
||||
$oCategory->setUrl($sUrl);
|
||||
$oCategory->setSort($iSort);
|
||||
$oCategory->setPid($iPid);
|
||||
|
||||
if ($oCategory->_Validate()) {
|
||||
$iCategoryId = $this->oEngine->Blog_AddCategory($oCategory);
|
||||
$oCategory = $this->oEngine->Blog_GetCategoryById($iCategoryId);
|
||||
|
||||
return $oCategory;
|
||||
|
||||
} else {
|
||||
throw new Exception("Create category - validation error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,19 @@ class LoadFixtures
|
|||
}
|
||||
echo "ExportSQL DATABASE $sDbname -> install_base.sql \n";
|
||||
// Load dump from geo_base.sql
|
||||
|
||||
if(file_exists(Config::Get('path.root.server') . '/tests/fixtures/sql/patch.sql')) {
|
||||
$result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/patch.sql');
|
||||
|
||||
if (!$result['result']) {
|
||||
// exception
|
||||
throw new Exception("DB is not exported with file patch.sql");
|
||||
return $result['errors'];
|
||||
}
|
||||
echo "ExportSQL DATABASE $sDbname -> patch.sql \n";
|
||||
// Load dump from patch.sql
|
||||
}
|
||||
|
||||
$result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/geo_base.sql');
|
||||
|
||||
if (!$result['result']) {
|
||||
|
|
|
@ -8,9 +8,7 @@ Feature: Test Base comment functionality (!!!SELENIUM NEEDED)
|
|||
Then I want to login as "admin"
|
||||
|
||||
Given I am on homepage
|
||||
Then I follow "Sony MicroVault Mach USB 3.0 flash drive"
|
||||
|
||||
Then I wait "1000"
|
||||
Given I am on "/blog/3.html"
|
||||
|
||||
Then I follow "Add comment"
|
||||
And I fill in "test comment" for "comment_text"
|
||||
|
@ -28,19 +26,10 @@ Feature: Test Base comment functionality (!!!SELENIUM NEEDED)
|
|||
| value |
|
||||
| test comment |
|
||||
|
||||
Then I should see in element by css "content .comment-info" values:
|
||||
Then I should see in element by css "content .comment-author" values:
|
||||
| value |
|
||||
| /profile/admin/">admin</a> |
|
||||
Then I should see in element by css "content .comment-actions" values:
|
||||
| value |
|
||||
| Reply |
|
||||
| Delete |
|
||||
|
||||
#create subcomment
|
||||
And I follow "Reply"
|
||||
Then I wait "1000"
|
||||
And I fill in "test subcomment" for "comment_text"
|
||||
And I press "Add"
|
||||
Then I wait "1000"
|
||||
|
||||
Then I should see in element by css "comment_wrapper_id_2" values:
|
||||
| value |
|
||||
| test subcomment |
|
59
tests/behat/features/comment.feature.incomplete
Normal file
59
tests/behat/features/comment.feature.incomplete
Normal file
|
@ -0,0 +1,59 @@
|
|||
Feature: Test Base comment functionality (!!!SELENIUM NEEDED)
|
||||
Test base functionality of Comments
|
||||
|
||||
@mink:selenium2
|
||||
Scenario: Adding the comment
|
||||
|
||||
Given I am on "/login"
|
||||
Then I want to login as "admin"
|
||||
|
||||
Given I am on homepage
|
||||
Given I am on "/blog/3.html"
|
||||
Then I follow "Add comment"
|
||||
And I fill in "test comment" for "comment_text"
|
||||
And I press "Preview"
|
||||
Then I wait "2000"
|
||||
|
||||
Then I should see in element by css "content .comment-preview" values:
|
||||
| value |
|
||||
| test comment |
|
||||
|
||||
And I press "Add"
|
||||
Then I wait "1000"
|
||||
|
||||
Then I should see in element by css "content .comment-content" values:
|
||||
| value |
|
||||
| test comment |
|
||||
|
||||
Then I should see in element by css "content .comment-author" values:
|
||||
| value |
|
||||
| /profile/admin/">admin</a> |
|
||||
Then I should see in element by css "content .comment-actions" values:
|
||||
| value |
|
||||
| Reply |
|
||||
| Delete |
|
||||
|
||||
@mink:selenium2
|
||||
Scenario: Reply for comment
|
||||
Given I am on "/login"
|
||||
Then I want to login as "admin"
|
||||
|
||||
Then I am on "/blog/gadgets/1.html"
|
||||
Then I should see "fixture comment text"
|
||||
|
||||
Then I should see in element by css "content .comment-wrapper .comment-actions" values:
|
||||
| value |
|
||||
| Reply |
|
||||
|
||||
And I follow "Reply"
|
||||
Then I wait "1000"
|
||||
And I fill in "test subcomment" for "comment_text"
|
||||
|
||||
#Then print last response
|
||||
|
||||
And I press "Add"
|
||||
Then I wait "1000"
|
||||
|
||||
Then I should see in element by css "#comment_content_id_2" values:
|
||||
| value |
|
||||
| test subcomment |
|
10
tests/fixtures/BlogFixtures.php
vendored
10
tests/fixtures/BlogFixtures.php
vendored
|
@ -4,14 +4,21 @@ require_once(realpath((dirname(__FILE__)) . "/../AbstractFixtures.php"));
|
|||
|
||||
class BlogFixtures extends AbstractFixtures
|
||||
{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public static function getOrder()
|
||||
{
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Blog
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
$oUserFirst = $this->getReference('user-golfer');
|
||||
$oCategory = $this->getReference('blog-category');
|
||||
|
||||
/* @var $oBlogGadgets ModuleBlog_EntityBlog */
|
||||
$oBlogGadgets = Engine::GetEntity('Blog');
|
||||
|
@ -22,6 +29,7 @@ class BlogFixtures extends AbstractFixtures
|
|||
$oBlogGadgets->setDateAdd(date("Y-m-d H:i:s")); // @todo freeze
|
||||
$oBlogGadgets->setUrl('gadgets');
|
||||
$oBlogGadgets->setLimitRatingTopic(0);
|
||||
$oBlogGadgets->setCategoryId($oCategory->getCategoryId());
|
||||
|
||||
$this->oEngine->Blog_AddBlog($oBlogGadgets);
|
||||
|
||||
|
|
24
tests/fixtures/CategoryFixtures.php
vendored
Normal file
24
tests/fixtures/CategoryFixtures.php
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
require_once(realpath((dirname(__FILE__)) . "/../AbstractFixtures.php"));
|
||||
|
||||
class CategoryFixtures extends AbstractFixtures
|
||||
{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public static function getOrder()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Category
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
$oBlogCategory = $this->_createCategory('First category name', 'first_category_url');
|
||||
|
||||
$this->addReference('blog-category', $oBlogCategory);
|
||||
}
|
||||
}
|
28
tests/fixtures/CommentFixtures.php
vendored
Normal file
28
tests/fixtures/CommentFixtures.php
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
require_once(realpath((dirname(__FILE__)) . "/../AbstractFixtures.php"));
|
||||
|
||||
class CommentFixtures extends AbstractFixtures
|
||||
{
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public static function getOrder()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Comment
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
$oUserFirst = $this->getReference('user-golfer');
|
||||
$oTopic = $this->getReference('topic-toshiba');
|
||||
|
||||
$oTopicComment = $this->_createComment($oTopic, $oUserFirst, NULL, 'fixture comment text');
|
||||
$this->addReference('topic-toshiba-comment', $oTopicComment);
|
||||
|
||||
}
|
||||
}
|
68
tests/fixtures/TopicFixtures.php
vendored
68
tests/fixtures/TopicFixtures.php
vendored
|
@ -4,13 +4,21 @@ require_once(realpath((dirname(__FILE__)) . "/../AbstractFixtures.php"));
|
|||
|
||||
class TopicFixtures extends AbstractFixtures
|
||||
{
|
||||
|
||||
protected $aActivePlugins = array();
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public static function getOrder()
|
||||
{
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Topics:
|
||||
* Toshiba unveils 13.3-inch AT330 Android ICS 4.0 tablet,
|
||||
* iPad 3 rumored to come this March with quad-core chip and 4G LTE,
|
||||
* Sony MicroVault Mach USB 3.0 flash drive,
|
||||
* Draft Topic
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
$oUserFirst = $this->getReference('user-golfer');
|
||||
|
@ -34,55 +42,11 @@ class TopicFixtures extends AbstractFixtures
|
|||
'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)
|
||||
{
|
||||
$this->aActivePlugins = $this->oEngine->Plugin_GetActivePlugins();
|
||||
|
||||
$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);
|
||||
//with active plugin l10n added a field topic_lang
|
||||
if (in_array('l10n', $this->aActivePlugins)) {
|
||||
$oTopic->setTopicLang(Config::Get('lang.current'));
|
||||
}
|
||||
// @todo refact this
|
||||
$oTopic->_setValidateScenario('topic');
|
||||
$oTopic->_Validate();
|
||||
|
||||
$this->oEngine->Topic_AddTopic($oTopic);
|
||||
|
||||
return $oTopic;
|
||||
$oTopicDraft = $this->_createTopic($oPersonalBlogGolfer->getBlogId(), $oUserFirst->getId(),
|
||||
'Draft Topic',
|
||||
'draft text draft text draft text draft text draft text draft text draft text',
|
||||
'sony, ipad', '2012-10-21 2:40:50', false);
|
||||
$this->addReference('topic-draft', $oTopicDraft);
|
||||
}
|
||||
}
|
27
tests/fixtures/UserFixtures.php
vendored
27
tests/fixtures/UserFixtures.php
vendored
|
@ -37,31 +37,4 @@ class UserFixtures extends AbstractFixtures
|
|||
$this->oEngine->User_AddFriend($friend);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user with default values
|
||||
*
|
||||
* @param string $sUserName
|
||||
* @param string $sPassword
|
||||
* @param string $sMail
|
||||
* @param string $sDate
|
||||
*
|
||||
* @return ModuleTopic_EntityUser
|
||||
*/
|
||||
private function _createUser($sUserName, $sPassword,$sMail,$sDate)
|
||||
{
|
||||
$oUser = Engine::GetEntity('User');
|
||||
$oUser->setLogin($sUserName);
|
||||
$oUser->setPassword(md5($sPassword));
|
||||
$oUser->setMail($sMail);
|
||||
$oUser->setUserDateRegister($sDate);
|
||||
$oUser->setUserIpRegister('127.0.0.1');
|
||||
$oUser->setUserActivate('1');
|
||||
$oUser->setUserActivateKey('0');
|
||||
|
||||
$this->oEngine->User_Add($oUser);
|
||||
|
||||
return $oUser;
|
||||
}
|
||||
|
||||
}
|
1
tests/fixtures/sql/geo_base.sql
vendored
1
tests/fixtures/sql/geo_base.sql
vendored
|
@ -1 +0,0 @@
|
|||
../../../install/geo_base.sql
|
1
tests/fixtures/sql/sql.sql
vendored
1
tests/fixtures/sql/sql.sql
vendored
|
@ -1 +0,0 @@
|
|||
../../../install/sql.sql
|
|
@ -1,6 +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
|
||||
mysql -u root -B social_test < ./tests/fixtures/sql/patch.sql
|
||||
|
|
Loading…
Reference in a new issue