Skip to content

Commit fa4b8df

Browse files
committed
apply more comments
1 parent f2e0784 commit fa4b8df

File tree

7 files changed

+67
-57
lines changed

7 files changed

+67
-57
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ unittests:
7777
composer install
7878
./vendor/bin/phpunit --bootstrap tests/unittests/bootstrap.php tests/unittests/ --testdox
7979

80+
# Run integration tests
81+
.PHONY: integrationtests
82+
integrationtests:
83+
./scripts/run-app.sh "32.0.0" 1
84+
composer install
85+
./vendor/bin/phpunit --bootstrap tests/integration/bootstrap.php tests/integration/ --testdox
86+
8087
# Run bats tests
8188
.PHONY: bats
8289
bats:

appinfo/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
['name' => 'settings#getCounters', 'url' => '/getCounters', 'verb' => 'GET'],
2323
// admin
2424
['name' => 'settings#setAdminSettings', 'url' => '/adminSettings', 'verb' => 'POST'],
25-
['name' => 'settings#setadvancedconfig', 'url' => '/setadvancedconfig', 'verb' => 'POST'],
25+
['name' => 'settings#setAdvancedConfig', 'url' => '/setAdvancedConfig', 'verb' => 'POST'],
2626
['name' => 'settings#getAuthMethod', 'url' => '/getAuthMethod', 'verb' => 'GET'],
2727
['name' => 'settings#resetAllTags', 'url' => '/resetalltags', 'verb' => 'POST'],
2828
['name' => 'settings#testsettings', 'url' => '/testsettings', 'verb' => 'POST'],

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
],
1111
"require": {
1212
"gdata/vaas": "11.0.1",
13-
"coduo/php-humanizer": "5.0.0"
13+
"coduo/php-humanizer": "5.0.0",
14+
"vlucas/phpdotenv": "5.6"
1415
},
1516
"require-dev": {
1617
"nextcloud/ocp": "v32.0.0",

lib/Controller/SettingsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function setAdminSettings(
7171
return new JSONResponse(['status' => 'success']);
7272
}
7373

74-
public function setadvancedconfig($tokenEndpoint, $vaasUrl): JSONResponse {
74+
public function setAdvancedConfig($tokenEndpoint, $vaasUrl): JSONResponse {
7575
$this->config->setValueString($this->appName, 'tokenEndpoint', $tokenEndpoint);
7676
$this->config->setValueString($this->appName, 'vaasUrl', $vaasUrl);
7777
return new JSONResponse(['status' => 'success']);

src/admin-settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ document.addEventListener('DOMContentLoaded', async () => {
106106
const tokenEndpoint = document.querySelector('#token_endpoint').value;
107107
const vaasUrl = document.querySelector('#vaas_url').value;
108108

109-
const response = await postData(OC.generateUrl('apps/gdatavaas/setadvancedconfig'), {
109+
const response = await postData(OC.generateUrl('apps/gdatavaas/setAdvancedConfig'), {
110110
tokenEndpoint,
111111
vaasUrl
112112
});

tests/integration/SettingsControllerTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,18 @@ public static function adminGetRouteProvider(): array
2424
public static function adminPostRouteProvider(): array
2525
{
2626
return [
27-
// TODO: use default settings
2827
['adminSettings', [
29-
'username' => 'username',
30-
'password' => 'password',
28+
'username' => 'admin',
29+
'password' => 'admin',
3130
'clientId' => 'clientId',
3231
'clientSecret' => 'clientSecret',
33-
'authMethod' => 'authMethod',
32+
'authMethod' => 'ResourceOwnerPassword',
3433
'maxScanSize' => 209715200,
3534
'timeout' => 900,
3635
'cache' => true,
3736
'hashlookup' => true
3837
]],
39-
// ['setadvancedconfig'],
38+
['setAdvancedConfig', ['tokenEndpoint' => 'tokenEndpoint', 'vaasUrl' => 'vaasUrl']],
4039
];
4140
}
4241

tests/integration/bootstrap.php

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,57 @@
1010
define('INTEGRATION_TEST_ROOT', __DIR__);
1111
define('PROJECT_ROOT', __DIR__ . '/../..');
1212

13-
// Load environment variables for integration testing
14-
$envFile = __DIR__ . '/../bats/.env-test';
15-
if (file_exists($envFile)) {
16-
$envContent = file_get_contents($envFile);
17-
$envLines = explode("\n", $envContent);
18-
19-
foreach ($envLines as $line) {
20-
$line = trim($line);
21-
if (empty($line) || strpos($line, '#') === 0 || strpos($line, 'export') !== 0) {
22-
continue;
23-
}
24-
25-
// Remove 'export ' prefix and parse key=value
26-
$line = substr($line, 7); // Remove 'export '
27-
if (strpos($line, '=') !== false) {
28-
[$key, $value] = explode('=', $line, 2);
29-
// Remove quotes if present
30-
$value = trim($value, '"\'');
31-
$_ENV[$key] = $value;
32-
putenv("$key=$value");
33-
}
34-
}
35-
}
36-
37-
// Load local environment files
38-
$localEnvFiles = [PROJECT_ROOT . '/.env-local', PROJECT_ROOT . '/.env'];
39-
foreach ($localEnvFiles as $envFile) {
40-
if (file_exists($envFile)) {
41-
$envContent = file_get_contents($envFile);
42-
$envLines = explode("\n", $envContent);
43-
44-
foreach ($envLines as $line) {
45-
$line = trim($line);
46-
if (empty($line) || strpos($line, '#') === 0) {
47-
continue;
48-
}
49-
50-
if (strpos($line, '=') !== false) {
51-
[$key, $value] = explode('=', $line, 2);
52-
// Remove quotes if present
53-
$value = trim($value, '"\'');
54-
$_ENV[$key] = $value;
55-
putenv("$key=$value");
56-
}
57-
}
58-
break; // Use first found env file
59-
}
60-
}
13+
$dotenv = Dotenv\Dotenv::createImmutable(PROJECT_ROOT);
14+
$dotenv->load();
15+
16+
// // Load environment variables for integration testing
17+
// $envFile = __DIR__ . '/../bats/.env-test';
18+
// if (file_exists($envFile)) {
19+
// $envContent = file_get_contents($envFile);
20+
// $envLines = explode("\n", $envContent);
21+
22+
// foreach ($envLines as $line) {
23+
// $line = trim($line);
24+
// if (empty($line) || strpos($line, '#') === 0 || strpos($line, 'export') !== 0) {
25+
// continue;
26+
// }
27+
28+
// // Remove 'export ' prefix and parse key=value
29+
// $line = substr($line, 7); // Remove 'export '
30+
// if (strpos($line, '=') !== false) {
31+
// [$key, $value] = explode('=', $line, 2);
32+
// // Remove quotes if present
33+
// $value = trim($value, '"\'');
34+
// $_ENV[$key] = $value;
35+
// putenv("$key=$value");
36+
// }
37+
// }
38+
// }
39+
40+
// // Load local environment files
41+
// $localEnvFiles = [PROJECT_ROOT . '/.env-local', PROJECT_ROOT . '/.env'];
42+
// foreach ($localEnvFiles as $envFile) {
43+
// if (file_exists($envFile)) {
44+
// $envContent = file_get_contents($envFile);
45+
// $envLines = explode("\n", $envContent);
46+
47+
// foreach ($envLines as $line) {
48+
// $line = trim($line);
49+
// if (empty($line) || strpos($line, '#') === 0) {
50+
// continue;
51+
// }
52+
53+
// if (strpos($line, '=') !== false) {
54+
// [$key, $value] = explode('=', $line, 2);
55+
// // Remove quotes if present
56+
// $value = trim($value, '"\'');
57+
// $_ENV[$key] = $value;
58+
// putenv("$key=$value");
59+
// }
60+
// }
61+
// break; // Use first found env file
62+
// }
63+
// }
6164

6265
// Set default values if not defined
6366
if (!isset($_ENV['HOSTNAME'])) {

0 commit comments

Comments
 (0)