-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test to create Answers and voting system
- Loading branch information
1 parent
42e6661
commit 9d821df
Showing
22 changed files
with
370 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
actor: Tester | ||
namespace: questions | ||
bootstrap: _bootstrap.php | ||
settings: | ||
suite_class: \PHPUnit_Framework_TestSuite | ||
colors: true | ||
shuffle: false | ||
memory_limit: 1024M | ||
log: true | ||
|
||
# This value controls whether PHPUnit attempts to backup global variables | ||
# See https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals | ||
backup_globals: true | ||
paths: | ||
tests: codeception | ||
log: codeception/_output | ||
data: codeception/_data | ||
helpers: codeception/_support | ||
envs: ../../../humhub/tests/config/env | ||
config: | ||
# the entry script URL (with host info) for functional and acceptance tests | ||
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL | ||
test_entry_url: http://localhost:8080/index-test.php | ||
actor: Tester | ||
namespace: questions | ||
bootstrap: _bootstrap.php | ||
settings: | ||
suite_class: \PHPUnit_Framework_TestSuite | ||
colors: true | ||
shuffle: false | ||
memory_limit: 1024M | ||
log: true | ||
|
||
# This value controls whether PHPUnit attempts to backup global variables | ||
# See https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals | ||
backup_globals: true | ||
paths: | ||
tests: codeception | ||
log: codeception/_output | ||
data: codeception/_data | ||
helpers: codeception/_support | ||
envs: ../../../humhub/tests/config/env | ||
config: | ||
# the entry script URL (with host info) for functional and acceptance tests | ||
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL | ||
test_entry_url: http://localhost:8080/index-test.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
/* | ||
* This is the initial test bootstrap, which will load the default test bootstrap from the humhub core | ||
*/ | ||
|
||
$testRoot = dirname(__DIR__); | ||
|
||
\Codeception\Configuration::append(['test_root' => $testRoot]); | ||
codecept_debug('Module root: ' . $testRoot); | ||
|
||
$humhubPath = getenv('HUMHUB_PATH'); | ||
if ($humhubPath === false) { | ||
// If no environment path was set, we assume residing in default the modules directory | ||
$moduleConfig = require $testRoot . '/config/test.php'; | ||
if (isset($moduleConfig['humhub_root'])) { | ||
$humhubPath = $moduleConfig['humhub_root']; | ||
} else { | ||
$humhubPath = dirname(__DIR__, 5); | ||
} | ||
} | ||
|
||
\Codeception\Configuration::append(['humhub_root' => $humhubPath]); | ||
codecept_debug('HumHub Root: ' . $humhubPath); | ||
|
||
// Load test configuration (/config/test.php or /config/env/<environment>/test.php | ||
$globalConfig = require $humhubPath . '/protected/humhub/tests/codeception/_loadConfig.php'; | ||
|
||
// Load default test bootstrap (initialize Yii...) | ||
require $globalConfig['humhub_root'] . '/protected/humhub/tests/codeception/_bootstrap.php'; | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
/* | ||
* This is the initial test bootstrap, which will load the default test bootstrap from the humhub core | ||
*/ | ||
|
||
$testRoot = dirname(__DIR__); | ||
|
||
\Codeception\Configuration::append(['test_root' => $testRoot]); | ||
codecept_debug('Module root: ' . $testRoot); | ||
|
||
$humhubPath = getenv('HUMHUB_PATH'); | ||
if ($humhubPath === false) { | ||
// If no environment path was set, we assume residing in default the modules directory | ||
$moduleConfig = require $testRoot . '/config/test.php'; | ||
if (isset($moduleConfig['humhub_root'])) { | ||
$humhubPath = $moduleConfig['humhub_root']; | ||
} else { | ||
$humhubPath = dirname(__DIR__, 5); | ||
} | ||
} | ||
|
||
\Codeception\Configuration::append(['humhub_root' => $humhubPath]); | ||
codecept_debug('HumHub Root: ' . $humhubPath); | ||
|
||
// Load test configuration (/config/test.php or /config/env/<environment>/test.php | ||
$globalConfig = require $humhubPath . '/protected/humhub/tests/codeception/_loadConfig.php'; | ||
|
||
// Load default test bootstrap (initialize Yii...) | ||
require $globalConfig['humhub_root'] . '/protected/humhub/tests/codeception/_bootstrap.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
# Codeception Test Suite Configuration | ||
|
||
# suite for acceptance tests. | ||
# perform tests in browser using the Selenium-like tools. | ||
# powered by Mink (http://mink.behat.org). | ||
# (tip: that's what your customer will see). | ||
# (tip: test your ajax and javascript by one of Mink drivers). | ||
|
||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. | ||
|
||
class_name: AcceptanceTester | ||
modules: | ||
enabled: | ||
- WebDriver | ||
- tests\codeception\_support\WebHelper | ||
- tests\codeception\_support\DynamicFixtureHelper | ||
config: | ||
WebDriver: | ||
url: 'http://localhost:8080/' | ||
browser: chrome | ||
restart: true | ||
port: 4444 | ||
capabilities: | ||
chromeOptions: | ||
# Codeception Test Suite Configuration | ||
|
||
# suite for acceptance tests. | ||
# perform tests in browser using the Selenium-like tools. | ||
# powered by Mink (http://mink.behat.org). | ||
# (tip: that's what your customer will see). | ||
# (tip: test your ajax and javascript by one of Mink drivers). | ||
|
||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. | ||
|
||
class_name: AcceptanceTester | ||
modules: | ||
enabled: | ||
- WebDriver | ||
- tests\codeception\_support\WebHelper | ||
- tests\codeception\_support\DynamicFixtureHelper | ||
config: | ||
WebDriver: | ||
url: 'http://localhost:8080/' | ||
browser: chrome | ||
restart: true | ||
port: 4444 | ||
capabilities: | ||
chromeOptions: | ||
args: ["--lang=en-US"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,69 @@ | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
namespace questions\acceptance; | ||
|
||
use questions\AcceptanceTester; | ||
|
||
class QuestionCest | ||
{ | ||
|
||
public function testCreateQuestion(AcceptanceTester $I) | ||
{ | ||
$I->wantTo('create a Question from stream'); | ||
$I->amAdmin(); | ||
|
||
$I->amGoingTo('install the questions module for space 1'); | ||
$I->enableModule(1, 'questions'); | ||
$I->amOnSpace1(); | ||
|
||
$I->amGoingTo('create a Question'); | ||
$I->waitForText('Q&A'); | ||
$I->click( 'Q&A', '#contentFormMenu'); | ||
$I->waitForElementVisible('input[name="Question[question]"]'); | ||
$I->fillField('Question[question]', 'Question headline text?'); | ||
$I->fillField('#question-description .humhub-ui-richtext', 'Question description text.'); | ||
$I->jsClick('#post_submit_button'); | ||
|
||
$I->waitForText('Question headline text?', null, '.wall-entry-header'); | ||
$I->see('Provide an answer', '[data-content-component="questions.Question"]'); | ||
$I->see('View all answers (0)', '[data-content-component="questions.Question"]'); | ||
|
||
$I->amGoingTo('provide an Answer'); | ||
$I->click('Provide an answer'); | ||
$I->switchToNextTab(); | ||
$I->waitForText('Collapse all answers (0)'); | ||
$I->fillField('#answerRichTextField0 .humhub-ui-richtext', 'Answer text.'); | ||
$I->click('Save', '.questions-answer-form'); | ||
$I->waitForText('Answer text.', null, '.except-best-answers'); | ||
} | ||
|
||
} | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
namespace questions\acceptance; | ||
|
||
use questions\AcceptanceTester; | ||
|
||
class QuestionCest | ||
{ | ||
|
||
public function testCreateQuestionWithAnswersAndTestVoting(AcceptanceTester $I) | ||
{ | ||
$I->wantTo('create a Question from stream'); | ||
$I->amAdmin(); | ||
|
||
$I->amGoingTo('install the questions module for space 1'); | ||
$I->enableModule(1, 'questions'); | ||
$I->amOnSpace1(); | ||
|
||
$I->createQuestion('Question headline text?', 'Question description text.'); | ||
|
||
$I->amGoingTo('provide first Answer from Admin'); | ||
$I->click('Provide an answer'); | ||
$I->switchToNextTab(); | ||
$I->provideAnswer('First answer text from Admin.'); | ||
$I->cannotVote(1); | ||
|
||
$I->amUser2(true); | ||
$I->amOnSpace1(); | ||
|
||
$I->amGoingTo('provide first Answer from Sara'); | ||
$I->waitForText('Provide an answer', null, '.wall-entry'); | ||
$I->click('Provide an answer'); | ||
$I->switchToNextTab(); | ||
$I->provideAnswer('Second answer text from Sara.'); | ||
$I->cannotVote(2); | ||
|
||
$I->amGoingTo('vote on the first Answer of Admin'); | ||
$I->upVote(1); | ||
$I->checkVotingSummary(1, 1); | ||
$I->downVote(1); | ||
$I->checkVotingSummary(1, -1); | ||
|
||
$I->amAdmin(true); | ||
$I->amOnSpace1(); | ||
|
||
$I->waitForText('View all answers (2)', null, '.wall-entry'); | ||
$I->click('View all answers (2)'); | ||
$I->switchToNextTab(); | ||
|
||
$I->amGoingTo('vote on the second Answer by Admin'); | ||
$I->upVote(2); | ||
$I->checkVotingSummary(2, 1); | ||
$I->wait(1); | ||
$I->upVote(2); | ||
$I->checkVotingSummary(2, 0); | ||
|
||
$I->amGoingTo('select the best Answer'); | ||
$I->selectBestAnswer(2); | ||
$I->unselectBestAnswer(); | ||
$I->selectBestAnswer(1); | ||
$I->selectBestAnswer(2); | ||
} | ||
|
||
} |
Oops, something went wrong.