From ad3d10607a4d07866179a77f847ae6095ae33c93 Mon Sep 17 00:00:00 2001 From: Spokje <39382-Spokje@users.noreply.drupalcode.org> Date: Sat, 28 Dec 2024 08:05:37 +0100 Subject: [PATCH 1/4] Run multiple classes? --- .gitlab-ci.yml | 220 ------------------ .gitlab-ci/pipeline.yml | 191 +-------------- .../src/Functional/CommentPreviewTest.php | 137 ----------- .../tests/src/Functional/UserEditTest.php | 107 --------- 4 files changed, 3 insertions(+), 652 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 22526bac8fd2..1308f2cb383a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -313,79 +313,6 @@ default: # Lint Jobs ################ - -'Lint cache warming': - <<: [ *default-job-settings-lint ] - stage: 🪄 Lint - rules: - - if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_ROOT_NAMESPACE == "project" - - if: $CI_PIPELINE_SOURCE == "schedule" && $CI_PROJECT_ROOT_NAMESPACE == "project" && $DAILY_TEST == "1" - - when: manual - allow_failure: true - variables: - KUBERNETES_CPU_REQUEST: "4" - script: - - *prepare-lint-directory - - *phpstan-cache - - *cspell-cache - - *eslint-cache - - *stylelint-cache - - composer install - - vendor/bin/phpstan --version - - php vendor/bin/phpstan -vvv analyze --configuration=./core/phpstan.neon.dist - - *core-spellcheck - - yarn run lint:core-js-passing --cache --cache-strategy content - - yarn run build:css --check - - yarn run lint:css --cache --cache-location .stylelintcache --cache-strategy content - - mv -f /build/core/phpstan-tmp $CI_PROJECT_DIR/core - - mv -f /build/core/.cspellcache $CI_PROJECT_DIR/core - - mv -f /build/core/.eslintcache $CI_PROJECT_DIR/core - - mv -f /build/core/.stylelintcache $CI_PROJECT_DIR/core - artifacts: - paths: - - core/phpstan-tmp/resultCache.php - - core/.cspellcache - - core/.eslintcache - - core/.stylelintcache - -'🧹 PHP Static Analysis (phpstan)': - <<: [ *default-job-settings-lint ] - stage: 🪄 Lint - variables: - KUBERNETES_CPU_REQUEST: "4" - script: - - *prepare-lint-directory - - *phpstan-cache - - composer validate - - composer install --optimize-autoloader - - if [ -n "$COMPOSER_UPDATE" ]; then - composer update --optimize-autoloader; - composer outdated; - fi - - vendor/bin/phpstan --version - # Rely on PHPStan caching to execute analysis multiple times without performance drawback. - # Output a copy in junit. - - php vendor/bin/phpstan -vvv analyze --configuration=./core/phpstan.neon.dist --error-format=gitlab > $CI_PROJECT_DIR/phpstan-quality-report.json || EXIT_CODE=$? - - php vendor/bin/phpstan -vvv analyze --configuration=./core/phpstan.neon.dist --no-progress --error-format=junit > $CI_PROJECT_DIR/phpstan-junit.xml || true - - | - if [ -n "$EXIT_CODE" ]; then - # Output a copy in plain text for human logs. - php vendor/bin/phpstan analyze --configuration=./core/phpstan.neon.dist --no-progress || true - # Generate a new baseline. - echo "Generating an PHPStan baseline file (available as job artifact)." - php vendor/bin/phpstan analyze --configuration=./core/phpstan.neon.dist --no-progress --generate-baseline=$CI_PROJECT_DIR/core/.phpstan-baseline.php || true - exit $EXIT_CODE - fi - - artifacts: - # Only store the baseline if the job fails. - when: on_failure - reports: - codequality: phpstan-quality-report.json - junit: phpstan-junit.xml - paths: - - core/.phpstan-baseline.php - '🧹 PHP Coding standards (PHPCS)': <<: [ *default-job-settings-lint ] stage: 🪄 Lint @@ -394,10 +321,6 @@ default: script: - composer validate - composer install --optimize-autoloader - - if [ -n "$COMPOSER_UPDATE" ]; then - composer update --optimize-autoloader; - composer outdated; - fi - vendor/bin/phpcs --version - composer phpcs -- -s --report-full --report-summary --report-\\Micheh\\PhpCodeSniffer\\Report\\Gitlab=phpcs-quality-report.json artifacts: @@ -407,146 +330,3 @@ default: - vendor/ reports: codequality: phpcs-quality-report.json - -'🧹 JavaScript linting (eslint)': - stage: 🪄 Lint - variables: - KUBERNETES_CPU_REQUEST: "2" - # Run on push, or on MRs if CSS files have changed, or manually. - rules: - - if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_ROOT_NAMESPACE == "project" - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - changes: - - core/.eslint* - - core/.prettier* - - core/package.json - - core/yarn.lock - - "**/*.js" - - "**/*.yml" - - when: manual - allow_failure: true - script: - - *prepare-lint-directory - - *eslint-cache - - cd core - - corepack enable - - yarn install - - yarn run check:ckeditor5 - - yarn run lint:core-js-passing --cache --cache-strategy content --format gitlab - artifacts: - reports: - codequality: eslint-quality-report.json - -'🧹 CSS linting (stylelint)': - stage: 🪄 Lint - variables: - KUBERNETES_CPU_REQUEST: "2" - # Run on push, or on MRs if CSS files have changed, or manually. - rules: - - if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_ROOT_NAMESPACE == "project" - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - changes: - - core/.stylelintrc.json - - core/.prettier* - - core/package.json - - core/yarn.lock - - "**/*.css" - - when: manual - allow_failure: true - script: - - *prepare-lint-directory - - *stylelint-cache - - corepack enable - - cd core - - yarn install - - yarn run build:css --check - - yarn run lint:css --cache --cache-location .stylelintcache --cache-strategy content --color --custom-formatter=@gitlab-formatters/stylelint-formatter-gitlab --output-file=$CI_PROJECT_DIR/gl-codequality.json - artifacts: - reports: - codequality: gl-codequality.json - -'📔 Spell-checking': - <<: [ *default-job-settings-lint ] - stage: 🪄 Lint - variables: - KUBERNETES_CPU_REQUEST: "2" - script: - - *prepare-lint-directory - - *cspell-cache - - *core-spellcheck - - mv -f /build/core/package.json $CI_PROJECT_DIR/core/package.json - - mv -f /build/core/yarn.lock $CI_PROJECT_DIR/core/yarn.lock - - mv /build/core/node_modules $CI_PROJECT_DIR/core - cache: - key: - files: - - ./core/package.json - - ./core/yarn.lock - paths: - - ./core/node_modules - artifacts: - expire_in: 1 week - expose_as: 'yarn-vendor' - paths: - - core/node_modules/ - -'📔 Validatable config': - <<: [ *default-job-settings-lint ] - stage: 🪄 Lint - variables: - KUBERNETES_CPU_REQUEST: "2" - _TARGET_PHP: "8.3-ubuntu" - # Run on MRs if config schema files have changed, or manually. - rules: - - if: $PERFORMANCE_TEST != "1" - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - changes: - - "**/config/schema/*.schema.yml" - # Modules may alter config schema using hook_config_schema_info_alter(). - - "**/*.module" - - when: manual - allow_failure: true - artifacts: - expire_in: 1 week - expose_as: 'validatable-config' - paths: - - HEAD.json - - MR.json - # This job must pass, but must also not disrupt Drupal core's CI if dependencies are not core-compatible. - allow_failure: - exit_codes: - # `composer require …` fails (implies no version available compatible with Drupal core) - - 100 - # `drush pm:install config_inspector …` fails (implies failure during module installation) - - 101 - # Temporarily allow this to fail as there's are bugs with adding/removing/modifying config schemas. - - 1 - script: - # Revert back to the tip of the branch this MR started from. - - git checkout -f $CI_MERGE_REQUEST_DIFF_BASE_SHA - # Composer-install Drush & the Config Inspector module. - - composer require drush/drush drupal/config_inspector || exit 100 - # Install Drupal's Standard install profile + all core modules (except obsolete ones) + the config inspector module. - - php core/scripts/drupal install standard - - ls core/modules | grep -v sdc | xargs vendor/bin/drush pm:install --yes - - vendor/bin/drush pm:install config_inspector --yes --quiet || exit 101 - # Compute statistics for coverage of validatable config for HEAD. - - vendor/bin/drush config:inspect --statistics > HEAD.json - # Return to the MR commit being tested, conditionally install updates, always rebuild the container. - - git checkout -f $CI_COMMIT_SHA - - git diff $CI_MERGE_REQUEST_DIFF_BASE_SHA $CI_COMMIT_SHA --name-only | grep -q '.install$\|.post_update\.php$' && echo '🤖 Installing DB updates…' && vendor/bin/drush updatedb --yes --quiet - - vendor/bin/drush cr --quiet - # Compute statistics for coverage of validatable config for MR. - - vendor/bin/drush config:inspect --statistics > MR.json - # Output diff, but never fail the job. - - diff -u HEAD.json MR.json || true - # Determine if this increased or decreased coverage. Fail the job if it is worse. All the - # percentages must be equal or higher, with the exception of `typesInUse`. - - | - php -r ' - $head = json_decode(file_get_contents("HEAD.json"), TRUE)["assessment"]; - $mr = json_decode(file_get_contents("MR.json"), TRUE)["assessment"]; - unset($head["_description"], $head["typesInUse"], $mr["_description"], $mr["typesInUse"]); - $impact = array_map(fn (float $h, float $m) => $m-$h, $head, $mr); - exit((int) (min($impact) < 0)); - ' diff --git a/.gitlab-ci/pipeline.yml b/.gitlab-ci/pipeline.yml index 14fc2e5e9b7e..c898bf19a3cd 100644 --- a/.gitlab-ci/pipeline.yml +++ b/.gitlab-ci/pipeline.yml @@ -105,16 +105,7 @@ variables: .run-repeat-class-test: &run-repeat-class-test script: - - echo "ℹ️ Running class ${REPEAT_TEST_CLASS}" - - | - if [[ $REPEAT_TEST_CLASS == "Drupal\Tests\Change\Me" ]]; then - echo '❗ You need to change the REPEAT_TEST_CLASS variable to an existing class before running the job.' - echo ' You just need to click on the job that you want to run (do not press the play button straight away) and then set the following:' - echo ' "Key" to "REPEAT_TEST_CLASS" and "Value" to "Drupal\Tests\ckeditor5\FunctionalJavascript\MediaLinkabilityTest"'; - exit 1; - else - sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./core/scripts/run-tests.sh --color --keep-results --concurrency "$CONCURRENCY" --repeat "100" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html --class $REPEAT_TEST_CLASS - fi + - sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./core/scripts/run-tests.sh --color --keep-results --concurrency "$CONCURRENCY" --repeat "2500" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html --class "\Drupal\Tests\comment\Functional\CommentPreviewTest,\Drupal\Tests\user\Functional\UserEditTest" ################ # Jobs @@ -126,185 +117,9 @@ variables: # Documentation: https://docs.gitlab.com/ee/ci/jobs/ ################ -'🩹 Test-only changes': - <<: [ *with-composer, *default-job-settings ] - when: manual - allow_failure: true - services: - - <<: *with-database - - <<: *with-chrome - script: - - $CI_PROJECT_DIR/.gitlab-ci/scripts/test-only.sh - -'🖱️️️ PHPUnit Functional Javascript': - <<: [ *with-composer, *run-tests, *default-job-settings ] - parallel: 3 - variables: - TESTSUITE: PHPUnit-FunctionalJavascript - CONCURRENCY: 5 - KUBERNETES_CPU_REQUEST: "16" - services: - - <<: *with-database - - <<: *with-selenium-chrome - after_script: - - echo $MINK_DRIVER_ARGS_WEBDRIVER - - sed -i "s#$CI_PROJECT_DIR/##" ./sites/default/files/simpletest/phpunit-*.xml || true - - cp /builds/chromedriver.log ./ - -'🖱️️️ PHPUnit Functional Javascript (non W3C legacy)': - <<: [ *with-composer, *default-job-settings ] - parallel: 1 - variables: - TESTSUITE: PHPUnit-FunctionalJavascript - CONCURRENCY: 6 - KUBERNETES_CPU_REQUEST: "16" - MINK_DRIVER_ARGS_WEBDRIVER: $MINK_DRIVER_ARGS_WEBDRIVER_CHROMEDRIVER_NON_W3C - services: - - <<: *with-database - - <<: *with-chrome - script: - # Run a small subset of tests to prove non W3C testing still works. - - sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./core/scripts/run-tests.sh --color --keep-results --types "$TESTSUITE" --concurrency "$CONCURRENCY" --repeat "1" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html javascript - - after_script: - - sed -i "s#$CI_PROJECT_DIR/##" ./sites/default/files/simpletest/phpunit-*.xml || true - - cp /builds/chromedriver.log ./ - -'🌐️️ PHPUnit Functional': - <<: [ *with-composer, *run-tests, *default-job-settings ] - parallel: 8 - variables: - TESTSUITE: PHPUnit-Functional - CONCURRENCY: "5" - KUBERNETES_CPU_REQUEST: "16" - services: - - <<: *with-database - -'⚙️️ PHPUnit Kernel': - <<: [ *with-composer, *run-tests, *default-job-settings ] - parallel: 5 - variables: - TESTSUITE: PHPUnit-Kernel - KUBERNETES_CPU_REQUEST: "8" - CONCURRENCY: 12 - services: - - <<: *with-database - -'👷️️️ PHPUnit Build': - <<: [ *with-composer, *run-tests, *default-job-settings ] - variables: - TESTSUITE: PHPUnit-Build - KUBERNETES_CPU_REQUEST: "8" - CONCURRENCY: "5" - services: - - <<: *with-database - -'⚡️ PHPUnit Unit': - <<: [ *with-composer, *run-tests, *default-job-settings ] - variables: - TESTSUITE: PHPUnit-Unit - KUBERNETES_CPU_REQUEST: "1" - CONCURRENCY: 6 - -'✅️ PHPStan Tests': - <<: [ *default-job-settings ] - variables: - KUBERNETES_CPU_REQUEST: "2" - # Run if PHPStan files have changed, or manually. - rules: - - if: $CI_PIPELINE_SOURCE == "parent_pipeline" && $PERFORMANCE_TEST != "1" - changes: - - core/tests/PHPStan/* - - composer/Metapackage/PinnedDevDependencies/composer.json - - when: manual - allow_failure: true - # Default job settings runs a script that expects vendor to exist. - before_script: [] - script: - - docker-php-ext-enable pcov - - cd core/tests/PHPStan - - composer install - - vendor/bin/phpunit tests --testdox --coverage-text --colors=never --coverage-cobertura=coverage.cobertura.xml --log-junit junit.xml - # Default job settings runs a script that junit files in a specific location.. - after_script: [] - artifacts: - when: always - reports: - junit: core/tests/PHPStan/junit.xml - coverage_report: - coverage_format: cobertura - path: core/tests/PHPStan/coverage.cobertura.xml - -'🦉️️️ Nightwatch': - <<: [ *with-composer-and-yarn, *default-job-settings ] - variables: - KUBERNETES_CPU_REQUEST: "16" - services: - - <<: *with-database - - <<: *with-selenium-chrome - script: - - export DRUPAL_TEST_DB_URL=$SIMPLETEST_DB - - cp ./core/.env.example ./core/.env - # dotenv-safe/config does not support environment variables - # @see https://github.com/rolodato/dotenv-safe/issues/126 - # @todo move this to `variables` when the above is resolved - - echo "DRUPAL_TEST_BASE_URL='http://localhost/subdirectory'" >> ./core/.env - - echo "DRUPAL_TEST_CHROMEDRIVER_AUTOSTART=false" >> ./core/.env - - echo "DRUPAL_TEST_DB_URL='${DRUPAL_TEST_DB_URL}'" >> ./core/.env - - echo "DRUPAL_TEST_WEBDRIVER_HOSTNAME='selenium'" >> ./core/.env - - echo "DRUPAL_TEST_WEBDRIVER_CHROME_ARGS='--disable-dev-shm-usage --disable-gpu --headless --dns-prefetch-disable'" >> ./core/.env - - echo "DRUPAL_TEST_WEBDRIVER_W3C=true" >> ./core/.env - - echo "DRUPAL_TEST_WEBDRIVER_PORT='4444'" >> ./core/.env - - echo "DRUPAL_NIGHTWATCH_OUTPUT='"../nightwatch_output"'" >> ./core/.env - - echo "COLUMNS=1000" >> ./core/.env - - chown -R www-data:www-data ./sites /var/www - - cd core - - corepack enable - - sudo -u www-data yarn run test:nightwatch --workers=3 - after_script: - - cp /builds/chromedriver.log ./ - artifacts: - when: always - expire_in: 6 mos - reports: - junit: ./nightwatch_output/**/*.xml - paths: - - ./nightwatch_output - - '*.log' - '🔁 Repeat Class Test': <<: [ *with-composer, *run-repeat-class-test, *default-job-settings ] - when: manual - allow_failure: true - variables: - REPEAT_TEST_CLASS: 'Drupal\Tests\Change\Me' - services: - - <<: *with-database - -'🚲 Performance tests': - <<: [ *default-job-settings ] - rules: - - if: $PERFORMANCE_TEST == "1" - - when: manual - allow_failure: true - variables: - KUBERNETES_CPU_REQUEST: "24" - MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-dev-shm-usage","--disable-gpu","--headless","--no-sandbox"]}}, "http://chrome:9515"]' - tags: - - performance-test-runner + when: always + allow_failure: false services: - <<: *with-database - - <<: *with-chrome - script: - # Determine DB driver. - - | - [[ $_TARGET_DB == sqlite* ]] && export SIMPLETEST_DB=sqlite://localhost/subdirectory/sites/default/files/db.sqlite?module=sqlite - [[ $_TARGET_DB == mysql* ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE?module=mysql - [[ $_TARGET_DB == mariadb* ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE?module=mysql - [[ $_TARGET_DB == pgsql* ]] && export SIMPLETEST_DB=pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@database/$POSTGRES_DB?module=pgsql - - composer install --optimize-autoloader - - export OTEL_COLLECTOR="$OTEL_COLLECTOR" - - mkdir -p ./sites/simpletest ./sites/default/files ./build/logs/junit /var/www/.composer - - chown -R www-data:www-data ./sites ./build/logs/junit ./vendor /var/www/ - - sudo -u www-data git config --global --add safe.directory $CI_PROJECT_DIR - - sudo SIMPLETEST_BASE_URL="http://$HOSTNAME/subdirectory" SIMPLETEST_DB="$SIMPLETEST_DB" MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" OTEL_COLLECTOR="$OTEL_COLLECTOR" -u www-data ./vendor/bin/phpunit -c core --group OpenTelemetry --log-junit=./sites/default/files/simpletest/phpunit-performance.xml diff --git a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php index a3d3c16f6367..7fb87327bd5c 100644 --- a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php @@ -6,8 +6,6 @@ use Drupal\comment\CommentManagerInterface; use Drupal\Component\Render\MarkupInterface; -use Drupal\Core\Datetime\DrupalDateTime; -use Drupal\comment\Entity\Comment; use Drupal\Tests\TestFileCreationTrait; /** @@ -87,139 +85,4 @@ public function testCommentPreview(): void { $this->assertSession()->elementExists('xpath', $xpath); } - /** - * Tests comment preview. - */ - public function testCommentPreviewDuplicateSubmission(): void { - $this->setCommentPreview(DRUPAL_OPTIONAL); - $this->setCommentForm(TRUE); - $this->setCommentSubject(TRUE); - $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.'); - - // Log in as web user. - $this->drupalLogin($this->webUser); - - // As the web user, fill in the comment form and preview the comment. - $edit = []; - $edit['subject[0][value]'] = $this->randomMachineName(8); - $edit['comment_body[0][value]'] = $this->randomMachineName(16); - $this->drupalGet('node/' . $this->node->id()); - $this->submitForm($edit, 'Preview'); - - // Check that the preview is displaying the title and body. - $this->assertSession()->titleEquals('Preview comment | Drupal'); - $this->assertSession()->pageTextContains($edit['subject[0][value]']); - $this->assertSession()->pageTextContains($edit['comment_body[0][value]']); - - // Check that the title and body fields are displayed with the correct values. - $this->assertSession()->fieldValueEquals('subject[0][value]', $edit['subject[0][value]']); - $this->assertSession()->fieldValueEquals('comment_body[0][value]', $edit['comment_body[0][value]']); - - // Store the content of this page. - $this->submitForm([], 'Save'); - $this->assertSession()->pageTextContains('Your comment has been posted.'); - $this->assertSession()->elementsCount('xpath', '//section[contains(@class, "comments")]/article', 1); - - // Go back and re-submit the form. - $this->getSession()->getDriver()->back(); - $submit_button = $this->assertSession()->buttonExists('Save'); - $submit_button->click(); - $this->assertSession()->pageTextContains('Your comment has been posted.'); - $this->assertSession()->elementsCount('xpath', '//section[contains(@class, "comments")]/article', 2); - } - - /** - * Tests comment edit, preview, and save. - */ - public function testCommentEditPreviewSave(): void { - $web_user = $this->drupalCreateUser([ - 'access comments', - 'post comments', - 'skip comment approval', - 'edit own comments', - ]); - $this->drupalLogin($this->adminUser); - $this->setCommentPreview(DRUPAL_OPTIONAL); - $this->setCommentForm(TRUE); - $this->setCommentSubject(TRUE); - $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.'); - - $edit = []; - $date = new DrupalDateTime('2008-03-02 17:23'); - $edit['subject[0][value]'] = $this->randomMachineName(8); - $edit['comment_body[0][value]'] = $this->randomMachineName(16); - $edit['uid'] = $web_user->getAccountName() . ' (' . $web_user->id() . ')'; - $edit['date[date]'] = $date->format('Y-m-d'); - $edit['date[time]'] = $date->format('H:i:s'); - $raw_date = $date->getTimestamp(); - $expected_text_date = $this->container->get('date.formatter')->formatInterval(\Drupal::time()->getRequestTime() - $raw_date); - $expected_form_date = $date->format('Y-m-d'); - $expected_form_time = $date->format('H:i:s'); - $comment = $this->postComment($this->node, $edit['subject[0][value]'], $edit['comment_body[0][value]'], TRUE); - $this->drupalGet('comment/' . $comment->id() . '/edit'); - $this->submitForm($edit, 'Preview'); - - // Check that the preview is displaying the subject, comment, author and date correctly. - $this->assertSession()->titleEquals('Preview comment | Drupal'); - $this->assertSession()->pageTextContains($edit['subject[0][value]']); - $this->assertSession()->pageTextContains($edit['comment_body[0][value]']); - $this->assertSession()->pageTextContains($web_user->getAccountName()); - $this->assertSession()->pageTextContains($expected_text_date); - - // Check that the subject, comment, author and date fields are displayed with the correct values. - $this->assertSession()->fieldValueEquals('subject[0][value]', $edit['subject[0][value]']); - $this->assertSession()->fieldValueEquals('comment_body[0][value]', $edit['comment_body[0][value]']); - $this->assertSession()->fieldValueEquals('uid', $edit['uid']); - $this->assertSession()->fieldValueEquals('date[date]', $edit['date[date]']); - $this->assertSession()->fieldValueEquals('date[time]', $edit['date[time]']); - - // Check that saving a comment produces a success message. - $this->drupalGet('comment/' . $comment->id() . '/edit'); - $this->submitForm($edit, 'Save'); - $this->assertSession()->pageTextContains('Your comment has been updated.'); - - // Check that the comment fields are correct after loading the saved comment. - $this->drupalGet('comment/' . $comment->id() . '/edit'); - $this->assertSession()->fieldValueEquals('subject[0][value]', $edit['subject[0][value]']); - $this->assertSession()->fieldValueEquals('comment_body[0][value]', $edit['comment_body[0][value]']); - $this->assertSession()->fieldValueEquals('uid', $edit['uid']); - $this->assertSession()->fieldValueEquals('date[date]', $expected_form_date); - $this->assertSession()->fieldValueEquals('date[time]', $expected_form_time); - - // Submit the form using the displayed values. - $displayed = []; - $displayed['subject[0][value]'] = $this->assertSession()->fieldExists('edit-subject-0-value')->getValue(); - $displayed['comment_body[0][value]'] = $this->assertSession()->fieldExists('edit-comment-body-0-value')->getValue(); - $displayed['uid'] = $this->assertSession()->fieldExists('edit-uid')->getValue(); - $displayed['date[date]'] = $this->assertSession()->fieldExists('edit-date-date')->getValue(); - $displayed['date[time]'] = $this->assertSession()->fieldExists('edit-date-time')->getValue(); - $this->drupalGet('comment/' . $comment->id() . '/edit'); - $this->submitForm($displayed, 'Save'); - - // Check that the saved comment is still correct. - $comment_storage = \Drupal::entityTypeManager()->getStorage('comment'); - $comment_storage->resetCache([$comment->id()]); - /** @var \Drupal\comment\CommentInterface $comment_loaded */ - $comment_loaded = Comment::load($comment->id()); - $this->assertEquals($edit['subject[0][value]'], $comment_loaded->getSubject(), 'Subject loaded.'); - $this->assertEquals($edit['comment_body[0][value]'], $comment_loaded->comment_body->value, 'Comment body loaded.'); - $this->assertEquals($web_user->id(), $comment_loaded->getOwner()->id(), 'Name loaded.'); - $this->assertEquals($raw_date, $comment_loaded->getCreatedTime(), 'Date loaded.'); - $this->drupalLogout(); - - // Check that the date and time of the comment are correct when edited by - // non-admin users. - $user_edit = []; - $expected_created_time = $comment_loaded->getCreatedTime(); - $this->drupalLogin($web_user); - // Web user cannot change the comment author. - unset($edit['uid']); - $this->drupalGet('comment/' . $comment->id() . '/edit'); - $this->submitForm($user_edit, 'Save'); - $comment_storage->resetCache([$comment->id()]); - $comment_loaded = Comment::load($comment->id()); - $this->assertEquals($expected_created_time, $comment_loaded->getCreatedTime(), 'Expected date and time for comment edited.'); - $this->drupalLogout(); - } - } diff --git a/core/modules/user/tests/src/Functional/UserEditTest.php b/core/modules/user/tests/src/Functional/UserEditTest.php index 295bc01f26e9..3fac608c5d95 100644 --- a/core/modules/user/tests/src/Functional/UserEditTest.php +++ b/core/modules/user/tests/src/Functional/UserEditTest.php @@ -140,113 +140,6 @@ public function testUserEdit(): void { $this->assertSession()->checkboxChecked('edit-status-1'); } - /** - * Tests setting the password to "0". - * - * We discovered in https://www.drupal.org/node/2563751 that logging in with a - * password that is literally "0" was not possible. This test ensures that - * this regression can't happen again. - */ - public function testUserWith0Password(): void { - $admin = $this->drupalCreateUser(['administer users']); - $this->drupalLogin($admin); - // Create a regular user. - $user1 = $this->drupalCreateUser([]); - - $edit = ['pass[pass1]' => '0', 'pass[pass2]' => '0']; - $this->drupalGet("user/" . $user1->id() . "/edit"); - $this->submitForm($edit, 'Save'); - $this->assertSession()->pageTextContains("The changes have been saved."); - } - - /** - * Tests editing of a user account without an email address. - */ - public function testUserWithoutEmailEdit(): void { - // Test that an admin can edit users without an email address. - $admin = $this->drupalCreateUser(['administer users']); - $this->drupalLogin($admin); - // Create a regular user. - $user1 = $this->drupalCreateUser([]); - // This user has no email address. - $user1->mail = ''; - $user1->save(); - $this->drupalGet("user/" . $user1->id() . "/edit"); - $this->submitForm(['mail' => ''], 'Save'); - $this->assertSession()->pageTextContains("The changes have been saved."); - } - - /** - * Tests well known change password route redirects to user edit form. - */ - public function testUserWellKnownChangePasswordAuth(): void { - $account = $this->drupalCreateUser([]); - $this->drupalLogin($account); - $this->drupalGet('.well-known/change-password'); - $this->assertSession()->addressEquals("user/" . $account->id() . "/edit"); - } - - /** - * Tests well known change password route returns 403 to anonymous user. - */ - public function testUserWellKnownChangePasswordAnon(): void { - $this->drupalGet('.well-known/change-password'); - $this->assertSession()->statusCodeEquals(403); - } - - /** - * Tests that a user is able to change site language. - */ - public function testUserChangeSiteLanguage(): void { - // Install these modules here as these aren't needed for other test methods. - \Drupal::service('module_installer')->install([ - 'content_translation', - 'language', - ]); - // Create and login as an admin user to add a new language and enable - // translation for user accounts. - $adminUser = $this->drupalCreateUser([ - 'administer account settings', - 'administer languages', - 'administer content translation', - 'administer users', - 'translate any entity', - ]); - $this->drupalLogin($adminUser); - - // Add a new language into the system. - $edit = [ - 'predefined_langcode' => 'fr', - ]; - $this->drupalGet('admin/config/regional/language/add'); - $this->submitForm($edit, 'Add language'); - $this->assertSession()->pageTextContains('French'); - - // Enable translation for user accounts. - $edit = [ - 'language[content_translation]' => 1, - ]; - $this->drupalGet('admin/config/people/accounts'); - $this->submitForm($edit, 'Save configuration'); - $this->assertSession()->pageTextContains('The configuration options have been saved.'); - - // Create a regular user for whom translation will be enabled. - $webUser = $this->drupalCreateUser(); - - // Create a translation for a regular user account. - $this->drupalGet('user/' . $webUser->id() . '/translations/add/en/fr'); - $this->submitForm([], 'Save'); - $this->assertSession()->pageTextContains('The changes have been saved.'); - - // Update the site language of the user account. - $edit = [ - 'preferred_langcode' => 'fr', - ]; - $this->drupalGet('user/' . $webUser->id() . '/edit'); - $this->submitForm($edit, 'Save'); - $this->assertSession()->statusCodeEquals(200); - } - /** * Tests the account form implements entity field access for mail. */ -- GitLab From 836ff5280171326dcfa0166cb2f2acc723c38e89 Mon Sep 17 00:00:00 2001 From: Spokje <39382-Spokje@users.noreply.drupalcode.org> Date: Sat, 28 Dec 2024 08:12:24 +0100 Subject: [PATCH 2/4] 1500x 4 classes as-is --- .gitlab-ci/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci/pipeline.yml b/.gitlab-ci/pipeline.yml index c898bf19a3cd..ffdae66c37fc 100644 --- a/.gitlab-ci/pipeline.yml +++ b/.gitlab-ci/pipeline.yml @@ -105,7 +105,7 @@ variables: .run-repeat-class-test: &run-repeat-class-test script: - - sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./core/scripts/run-tests.sh --color --keep-results --concurrency "$CONCURRENCY" --repeat "2500" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html --class "\Drupal\Tests\comment\Functional\CommentPreviewTest,\Drupal\Tests\user\Functional\UserEditTest" + - sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./core/scripts/run-tests.sh --color --keep-results --concurrency "$CONCURRENCY" --repeat "1500" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html --class "\Drupal\Tests\comment\Functional\CommentPreviewTest,\Drupal\Tests\user\Functional\UserEditTest,\Drupal\Tests\user\Functional\UserTokenReplaceTest,\Drupal\Tests\user\Kernel\UserEntityLabelTest" ################ # Jobs -- GitLab From 1e79147c835efc91e94ce62ddf95a52d08b0dd4d Mon Sep 17 00:00:00 2001 From: Spokje <39382-Spokje@users.noreply.drupalcode.org> Date: Sat, 28 Dec 2024 08:50:53 +0100 Subject: [PATCH 3/4] 2500x 4 classes as-is --- .gitlab-ci/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci/pipeline.yml b/.gitlab-ci/pipeline.yml index ffdae66c37fc..f57d750430ff 100644 --- a/.gitlab-ci/pipeline.yml +++ b/.gitlab-ci/pipeline.yml @@ -105,7 +105,7 @@ variables: .run-repeat-class-test: &run-repeat-class-test script: - - sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./core/scripts/run-tests.sh --color --keep-results --concurrency "$CONCURRENCY" --repeat "1500" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html --class "\Drupal\Tests\comment\Functional\CommentPreviewTest,\Drupal\Tests\user\Functional\UserEditTest,\Drupal\Tests\user\Functional\UserTokenReplaceTest,\Drupal\Tests\user\Kernel\UserEntityLabelTest" + - sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./core/scripts/run-tests.sh --color --keep-results --concurrency "$CONCURRENCY" --repeat "2500" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html --class "\Drupal\Tests\comment\Functional\CommentPreviewTest,\Drupal\Tests\user\Functional\UserEditTest,\Drupal\Tests\user\Functional\UserTokenReplaceTest,\Drupal\Tests\user\Kernel\UserEntityLabelTest" ################ # Jobs -- GitLab From a6af0116a8e0a2a39ff916137b4a678ff201a222 Mon Sep 17 00:00:00 2001 From: Spokje <39382-Spokje@users.noreply.drupalcode.org> Date: Sat, 28 Dec 2024 09:05:37 +0100 Subject: [PATCH 4/4] 2500x 4 classes as-is --- .../user/tests/src/Functional/UserEditTest.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/core/modules/user/tests/src/Functional/UserEditTest.php b/core/modules/user/tests/src/Functional/UserEditTest.php index 3fac608c5d95..6cda7a6e2fa1 100644 --- a/core/modules/user/tests/src/Functional/UserEditTest.php +++ b/core/modules/user/tests/src/Functional/UserEditTest.php @@ -140,16 +140,4 @@ public function testUserEdit(): void { $this->assertSession()->checkboxChecked('edit-status-1'); } - /** - * Tests the account form implements entity field access for mail. - */ - public function testUserMailFieldAccess(): void { - \Drupal::state()->set('user_access_test_forbid_mail_edit', TRUE); - \Drupal::service('module_installer')->install(['user_access_test']); - $user = $this->drupalCreateUser(); - $this->drupalLogin($user); - $this->drupalGet("user/" . $user->id() . "/edit"); - $this->assertFalse($this->getSession()->getPage()->hasField('mail')); - } - } -- GitLab