diff --git a/protected/humhub/modules/content/tests/codeception/_data/contentcontainer.php b/protected/humhub/modules/content/tests/codeception/_data/contentcontainer.php index 64ecc3ca75..531211b256 100644 --- a/protected/humhub/modules/content/tests/codeception/_data/contentcontainer.php +++ b/protected/humhub/modules/content/tests/codeception/_data/contentcontainer.php @@ -24,4 +24,5 @@ return [ ['id' => 4, 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34a', 'class' => 'humhub\modules\space\models\Space', 'pk' => '1', 'owner_user_id' => 1], ['id' => 5, 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34b', 'class' => 'humhub\modules\space\models\Space', 'pk' => '2', 'owner_user_id' => 2], ['id' => 6, 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34c', 'class' => 'humhub\modules\space\models\Space', 'pk' => '3', 'owner_user_id' => 3], + ['id' => 7, 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34d', 'class' => 'humhub\modules\space\models\Space', 'pk' => '4', 'owner_user_id' => 3], ]; \ No newline at end of file diff --git a/protected/humhub/modules/notification/tests/codeception/fixtures/data/notification.php b/protected/humhub/modules/notification/tests/codeception/fixtures/data/notification.php new file mode 100644 index 0000000000..e55c3524aa --- /dev/null +++ b/protected/humhub/modules/notification/tests/codeception/fixtures/data/notification.php @@ -0,0 +1,9 @@ +expectTo('see the notification settings form'); $I->see('Send notifications?'); $I->see('Send activities?'); + $I->selectOption('AccountEmailing[receive_email_notifications]', 'Never'); + $I->selectOption('AccountEmailing[receive_email_activities]', 'Never'); + $I->click('.regular-checkbox-box'); $I->click('Save'); - $I->waitForElementVisible('.data-saved', 5); + + // Refresh page + $I->amOnPage('index-test.php?r=user%2Faccount%2Femailing'); + $I->click('Notifications'); //Notification tab + $I->seeOptionIsSelected('AccountEmailing[receive_email_notifications]', 'Never'); + $I->seeOptionIsSelected('AccountEmailing[receive_email_activities]', 'Never'); } } \ No newline at end of file diff --git a/protected/humhub/tests/codeception.yml b/protected/humhub/tests/codeception.yml index a8229f9752..a037c60021 100644 --- a/protected/humhub/tests/codeception.yml +++ b/protected/humhub/tests/codeception.yml @@ -24,9 +24,9 @@ paths: log: codeception/_output data: codeception/_data helpers: codeception/_support -#include: +include: + - ../modules/*/tests #- ../../../../modules/*/tests - #- ../modules/*/tests settings: bootstrap: _bootstrap.php diff --git a/protected/humhub/tests/codeception/_bootstrap.php b/protected/humhub/tests/codeception/_bootstrap.php index 8799e4585c..64caee78c8 100644 --- a/protected/humhub/tests/codeception/_bootstrap.php +++ b/protected/humhub/tests/codeception/_bootstrap.php @@ -19,13 +19,11 @@ $_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config // Set alias $config = \Codeception\Configuration::config(); -$testRoot = $config['test_root']; -if($testRoot == null) { - $testRoot = dirname(__DIR__); -} +$config['test_root'] = isset($config['test_root']) ? $config['test_root'] : dirname(__DIR__); +$config['humhub_root'] = isset($config['humhub_root']) ? $config['humhub_root'] : realpath(dirname(__DIR__ ). '/../../../'); -Yii::setAlias('@tests', $testRoot); +Yii::setAlias('@tests', $config['test_root']); Yii::setAlias('@env', '@tests/config/env'); Yii::setAlias('@modules', dirname(dirname(__DIR__)).'/modules'); Yii::setAlias('@root', $config['humhub_root']); diff --git a/protected/humhub/tests/codeception/_support/AcceptanceTester.php b/protected/humhub/tests/codeception/_support/AcceptanceTester.php index d5a33c94ef..3b15b2a225 100644 --- a/protected/humhub/tests/codeception/_support/AcceptanceTester.php +++ b/protected/humhub/tests/codeception/_support/AcceptanceTester.php @@ -1,7 +1,5 @@ amUser('Admin', 'test', $logout); } - + public function amUser1($logout = false) { $this->amUser('User1', '123qwe', $logout); } - + public function amUser2($logout = false) { $this->amUser('User2', '123qwe', $logout); } + + public function amUser3($logout = false) + { + $this->amUser('User3', '123qwe', $logout); + } + + public function amOnSpace1() + { + $this->amOnPage('index-test.php?r=space/space&sguid=5396d499-20d6-4233-800b-c6c86e5fa34a'); + } + + public function amOnSpace2() + { + $this->amOnPage('index-test.php?r=space/space&sguid=5396d499-20d6-4233-800b-c6c86e5fa34b'); + } + + public function amOnSpace3() + { + $this->amOnPage('index-test.php?r=space/space&sguid=5396d499-20d6-4233-800b-c6c86e5fa34c'); + } + public function amOnSpace4() + { + $this->amOnPage('index-test.php?r=space/space&sguid=5396d499-20d6-4233-800b-c6c86e5fa34d'); + } + public function amUser($user = null, $password = null, $logout = false) { - if($logout) { + if ($logout) { $this->logout(); } - + $user = ($user != null) ? $user : 'User1'; $password = ($password != null) ? $password : '123qwe'; $this->login($user, $password); - $this->wait(10); + $this->wait(5); $this->seeElement('#wallStream'); } - + public function login($user, $password) { LoginPage::openBy($this)->login($user, $password); } - + public function logout() { $this->clickAccountDropDown(); $this->click('Logout'); - $this->wait(10); + $this->wait(5); } - + public function clickAccountDropDown() { $this->click('#account-dropdown-link'); $this->wait(2); } - + public function amOnProfile() { $this->clickAccountDropDown(); $this->click('My profile'); } + public function amOnUser1Profile() + { + $this->amOnPage('index-test.php?r=user/profile&uguid=01e50e0d-82cd-41fc-8b0c-552392f5839d'); + } + + public function amOnUser2Profile() + { + $this->amOnPage('index-test.php?r=user/profile&uguid=01e50e0d-82cd-41fc-8b0c-552392f5839e'); + } + + public function amOnUser3Profile() + { + $this->amOnPage('index-test.php?r=user/profile&uguid=01e50e0d-82cd-41fc-8b0c-552392f5839a'); + } + + public function seeInNotifications($text) + { + $this->click('.notifications'); + $this->wait(1); + $this->see($text); + $this->click('.notifications'); + } + + public function dontSeeInNotifications($text) + { + $this->click('.notifications'); + $this->wait(1); + $this->dontSee($text); + $this->click('.notifications'); + } + public function jsClick($selector) { - $this->executeJS('$("'.$selector.'").click();'); + $this->executeJS('$("' . $selector . '").click();'); } - + public function jsFillField($selector, $value) { - $this->executeJS('$("'.$selector.'").val("'.$value.'");'); + $this->executeJS('$("' . $selector . '").val("' . $value . '");'); } - + public function jsShow($selector) { - $this->executeJS('$("'.$selector.'").show();'); + $this->executeJS('$("' . $selector . '").show();'); } - + public function jsAttr($selector, $attr, $val) { - $this->executeJS('$("'.$selector.'").attr("'.$attr.'", "'.$val.'");'); + $this->executeJS('$("' . $selector . '").attr("' . $attr . '", "' . $val . '");'); } - + public function scrollToTop() { $this->executeJS('window.scrollTo(0,0);'); } + } diff --git a/protected/humhub/tests/codeception/_support/DynamicFixtureHelper.php b/protected/humhub/tests/codeception/_support/DynamicFixtureHelper.php index d5a4d96eab..d57a95dbf8 100644 --- a/protected/humhub/tests/codeception/_support/DynamicFixtureHelper.php +++ b/protected/humhub/tests/codeception/_support/DynamicFixtureHelper.php @@ -111,6 +111,7 @@ class DynamicFixtureHelper extends Module 'space' => [ 'class' => \tests\codeception\fixtures\SpaceFixture::className()], 'space_membership' => [ 'class' => \tests\codeception\fixtures\SpaceMembershipFixture::className()], 'contentcontainer' => [ 'class' => \tests\codeception\fixtures\ContentContainerFixture::className()], + 'notification' => [ 'class' => \tests\codeception\fixtures\NotificationFixture::className()], ]; } diff --git a/protected/humhub/tests/codeception/_support/HumHubDbTestCase.php b/protected/humhub/tests/codeception/_support/HumHubDbTestCase.php index a327bdef46..50a36bcbe8 100644 --- a/protected/humhub/tests/codeception/_support/HumHubDbTestCase.php +++ b/protected/humhub/tests/codeception/_support/HumHubDbTestCase.php @@ -72,6 +72,7 @@ class HumHubDbTestCase extends \yii\codeception\DbTestCase 'space' => [ 'class' => \tests\codeception\fixtures\SpaceFixture::className()], 'space_membership' => [ 'class' => \tests\codeception\fixtures\SpaceMembershipFixture::className()], 'contentcontainer' => [ 'class' => \tests\codeception\fixtures\ContentContainerFixture::className()], + 'notification' => [ 'class' => \tests\codeception\fixtures\NotificationFixture::className()], ]; } } diff --git a/protected/humhub/tests/codeception/config/config.php b/protected/humhub/tests/codeception/config/config.php index ae23081ae0..6536d78d6f 100644 --- a/protected/humhub/tests/codeception/config/config.php +++ b/protected/humhub/tests/codeception/config/config.php @@ -32,6 +32,9 @@ $default = [ 'scriptUrl' => 'index-test.php', ], ], + 'params' => [ + 'allowedLanguages' => ['en'] + ] ]; return yii\helpers\ArrayHelper::merge( diff --git a/protected/humhub/tests/codeception/fixtures/ContentFixture.php b/protected/humhub/tests/codeception/fixtures/ContentFixture.php index cc8f3131f0..626cd60d0a 100644 --- a/protected/humhub/tests/codeception/fixtures/ContentFixture.php +++ b/protected/humhub/tests/codeception/fixtures/ContentFixture.php @@ -14,7 +14,7 @@ class ContentFixture extends ActiveFixture { public $modelClass = 'humhub\modules\content\models\Content'; - public $dataFile = '@tests/../modules/content/tests/codeception/_data/content.php'; + public $dataFile = '@modules/content/tests/codeception/_data/content.php'; public $depends = [ 'tests\codeception\fixtures\ContentContainerFixture' diff --git a/protected/humhub/tests/codeception/fixtures/NotificationFixture.php b/protected/humhub/tests/codeception/fixtures/NotificationFixture.php new file mode 100644 index 0000000000..ff2c407502 --- /dev/null +++ b/protected/humhub/tests/codeception/fixtures/NotificationFixture.php @@ -0,0 +1,23 @@ + 'cache.expireTime', 'value' => '3600', 'module_id' => 'base'), array('name' => 'installationId', 'value' => '99846c45e9b9b0962238986a6fed519a', 'module_id' => 'admin'), array('name' => 'theme', 'value' => 'HumHub', 'module_id' => 'base'), - array('name' => 'tour', 'value' => '1', 'module_id' => 'base') + array('name' => 'tour', 'value' => '1', 'module_id' => 'base'), ); diff --git a/protected/humhub/tests/codeception/fixtures/data/space.php b/protected/humhub/tests/codeception/fixtures/data/space.php index 94039fb1b6..7fc0228b23 100644 --- a/protected/humhub/tests/codeception/fixtures/data/space.php +++ b/protected/humhub/tests/codeception/fixtures/data/space.php @@ -18,8 +18,9 @@ * GNU Affero General Public License for more details. */ return array( - array('id' => '1', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34a', 'name' => 'Space 1', 'description' => 'Space by Admin', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '1', 'ldap_dn' => NULL, 'auto_add_new_members' => '0'), - array('id' => '2', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34b', 'name' => 'Space 2', 'description' => 'User 1 Space', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '2', 'ldap_dn' => NULL, 'auto_add_new_members' => '0'), - array('id' => '3', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34c', 'name' => 'Space 3', 'description' => 'Another User 1 Space', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '2', 'ldap_dn' => NULL, 'auto_add_new_members' => '1') + array('id' => '1', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34a', 'name' => 'Space 1', 'contentcontainer_id' => '4', 'description' => 'Space by Admin', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '1', 'ldap_dn' => NULL, 'auto_add_new_members' => '0'), + array('id' => '2', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34b', 'name' => 'Space 2', 'contentcontainer_id' => '5', 'description' => 'User 1 Space', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '2', 'ldap_dn' => NULL, 'auto_add_new_members' => '0'), + array('id' => '3', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34c', 'name' => 'Space 3', 'contentcontainer_id' => '6', 'description' => 'Another User 1 Space', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '2', 'ldap_dn' => NULL, 'auto_add_new_members' => '1'), + array('id' => '4', 'guid' => '5396d499-20d6-4233-800b-c6c86e5fa34d', 'name' => 'Space 4', 'contentcontainer_id' => '7', 'description' => 'User 1/2 Space', 'join_policy' => '2', 'visibility' => '2', 'status' => '1', 'tags' => NULL, 'created_at' => '2014-08-08 05:36:04', 'created_by' => '2', 'updated_at' => '2014-08-08 05:36:04', 'updated_by' => '2', 'ldap_dn' => NULL, 'auto_add_new_members' => '1') ); diff --git a/protected/humhub/tests/codeception/fixtures/data/space_membership.php b/protected/humhub/tests/codeception/fixtures/data/space_membership.php index ba8cb792aa..b6f59a22bc 100644 --- a/protected/humhub/tests/codeception/fixtures/data/space_membership.php +++ b/protected/humhub/tests/codeception/fixtures/data/space_membership.php @@ -23,7 +23,17 @@ return array( array('space_id' => '1', 'user_id' => '1', 'originator_user_id' => NULL, 'status' => '3', 'request_message' => NULL, 'last_visit' => '2014-08-08 06:49:57', 'group_id' => 'admin', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'), array('space_id' => '1', 'user_id' => '3', 'originator_user_id' => NULL, 'status' => '3', 'request_message' => NULL, 'last_visit' => NULL, 'group_id' => 'member', 'created_at' => '2014-08-10 16:55:41', 'created_by' => NULL, 'updated_at' => NULL, 'updated_by' => NULL), - // User 2 is Member/Admin of Space 2 & 3 + // User 2 is Member/Admin of Space 2 array('space_id' => '2', 'user_id' => '2', 'originator_user_id' => NULL, 'status' => '3', 'request_message' => NULL, 'last_visit' => '2014-08-08 06:49:57', 'group_id' => 'admin', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'), - array('space_id' => '3', 'user_id' => '2', 'originator_user_id' => NULL, 'status' => '3', 'request_message' => NULL, 'last_visit' => '2014-08-08 06:49:57', 'group_id' => 'admin', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'), + + // User 1 is admin of space 3 and user 2 & 3 are members + array('space_id' => '3', 'user_id' => '1', 'originator_user_id' => NULL, 'status' => '3', 'request_message' => NULL, 'last_visit' => '2014-08-08 06:49:57', 'group_id' => 'admin', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'), + array('space_id' => '3', 'user_id' => '2', 'originator_user_id' => NULL, 'status' => '3', 'request_message' => NULL, 'last_visit' => NULL, 'group_id' => 'member', 'created_at' => '2014-08-10 16:55:41', 'created_by' => NULL, 'updated_at' => NULL, 'updated_by' => NULL), + array('space_id' => '3', 'user_id' => '3', 'originator_user_id' => NULL, 'status' => '3', 'request_message' => NULL, 'last_visit' => '2014-08-08 06:49:57', 'group_id' => 'member', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'), + + // User 1/2 is admin of space 3 and user 3 is members + array('space_id' => '4', 'user_id' => '1', 'originator_user_id' => NULL, 'status' => '3', 'request_message' => NULL, 'last_visit' => '2014-08-08 06:49:57', 'group_id' => 'admin', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'), + array('space_id' => '4', 'user_id' => '2', 'originator_user_id' => NULL, 'status' => '3', 'request_message' => NULL, 'last_visit' => NULL, 'group_id' => 'admin', 'created_at' => '2014-08-10 16:55:41', 'created_by' => NULL, 'updated_at' => NULL, 'updated_by' => NULL), + array('space_id' => '4', 'user_id' => '3', 'originator_user_id' => NULL, 'status' => '3', 'request_message' => NULL, 'last_visit' => '2014-08-08 06:49:57', 'group_id' => 'member', 'created_at' => '2014-08-08 05:36:05', 'created_by' => '1', 'updated_at' => '2014-08-08 05:36:05', 'updated_by' => '1'), + ); diff --git a/protected/humhub/widgets/views/modalConfirm.php b/protected/humhub/widgets/views/modalConfirm.php index 07ff822add..ffdf939953 100644 --- a/protected/humhub/widgets/views/modalConfirm.php +++ b/protected/humhub/widgets/views/modalConfirm.php @@ -70,7 +70,7 @@ if ($confirmJS != "") { ], 'htmlOptions' => [ 'return' => 'true', - 'class' => 'btn btn-primary', + 'class' => 'btn btn-primary modalConfirm', 'data-dismiss' => 'modal' ] ]);