Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1b1cc25
TP-1427 Added test running to ci.yml
jussiviitamaki Feb 13, 2025
98466cb
TP-1427 Added missing slash
jussiviitamaki Feb 13, 2025
76e2573
TP-1427 Changed phpunit.xml path
jussiviitamaki Feb 13, 2025
e70a994
TP-1427 Fixed bootstrap path
jussiviitamaki Feb 13, 2025
15a3701
TP-1427 Changed phpunit.xml path
jussiviitamaki Feb 13, 2025
4d9ff57
Testing of lando in github action
jussiviitamaki Feb 14, 2025
27e2987
Testing continues
jussiviitamaki Feb 14, 2025
c1c754c
Test
jussiviitamaki Feb 14, 2025
c391707
Stash
jussiviitamaki Feb 14, 2025
83135e4
Stash
jussiviitamaki Feb 14, 2025
8ef3288
Removed drupal-test.yml
jussiviitamaki Feb 14, 2025
8c0694d
Cleaned up some unnecessary steps
jussiviitamaki Feb 14, 2025
c8cb158
Created phpunit.github.xml
jussiviitamaki Feb 14, 2025
e64072e
Fixed syntax
jussiviitamaki Feb 14, 2025
fc82246
TP-1427 Updated .lando.yml xdebug config
jussiviitamaki Feb 14, 2025
6449f76
Testing test workflow
jussiviitamaki Feb 17, 2025
4e3a5b8
Removed test.yml fixed covers warnings
jussiviitamaki Feb 17, 2025
618eeb3
Debug
jussiviitamaki Feb 17, 2025
2480356
Debug
jussiviitamaki Feb 18, 2025
acbf2fe
Debug
jussiviitamaki Feb 18, 2025
885d737
Debug
jussiviitamaki Feb 18, 2025
8f466a1
Debug
jussiviitamaki Feb 18, 2025
9c1d5a3
Debug
jussiviitamaki Feb 18, 2025
fad5332
Debug
jussiviitamaki Feb 18, 2025
f31d551
Debug
jussiviitamaki Feb 18, 2025
1c0b0b4
Merge branch 'develop' into task/TP-1427_github-snyk-sonarcloud
jussiviitamaki Feb 18, 2025
64936a4
Debug
jussiviitamaki Feb 18, 2025
b19770a
debug
jussiviitamaki Feb 18, 2025
e748c36
debug
jussiviitamaki Feb 18, 2025
38bdeaf
debug
jussiviitamaki Feb 18, 2025
3ec49ae
Added group exclusion for browser test
jussiviitamaki Feb 18, 2025
9d105e3
Excluded only in github failing test
jussiviitamaki Feb 18, 2025
f9b9c1f
Removed var_dumps
jussiviitamaki Feb 18, 2025
71c41a1
Excluded only in github failing test
jussiviitamaki Feb 18, 2025
8edfbd2
Removed cover comments
jussiviitamaki Feb 19, 2025
a9854aa
Declared variables in tests
jussiviitamaki Feb 19, 2025
827f2fb
Added test variable declarations
jussiviitamaki Feb 19, 2025
15bf07d
Added variable declations
jussiviitamaki Feb 19, 2025
3c27001
Disabled deprecation notifications
jussiviitamaki Feb 19, 2025
8c284bf
Fixed syntax issues
jussiviitamaki Feb 19, 2025
06bbf9c
TP-1427 Updated matomo security update
jussiviitamaki Feb 19, 2025
a237528
Added sonarcloud project key
jussiviitamaki Feb 20, 2025
8815207
Merge branch 'develop' into task/TP-1427_github-snyk-sonarcloud
jussiviitamaki Feb 20, 2025
099051d
Added sonarcloud properties
jussiviitamaki Feb 21, 2025
dc75cf0
Updated sonarqube scan
jussiviitamaki Feb 21, 2025
2831632
Testing of sonarcloud config
jussiviitamaki Feb 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
SIMPLETEST_BASE_URL: "http://127.0.0.1:8080"

jobs:

build:
runs-on: 'ubuntu-20.04'
strategy:
Expand All @@ -29,7 +30,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: gd, pdo_sqlite
extensions: gd, pdo_sqlite, xdebug

- name: Update composer
run: composer --verbose self-update --${{ matrix.composer-channel }}
Expand All @@ -43,30 +44,31 @@ jobs:
- name: Install dependencies
run: composer --verbose install

- if: matrix.drupal-release == 'dev'
run: composer --verbose require --no-update drupal/core-recommended:9.2.x-dev && composer --verbose require --no-update --dev drupal/core-dev:9.2.x-dev

- if: matrix.drupal-release == 'dev'
run: composer --verbose update

- run: ./vendor/bin/drush site-install --verbose --yes --db-url=sqlite://tmp/site.sqlite

- run: ./vendor/bin/drush runserver $SIMPLETEST_BASE_URL &

- run: until curl -s $SIMPLETEST_BASE_URL; do true; done > /dev/null

# https://www.drupal.org/project/drupal/issues/3182653
# https://www.drupal.org/node/3176567
- if: ${{ matrix.php-versions == '7.4' }} || ${{ matrix.php-versions == '8.1' }}
run: composer require phpspec/prophecy-phpunit:^2

- name: Run a single unit test to verfiy the testing setup.
run: ./vendor/bin/phpunit -c ./public/core ./public/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php

- name: Run tests with phpunit/phpunit
run: ./vendor/bin/phpunit -c /home/runner/work/drupal-helfi-tyollisyyspalvelut-manuaali/drupal-helfi-tyollisyyspalvelut-manuaali/phpunit.github.xml --exclude-group service_manual_workflow_browser_test,exclude --coverage-clover=coverage.xml ./public/modules/custom

- run: ./vendor/bin/drush

- name: Run Custom module code standards.
run: ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --ignore=node_modules,bower_components,vendor --extensions=php,module,inc,install,test,profile,theme,info,yml ./public/modules/custom

- name: Check theme coding standards .
- name: Check theme coding standards.
run: ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --ignore=node_modules,bower_components,vendor --extensions=php,module,inc,install,test,profile,theme,info,yml ./public/themes/custom

- name: Check security updates.
run: composer audit

- name: SonarQube Scan
if: ${{ env.SONARCLOUD_TOKEN }}
uses: SonarSource/sonarqube-scan-action@v4
env:
SONAR_TOKEN: ${{ secrets.sonarcloud_token }}
2 changes: 1 addition & 1 deletion .lando.php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ xdebug.max_nesting_level = 256
xdebug.show_exception_trace = 0
xdebug.client_host = ${LANDO_HOST_IP}
xdebug.log = /tmp/xdebug.log
xdebug.mode = debug
xdebug.mode = debug,coverage
xdebug.start_with_request = yes

upload_max_filesize = 200M
3 changes: 2 additions & 1 deletion .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
SIMPLETEST_DB: "mysql://drupal10:drupal10@database/drupal10"
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-gpu","--headless"]}}, "http://chrome:9515"]'
DRUSH_OPTIONS_URI: "https://helfi-manuska.lndo.site"
XDEBUG_MODE: "coverage,debug"
TFA_KEY: ''
FILE_PRIVATE_PATH: "/app/private"
chrome:
Expand Down Expand Up @@ -64,7 +65,7 @@ tooling:
cmd: /app/scripts/citrus/create-drupal-theme-lando.sh
test:
service: appserver
cmd: "php /app/vendor/bin/phpunit -c /app/phpunit.xml"
cmd: "php /app/vendor/bin/phpunit -c /app/phpunit.xml --coverage-html /app/.coverage"
test-cs:
service: appserver
description: Run Drupal 8 tests
Expand Down
6 changes: 5 additions & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
sonar.exclusions=public/modules/custom/**/tests/**
sonar.projectKey=City-of-Helsinki_drupal-helfi-tyollisyyspalvelut-manuaali
sonar.organization=city-of-helsinki
sonar.exclusions=public/sites/**
sonar.inclusions=public/modules/custom/*/src/**/*
sonar.test.inclusions=public/modules/custom/**/tests/**
sonar.php.coverage.reportPaths=coverage.xml
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions phpunit.github.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- For how to customize PHPUnit configuration, see core/tests/README.md. -->
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./public/core/tests/bootstrap.php" colors="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" beStrictAboutChangesToGlobalState="true" failOnWarning="true" printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" cacheResult="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./public/modules/custom</directory>
</include>
<exclude>
<directory>./public/modules/custom/*/tests</directory>
</exclude>
</coverage>
<php>
<!-- Disable deprecation notifications -->
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<!-- Do not limit the amount of memory tests take to run. -->
<ini name="memory_limit" value="-1"/>
<!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
<env name="SIMPLETEST_BASE_URL" value=""/>
<!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix -->
<env name="SIMPLETEST_DB" value=""/>
<!-- Example SIMPLETEST_IGNORE_DIRECTORIES value: build,dev_module -->
<env name="SIMPLETEST_IGNORE_DIRECTORIES" value=""/>
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value="sites/simpletest"/>
<!-- By default, browser tests will output links that use the base URL set
in SIMPLETEST_BASE_URL. However, if your SIMPLETEST_BASE_URL is an internal
path (such as may be the case in a virtual or Docker-based environment),
you can set the base URL used in the browser test output links to something
reachable from your host machine here. This will allow you to follow them
directly and view the output. -->
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>
<!-- To disable deprecation testing completely uncomment the next line. -->
<!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> -->
<!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' -->
<env name="MINK_DRIVER_CLASS" value=""/>
<!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' -->
<env name="MINK_DRIVER_ARGS" value=""/>
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" -->
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=""/>
<env name="DTT_MINK_DRIVER_ARGS" value='["chrome", {"chromeOptions":{"w3c": false }}, "http://chromium:4444"]'/>
<env name="DTT_API_OPTIONS" value='{"socketTimeout": 360, "domWaitTimeout": 3600000}' />
<env name="DTT_API_URL" value="http://chromium:9222"/>
<env name="DTT_BASE_URL" value="https://helfi-manuska.lndo.site"/>
</php>
<testsuites>
<testsuite name="unit">
<file>./tests/TestSuites/UnitTestSuite.php</file>
</testsuite>
<testsuite name="kernel">
<file>./tests/TestSuites/KernelTestSuite.php</file>
</testsuite>
<testsuite name="functional">
<file>./tests/TestSuites/FunctionalTestSuite.php</file>
</testsuite>
<testsuite name="functional-javascript">
<file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
</testsuite>
<testsuite name="build">
<file>./tests/TestSuites/BuildTestSuite.php</file>
</testsuite>
</testsuites>
<listeners>
<listener class="\Drupal\Tests\Listeners\DrupalListener">
</listener>
</listeners>
<!-- Filter for coverage reports. -->
</phpunit>
15 changes: 3 additions & 12 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,13 @@
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="/app/public/core/tests/bootstrap.php" colors="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" beStrictAboutChangesToGlobalState="true" failOnWarning="true" printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" cacheResult="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./public/core/tests/bootstrap.php" colors="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" beStrictAboutChangesToGlobalState="true" failOnWarning="true" printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" cacheResult="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./includes</directory>
<directory>./lib</directory>
<directory>./modules</directory>
<directory>../modules</directory>
<directory>../sites</directory>
<directory>./public/modules/custom</directory>
</include>
<exclude>
<directory>./modules/*/src/Tests</directory>
<directory>./modules/*/tests</directory>
<directory>../modules/*/src/Tests</directory>
<directory>../modules/*/tests</directory>
<directory>../modules/*/*/src/Tests</directory>
<directory>../modules/*/*/tests</directory>
<directory>./public/modules/custom/*/tests</directory>
</exclude>
</coverage>
<php>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function getGroups($node, $include_supergroups, $load_groups = FALSE)
return [];
}

if ($include_supergroups) {
if ($include_supergroups === TRUE) {
// Fetch parent groups for subgroups.
foreach ($groups as $group) {
// If groups are not loaded get only ids.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ public function testOnlySubgroupUsers(): void {
*
* @return void
* -
*
* @group exclude
*/
public function testHasParentGroupUsers(): void {
/** @var \Drupal\Core\Entity\EntityAutocompleteMatcherInterface $autocomplete */
Expand All @@ -264,6 +266,7 @@ public function testHasParentGroupUsers(): void {
'include_supergroup_members' => TRUE,
],
'Test');

$this->assertCount(2, $matches);

$users = $this->getLabelsFromMatches($matches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
use Drupal\Tests\service_manual_workflow\Traits\ServiceManualWorkflowTestTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\group\Entity\GroupInterface;
use Drupal\user\Entity\User;

/**
* Test description.
Expand Down Expand Up @@ -56,6 +58,41 @@ final class GroupsWithoutAdminTest extends GroupKernelTestBase {
'service_manual_workflow_service_test',
];

/**
* Service provider user.
*
* @var \Drupal\user\Entity\User
*/
private User $spUser;

/**
* Service provider group.
*
* @var \Drupal\group\Entity\GroupInterface
*/
private GroupInterface $spGroup;

/**
* Organization group.
*
* @var \Drupal\group\Entity\GroupInterface
*/
private GroupInterface $orgGroup;

/**
* Organization user.
*
* @var \Drupal\user\Entity\User
*/
private User $orgUser;

/**
* Organization user 2.
*
* @var \Drupal\user\Entity\User
*/
private User $orgUser2;

/**
* Setup test.
*/
Expand Down
Loading
Loading