Skip to content

Commit a0f6a71

Browse files
authored
Merge pull request #1030 from owncloud/add-acceptance-tests
[tests-only] [full-ci] Add acceptance tests
2 parents 509fe30 + 63ce9c8 commit a0f6a71

File tree

10 files changed

+228
-8
lines changed

10 files changed

+228
-8
lines changed

.drone.star

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,16 @@ config = {
4747
"phpstan": True,
4848
"javascript": False,
4949
"phpunit": True,
50-
"acceptance": False,
50+
"acceptance": {
51+
"cli": {
52+
"suites": [
53+
"cliMain",
54+
],
55+
"servers": [
56+
"daily-master-qa",
57+
],
58+
},
59+
},
5160
}
5261

5362
def main(ctx):

Makefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ PHPUNITDBG=phpdbg -qrr -d memory_limit=4096M -d zend.enable_gc=0 "$(PWD)/../../l
2929
PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/owncloud-codestyle/vendor/bin/php-cs-fixer
3030
PHAN=php -d zend.enable_gc=0 vendor-bin/phan/vendor/bin/phan
3131
PHPSTAN=php -d zend.enable_gc=0 vendor-bin/phpstan/vendor/bin/phpstan
32+
BEHAT_BIN=vendor-bin/behat/vendor/bin/behat
3233

3334
market_doc_files=LICENSE README.md CHANGELOG.md
3435
market_src_dirs=appinfo img js lib templates vendor
@@ -39,6 +40,7 @@ dist_dir=$(build_dir)/dist
3940
# internal aliases
4041
composer_deps=vendor/
4142
js_deps=node_modules/
43+
acceptance_test_deps=vendor-bin/behat/vendor
4244

4345
#
4446
# Catch-all rules
@@ -156,18 +158,18 @@ test-php-phpstan: vendor-bin/phpstan/vendor
156158

157159
.PHONY: test-acceptance-api
158160
test-acceptance-api: ## Run API acceptance tests
159-
test-acceptance-api:
160-
../../tests/acceptance/run.sh --remote --type api
161+
test-acceptance-api: $(acceptance_test_deps)
162+
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type api
161163

162164
.PHONY: test-acceptance-cli
163165
test-acceptance-cli: ## Run CLI acceptance tests
164-
test-acceptance-cli:
165-
../../tests/acceptance/run.sh --remote --type cli
166+
test-acceptance-cli: $(acceptance_test_deps)
167+
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type cli
166168

167169
.PHONY: test-acceptance-webui
168170
test-acceptance-webui: ## Run webUI acceptance tests
169-
test-acceptance-webui:
170-
../../tests/acceptance/run.sh --remote --type webUI
171+
test-acceptance-webui: $(acceptance_test_deps)
172+
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type webUI
171173

172174
.PHONY: test-php-codecheck
173175
test-php-codecheck:
@@ -204,3 +206,9 @@ vendor-bin/phpstan/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/phpstan
204206

205207
vendor-bin/phpstan/composer.lock: vendor-bin/phpstan/composer.json
206208
@echo phpstan composer.lock is not up to date.
209+
210+
vendor-bin/behat/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/behat/composer.lock
211+
composer bin behat install --no-progress
212+
213+
vendor-bin/behat/composer.lock: vendor-bin/behat/composer.json
214+
@echo behat composer.lock is not up to date.

lib/Command/InstallApp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
134134
$output->writeln("$appId: App installed.");
135135
}
136136
} catch (\Exception $ex) {
137-
$output->writeln("<error> $appId: {$ex->getMessage()} </error>");
137+
$output->writeln("<error>$appId: {$ex->getMessage()}</error>");
138138
$this->exitCode = 1;
139139
}
140140
}

lib/Command/UpgradeApp.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ function ($elem) {
167167
}
168168
} else {
169169
$output->writeln("$appId: Not installed ...");
170+
$this->exitCode = 1;
170171
}
171172
} catch (\Exception $ex) {
172173
$output->writeln("<error>$appId: {$ex->getMessage()}</error>");

tests/acceptance/config/behat.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
default:
2+
autoload:
3+
'': '%paths.base%/../features/bootstrap'
4+
5+
suites:
6+
cliMain:
7+
paths:
8+
- '%paths.base%/../features/cliMain'
9+
contexts:
10+
- MarketContext:
11+
- FeatureContext: &common_feature_context_params
12+
baseUrl: http://localhost:8080
13+
adminUsername: admin
14+
adminPassword: admin
15+
regularUserPassword: 123456
16+
ocPath: apps/testing/api/v1/occ
17+
- LoggingContext:
18+
- OccContext:
19+
- OccAppManagementContext:
20+
21+
extensions:
22+
Cjm\Behat\StepThroughExtension: ~
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* ownCloud
4+
*
5+
* @author Phil Davis <[email protected]>
6+
* @copyright Copyright (c) 2022 Phil Davis [email protected]
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10+
* License as published by the Free Software Foundation; either
11+
* version 3 of the License, or any later version.
12+
*
13+
* This library is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public
19+
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
use Behat\Behat\Context\Context;
24+
25+
require_once 'bootstrap.php';
26+
27+
/**
28+
* Context for market specific steps
29+
*/
30+
class MarketContext implements Context {
31+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* ownCloud
4+
*
5+
* @author Phil Davis <[email protected]>
6+
* @copyright Copyright (c) 2022 Phil Davis [email protected]
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10+
* License as published by the Free Software Foundation; either
11+
* version 3 of the License, or any later version.
12+
*
13+
* This library is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public
19+
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
require_once __DIR__ . '/../../../../../../tests/acceptance/features/bootstrap/bootstrap.php';
23+
24+
$classLoader = new \Composer\Autoload\ClassLoader();
25+
$classLoader->addPsr4(
26+
"",
27+
__DIR__ . "/../../../../../../tests/acceptance/features/bootstrap",
28+
true
29+
);
30+
$classLoader->register();
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
@cli
2+
Feature: install, upgrade and uninstall apps that are available in the market-place
3+
4+
# Note: testing this feature requires that the real market-place be online,
5+
# working and reachable from the system-under-test.
6+
# The activity app must not yet be installed on the system-under-test.
7+
# Happy-path install, upgrade and uninstall are tested all in one scenario as a "user journey"
8+
# because we need to install anyway, in order to test a normal uninstall.
9+
Scenario: install, attempt to reinstall, upgrade and uninstall an app that is available in the market-place
10+
# Note: use the activity app as the example to install
11+
# it should be an app that is always available
12+
When the administrator invokes occ command "market:install activity"
13+
Then the command should have been successful
14+
And the command output should be:
15+
"""
16+
activity: Installing new app ...
17+
activity: App installed.
18+
"""
19+
And app "activity" should be enabled
20+
# Attempt to install again and check the different message
21+
When the administrator invokes occ command "market:install activity"
22+
Then the command should have been successful
23+
And the command output should be:
24+
"""
25+
activity: App already installed and no update available
26+
"""
27+
And app "activity" should be enabled
28+
# Attempt to upgrade and check that no update is available
29+
When the administrator invokes occ command "market:upgrade activity"
30+
Then the command should have been successful
31+
And the command output should be:
32+
"""
33+
activity: No update available.
34+
"""
35+
And app "activity" should be enabled
36+
# Uninstall the app - to make sure that uninstall works, and to cleanup
37+
When the administrator invokes occ command "market:uninstall activity"
38+
Then the command should have been successful
39+
And the command output should be:
40+
"""
41+
activity: Un-Installing ...
42+
activity: App uninstalled.
43+
"""
44+
And app "activity" should not be in the apps list
45+
46+
Scenario: install an app that is not available in the market-place
47+
When the administrator invokes occ command "market:install nonexistentapp"
48+
Then the command should have failed with exit code 1
49+
And the command output should be:
50+
"""
51+
nonexistentapp: Installing new app ...
52+
nonexistentapp: Unknown app (nonexistentapp)
53+
"""
54+
55+
Scenario: upgrade an app that is not available in the market-place
56+
When the administrator invokes occ command "market:upgrade nonexistentapp"
57+
Then the command should have failed with exit code 1
58+
And the command output should be:
59+
"""
60+
nonexistentapp: Not installed ...
61+
"""
62+
63+
Scenario: upgrade an app that is available in the market-place but not installed locally
64+
When the administrator invokes occ command "market:upgrade activity"
65+
Then the command should have failed with exit code 1
66+
And the command output should be:
67+
"""
68+
activity: Not installed ...
69+
"""
70+
71+
Scenario: uninstall an app that is not available in the market-place
72+
When the administrator invokes occ command "market:uninstall nonexistentapp"
73+
Then the command should have failed with exit code 1
74+
And the command output should be:
75+
"""
76+
nonexistentapp: Un-Installing ...
77+
nonexistentapp: App (nonexistentapp) could not be uninstalled. Please check the server logs.
78+
"""
79+
80+
Scenario: uninstall an app that is available in the market-place but not installed locally
81+
When the administrator invokes occ command "market:uninstall activity"
82+
Then the command should have failed with exit code 1
83+
And the command output should be:
84+
"""
85+
activity: Un-Installing ...
86+
activity: App (activity) could not be uninstalled. Please check the server logs.
87+
"""
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@cli
2+
Feature: list apps that are available in the market-place
3+
4+
# Note: testing this feature requires that the real market-place be online,
5+
# working and reachable from the system-under-test.
6+
Scenario: list the apps available in the market-place
7+
When the administrator invokes occ command "market:list"
8+
Then the command should have been successful
9+
# The command lists all the apps that are available on the market-place
10+
# Just check for an example app that should always be there
11+
And the command output should contain the text "activity"

vendor-bin/behat/composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"config" : {
3+
"platform": {
4+
"php": "7.4"
5+
}
6+
},
7+
"require": {
8+
"behat/behat": "^3.9",
9+
"behat/gherkin": "^4.9",
10+
"behat/mink": "1.7.1",
11+
"friends-of-behat/mink-extension": "^2.5",
12+
"behat/mink-selenium2-driver": "^1.5",
13+
"ciaranmcnulty/behat-stepthroughextension" : "dev-master",
14+
"rdx/behat-variables": "^1.2",
15+
"sensiolabs/behat-page-object-extension": "^2.3",
16+
"symfony/translation": "^4.4",
17+
"sabre/xml": "^2.2",
18+
"guzzlehttp/guzzle": "^7.4",
19+
"phpunit/phpunit": "^9.5"
20+
}
21+
}

0 commit comments

Comments
 (0)