test commits optimization

This commit is contained in:
John 2013-07-24 18:17:30 +03:00
parent 77ae613a53
commit f85f1c5597
15 changed files with 318 additions and 20693 deletions

View File

@ -13,9 +13,12 @@ before_script:
- chmod -R 0777 ./uploads - chmod -R 0777 ./uploads
- chmod -R 0777 ./templates/cache/ - chmod -R 0777 ./templates/cache/
- chmod -R 0777 ./templates/compiled/ - chmod -R 0777 ./templates/compiled/
- cp ./install/*.sql tests/fixtures/sql/
- rm -rf ./install
# install required PHP stuff # 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 # launch apache, MySQL and PHPUnit Selenium installers
- ./tests/travis/apache_setup.sh - ./tests/travis/apache_setup.sh
@ -28,6 +31,7 @@ before_script:
- sleep 5 - sleep 5
# get HTML of main page (for debug) # get HTML of main page (for debug)
- firefox --version - firefox --version
- wget -S http://livestreet.test -O /dev/null - wget -S http://livestreet.test -O /dev/null
@ -36,7 +40,7 @@ before_script:
- sleep 5 - sleep 5
# download and launch Selenium # 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 & - java -jar /tmp/selenium-server-standalone.jar > /dev/null &
- sleep 5 - sleep 5

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,8 @@ abstract class AbstractFixtures
*/ */
private $aReferences = array(); private $aReferences = array();
private $aActivePlugins = array();
/** /**
* @param Engine $oEngine * @param Engine $oEngine
* @param array $aReferences * @param array $aReferences
@ -27,6 +29,7 @@ abstract class AbstractFixtures
{ {
$this->oEngine = $oEngine; $this->oEngine = $oEngine;
$this->aReferences = $aReferences; $this->aReferences = $aReferences;
$this->aActivePlugins = $oEngine->Plugin_GetActivePlugins();
} }
/** /**
@ -80,8 +83,162 @@ abstract class AbstractFixtures
* *
* @return int * @return int
*/ */
public static function getOrder() { public static function getOrder()
{
return 0; 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");
}
}
} }

View File

@ -83,6 +83,19 @@ class LoadFixtures
} }
echo "ExportSQL DATABASE $sDbname -> install_base.sql \n"; echo "ExportSQL DATABASE $sDbname -> install_base.sql \n";
// Load dump from geo_base.sql // 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'); $result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/geo_base.sql');
if (!$result['result']) { if (!$result['result']) {

View File

@ -8,9 +8,7 @@ Feature: Test Base comment functionality (!!!SELENIUM NEEDED)
Then I want to login as "admin" Then I want to login as "admin"
Given I am on homepage Given I am on homepage
Then I follow "Sony MicroVault Mach USB 3.0 flash drive" Given I am on "/blog/3.html"
Then I wait "1000"
Then I follow "Add comment" Then I follow "Add comment"
And I fill in "test comment" for "comment_text" And I fill in "test comment" for "comment_text"
@ -28,19 +26,10 @@ Feature: Test Base comment functionality (!!!SELENIUM NEEDED)
| value | | value |
| test comment | | 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 | | value |
| /profile/admin/">admin</a> | | /profile/admin/">admin</a> |
Then I should see in element by css "content .comment-actions" values:
| value |
| Reply | | Reply |
| Delete | | 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 |

View 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 |

View File

@ -4,14 +4,21 @@ require_once(realpath((dirname(__FILE__)) . "/../AbstractFixtures.php"));
class BlogFixtures extends AbstractFixtures class BlogFixtures extends AbstractFixtures
{ {
/**
* @return int
*/
public static function getOrder() public static function getOrder()
{ {
return 1; return 2;
} }
/**
* Create Blog
*/
public function load() public function load()
{ {
$oUserFirst = $this->getReference('user-golfer'); $oUserFirst = $this->getReference('user-golfer');
$oCategory = $this->getReference('blog-category');
/* @var $oBlogGadgets ModuleBlog_EntityBlog */ /* @var $oBlogGadgets ModuleBlog_EntityBlog */
$oBlogGadgets = Engine::GetEntity('Blog'); $oBlogGadgets = Engine::GetEntity('Blog');
@ -22,6 +29,7 @@ class BlogFixtures extends AbstractFixtures
$oBlogGadgets->setDateAdd(date("Y-m-d H:i:s")); // @todo freeze $oBlogGadgets->setDateAdd(date("Y-m-d H:i:s")); // @todo freeze
$oBlogGadgets->setUrl('gadgets'); $oBlogGadgets->setUrl('gadgets');
$oBlogGadgets->setLimitRatingTopic(0); $oBlogGadgets->setLimitRatingTopic(0);
$oBlogGadgets->setCategoryId($oCategory->getCategoryId());
$this->oEngine->Blog_AddBlog($oBlogGadgets); $this->oEngine->Blog_AddBlog($oBlogGadgets);

24
tests/fixtures/CategoryFixtures.php vendored Normal file
View 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
View 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);
}
}

View File

@ -4,13 +4,21 @@ require_once(realpath((dirname(__FILE__)) . "/../AbstractFixtures.php"));
class TopicFixtures extends AbstractFixtures class TopicFixtures extends AbstractFixtures
{ {
/**
protected $aActivePlugins = array(); * @return int
*/
public static function getOrder() 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() public function load()
{ {
$oUserFirst = $this->getReference('user-golfer'); $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. Its also backward compatible with USB 2.0.', '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. Its also backward compatible with USB 2.0.',
'sony, flash, gadget', '2012-10-21 2:30:40'); 'sony, flash, gadget', '2012-10-21 2:30:40');
$this->addReference('topic-sony', $oTopicSony); $this->addReference('topic-sony', $oTopicSony);
}
/** $oTopicDraft = $this->_createTopic($oPersonalBlogGolfer->getBlogId(), $oUserFirst->getId(),
* Create topic with default values 'Draft Topic',
* 'draft text draft text draft text draft text draft text draft text draft text',
* @param int $iBlogId 'sony, ipad', '2012-10-21 2:40:50', false);
* @param int $iUserId $this->addReference('topic-draft', $oTopicDraft);
* @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;
} }
} }

View File

@ -37,31 +37,4 @@ class UserFixtures extends AbstractFixtures
$this->oEngine->User_AddFriend($friend); $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;
}
} }

View File

@ -1 +0,0 @@
../../../install/geo_base.sql

View File

@ -1 +0,0 @@
../../../install/sql.sql

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
sudo apt-get install mysql-server mysql-client
mysql -u root -e 'CREATE DATABASE social_test;' 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/sql.sql
mysql -u root -B social_test < ./tests/fixtures/sql/geo_base.sql mysql -u root -B social_test < ./tests/fixtures/sql/geo_base.sql
mysql -u root -B social_test < ./tests/fixtures/sql/patch.sql