-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from humhub/enh/23-github-actions
Add GitHub Actions
- Loading branch information
Showing
21 changed files
with
336 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
name: Upload to HumHub Marketplace | ||
|
||
jobs: | ||
build: | ||
uses: humhub/actions/.github/workflows/module-marketplace-upload.yml@main | ||
secrets: inherit |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: PHP Codeception Tests - develop | ||
|
||
on: | ||
push: | ||
schedule: | ||
- cron: "0 0 * * 0" | ||
|
||
jobs: | ||
tests: | ||
uses: humhub/actions/.github/workflows/module-tests-develop.yml@main | ||
with: | ||
module-id: text-editor |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: PHP Codeception Tests - master | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
tests: | ||
uses: humhub/actions/.github/workflows/module-tests-master.yml@main | ||
with: | ||
module-id: text-editor |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: PHP Codeception Tests - next | ||
|
||
on: | ||
push: | ||
schedule: | ||
- cron: "0 0 * * 0" | ||
|
||
jobs: | ||
tests: | ||
uses: humhub/actions/.github/workflows/module-tests-next.yml@main | ||
with: | ||
module-id: text-editor |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
actor: Tester | ||
namespace: text_editor | ||
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 |
---|---|---|
@@ -0,0 +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'; |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
namespace text_editor; | ||
|
||
/** | ||
* Inherited Methods | ||
* @method void wantToTest($text) | ||
* @method void wantTo($text) | ||
* @method void execute($callable) | ||
* @method void expectTo($prediction) | ||
* @method void expect($prediction) | ||
* @method void amGoingTo($argumentation) | ||
* @method void am($role) | ||
* @method void lookForwardTo($achieveValue) | ||
* @method void comment($description) | ||
* @method void pause() | ||
* | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
class AcceptanceTester extends \AcceptanceTester | ||
{ | ||
use _generated\AcceptanceTesterActions; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
namespace text_editor; | ||
|
||
use tests\codeception\_support\HumHubDbTestCase; | ||
|
||
class UnitTester extends HumHubDbTestCase | ||
{ | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# 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 |
---|---|---|
@@ -0,0 +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: | ||
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
namespace text_editor\acceptance; | ||
|
||
use text_editor\AcceptanceTester; | ||
|
||
class TextEditorCest | ||
{ | ||
public function testTextEditor(AcceptanceTester $I) | ||
{ | ||
$I->amAdmin(); | ||
|
||
$I->amOnPage('/text-editor/config'); | ||
$I->waitForText('Text editor'); | ||
$I->click('#configform-allownewfiles'); | ||
$I->click('Save'); | ||
$I->seeSuccess(); | ||
|
||
$I->amOnSpace1(); | ||
$I->click('#contentForm_message'); | ||
$I->click('.contentForm_options .btn-group .dropdown-toggle'); | ||
$I->waitForText('Create file (Text, Log, XML)'); | ||
$I->click('Create file (Text, Log, XML)'); | ||
$I->waitForText('Create file'); | ||
$I->fillField('#createfile-filename', 'Test file name.tst'); | ||
$I->click('Save'); | ||
|
||
$I->waitForText('Edit file: Test file name.tst'); | ||
$I->executeJS('document.querySelectorAll("div.CodeMirror")[0].CodeMirror.setValue("Test\r\nLine 2")'); | ||
$I->click('Save'); | ||
$I->seeSuccess(); | ||
$I->fillField('#contentFormBody .humhub-ui-richtext[contenteditable]', 'Post with test text file.'); | ||
$I->click('Submit'); | ||
|
||
$I->waitForText('Post with test text file.', null, '.wall-entry'); | ||
$I->see('Test file name.tst - 12 B', '.wall-entry .file-preview-content'); | ||
$I->click('Test file name.tst'); | ||
$I->waitForText('Open file'); | ||
$I->click('View'); | ||
$I->waitForText('View file: Test file name.tst'); | ||
$I->see("Test\r\nLine 2"); | ||
$I->click('Close'); | ||
|
||
$I->click('Test file name.tst'); | ||
$I->waitForText('Open file'); | ||
$I->click('Edit with Text editor'); | ||
$I->waitForText('Edit file: Test file name.tst'); | ||
$I->executeJS('document.querySelectorAll("div.CodeMirror")[0].CodeMirror.setValue("1st Line\r\nSecond Line")'); | ||
$I->click('Save'); | ||
$I->seeSuccess(); | ||
$I->click('Test file name.tst'); | ||
$I->waitForText('Open file'); | ||
$I->click('View'); | ||
$I->waitForText('View file: Test file name.tst'); | ||
$I->see("1st Line\r\nSecond Line"); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
/** | ||
* Initialize the HumHub Application for functional testing. The default application configuration for this suite can be overwritten | ||
* in @tests/config/functional.php | ||
*/ | ||
require Yii::getAlias('@humhubTests/codeception/acceptance/_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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
return \tests\codeception\_support\HumHubTestConfiguration::getSuiteConfig('unit'); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Codeception Test Suite Configuration | ||
|
||
# suite for unit (internal) tests. | ||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. | ||
|
||
class_name: UnitTester | ||
modules: | ||
enabled: | ||
- tests\codeception\_support\CodeHelper | ||
- Yii2 | ||
config: | ||
Yii2: | ||
configFile: 'codeception/config/unit.php' | ||
transaction: false |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
namespace text_editor; | ||
|
||
use humhub\modules\text_editor\models\CreateFile; | ||
use humhub\modules\text_editor\models\forms\ConfigForm; | ||
use humhub\modules\text_editor\Module; | ||
use Yii; | ||
|
||
class TextEditorTest extends UnitTester | ||
{ | ||
public function testTextEditor() | ||
{ | ||
/* @var Module $module */ | ||
$module = Yii::$app->getModule('text-editor'); | ||
|
||
$this->assertFalse($module->canCreate()); | ||
|
||
$config = new ConfigForm(); | ||
$config->allowNewFiles = true; | ||
$config->save(); | ||
|
||
$this->assertTrue($module->canCreate()); | ||
|
||
$createFile = new CreateFile(); | ||
$createFile->fileName = 'test.any'; | ||
$testFile = $createFile->save(); | ||
|
||
$this->assertEquals('text/plain', $testFile->mime_type); | ||
$this->assertTrue($module->isSupportedType($testFile)); | ||
$this->assertTrue($module->canView($testFile)); | ||
$this->assertTrue($module->canEdit($testFile)); | ||
|
||
$testFile->mime_type = 'image/jpeg'; | ||
|
||
$this->assertFalse($module->isSupportedType($testFile)); | ||
$this->assertFalse($module->canView($testFile)); | ||
$this->assertFalse($module->canEdit($testFile)); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
/** | ||
* Initialize the HumHub Application for functional testing. The default application configuration for this suite can be overwritten | ||
* in @tests/config/functional.php | ||
*/ | ||
require Yii::getAlias('@humhubTests/codeception/unit/_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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
/** | ||
* This config is shared by all suites (unit/functional/acceptance) and can be overwritten by a suite config (e.g. functional.php) | ||
*/ | ||
return []; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
return [ | ||
'modules' => ['text-editor'], | ||
'fixtures' => ['default'], | ||
]; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
/** | ||
* Here you can overwrite your functional humhub config. The default config resiedes in @humhubTests/codeception/config/config.php | ||
*/ | ||
return []; |