diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 22526bac8fd230bf18c13ecccef2bf9a7d36628d..1308f2cb383a9e87dc8c371425d98ca2aace973e 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 14fc2e5e9b7e3d31965aff551b488fdbc6ad59ef..a9e952a7836a9e99845fac4380eabc540e0a58ad 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\layout_builder\Functional\LayoutBuilderBlocksTest" ################ # 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/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php index da9657a5aa985ae7af901027fbfc3197637d970c..37ccefa36b3a9961d9ac12ac4e18de140986e1cb 100644 --- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php +++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php @@ -21,7 +21,7 @@ class TestCacheBlock extends BlockBase { * {@inheritdoc} */ public function build() { - $content = \Drupal::state()->get('block_test.content'); + $content = \Drupal::keyValue('block_test')->get('content'); $build = []; if (!empty($content)) { diff --git a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderBlocksTest.php b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderBlocksTest.php index be7825d46e22ad3f64294bd98c4e30bbca2aefee..705d298c834662d86e7c797e582802a0c916be88 100644 --- a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderBlocksTest.php +++ b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderBlocksTest.php @@ -4,11 +4,6 @@ namespace Drupal\Tests\layout_builder\Functional; -use Drupal\node\Entity\Node; -use Drupal\views\Entity\View; - -// cspell:ignore blocktest - /** * Tests the Layout Builder UI with blocks. * @@ -16,166 +11,6 @@ */ class LayoutBuilderBlocksTest extends LayoutBuilderTestBase { - /** - * Tests that block plugins can define custom attributes and contextual links. - */ - public function testPluginsProvidingCustomAttributesAndContextualLinks(): void { - $assert_session = $this->assertSession(); - $page = $this->getSession()->getPage(); - - $this->drupalLogin($this->drupalCreateUser([ - 'access contextual links', - 'configure any layout', - 'administer node display', - ])); - - $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default'); - $this->submitForm(['layout[enabled]' => TRUE], 'Save'); - $page->clickLink('Manage layout'); - $page->clickLink('Add section'); - $page->clickLink('Layout Builder Test Plugin'); - $page->pressButton('Add section'); - $page->clickLink('Add block'); - $page->clickLink('Test Attributes'); - $page->pressButton('Add block'); - $page->pressButton('Save layout'); - - $this->drupalGet('node/1'); - - $assert_session->elementExists('css', '.attribute-test-class'); - $assert_session->elementExists('css', '[custom-attribute=test]'); - $assert_session->elementExists('css', 'div[data-contextual-id*="layout_builder_test"]'); - } - - /** - * Tests preview-aware layout & block plugins. - */ - public function testPreviewAwarePlugins(): void { - $assert_session = $this->assertSession(); - $page = $this->getSession()->getPage(); - - $this->drupalLogin($this->drupalCreateUser([ - 'configure any layout', - 'administer node display', - ])); - - $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default'); - $this->submitForm(['layout[enabled]' => TRUE], 'Save'); - $page->clickLink('Manage layout'); - $page->clickLink('Add section'); - $page->clickLink('Layout Builder Test Plugin'); - $page->pressButton('Add section'); - $page->clickLink('Add block'); - $page->clickLink('Preview-aware block'); - $page->pressButton('Add block'); - - $assert_session->elementExists('css', '.go-birds-preview'); - $assert_session->pageTextContains('The block template is being previewed.'); - $assert_session->pageTextContains('This block is being rendered in preview mode.'); - - $page->pressButton('Save layout'); - $this->drupalGet('node/1'); - - $assert_session->elementNotExists('css', '.go-birds-preview'); - $assert_session->pageTextNotContains('The block template is being previewed.'); - $assert_session->pageTextContains('This block is being rendered normally.'); - } - - /** - * {@inheritdoc} - */ - public function testLayoutBuilderChooseBlocksAlter(): void { - // See layout_builder_test_plugin_filter_block__layout_builder_alter(). - $assert_session = $this->assertSession(); - - $this->drupalLogin($this->drupalCreateUser([ - 'configure any layout', - 'administer node display', - 'administer node fields', - ])); - - // From the manage display page, go to manage the layout. - $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default'); - $this->submitForm(['layout[enabled]' => TRUE], 'Save'); - $assert_session->linkExists('Manage layout'); - $this->clickLink('Manage layout'); - - // Add a new block. - $this->clickLink('Add block'); - - // Verify that blocks not modified are present. - $assert_session->linkExists('Powered by Drupal'); - $assert_session->linkExists('Default revision'); - - // Verify that blocks explicitly removed are not present. - $assert_session->linkNotExists('Help'); - $assert_session->linkNotExists('Sticky at top of lists'); - $assert_session->linkNotExists('Main page content'); - $assert_session->linkNotExists('Page title'); - $assert_session->linkNotExists('Messages'); - $assert_session->linkNotExists('Help'); - $assert_session->linkNotExists('Tabs'); - $assert_session->linkNotExists('Primary admin actions'); - - // Verify that Changed block is not present on first section. - $assert_session->linkNotExists('Changed'); - - // Go back to Manage layout. - $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default'); - $this->clickLink('Manage layout'); - - // Add a new section. - $this->clickLink('Add section', 1); - $assert_session->linkExists('Two column'); - $this->clickLink('Two column'); - $assert_session->buttonExists('Add section'); - $this->getSession()->getPage()->pressButton('Add section'); - // Add a new block to second section. - $this->clickLink('Add block', 1); - - // Verify that Changed block is present on second section. - $assert_session->linkExists('Changed'); - } - - /** - * Tests that deleting a View block used in Layout Builder works. - */ - public function testDeletedView(): void { - $assert_session = $this->assertSession(); - $page = $this->getSession()->getPage(); - - $this->drupalLogin($this->drupalCreateUser([ - 'configure any layout', - 'administer node display', - ])); - - $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field'; - // Enable overrides. - $this->drupalGet("{$field_ui_prefix}/display/default"); - $this->submitForm(['layout[enabled]' => TRUE], 'Save'); - $this->drupalGet("{$field_ui_prefix}/display/default"); - $this->submitForm(['layout[allow_custom]' => TRUE], 'Save'); - $this->drupalGet('node/1'); - - $assert_session->linkExists('Layout'); - $this->clickLink('Layout'); - $this->clickLink('Add block'); - $this->clickLink('Test Block View'); - $page->pressButton('Add block'); - - $assert_session->pageTextContains('Test Block View'); - $assert_session->elementExists('css', '.block-views-blocktest-block-view-block-1'); - $page->pressButton('Save'); - $assert_session->pageTextContains('Test Block View'); - $assert_session->elementExists('css', '.block-views-blocktest-block-view-block-1'); - - View::load('test_block_view')->delete(); - $this->drupalGet('node/1'); - // Node can be loaded after deleting the View. - $assert_session->pageTextContains(Node::load(1)->getTitle()); - $assert_session->pageTextNotContains('Test Block View'); - } - /** * Tests the usage of placeholders for empty blocks. * @@ -212,7 +47,7 @@ public function testBlockPlaceholder(): void { $assert_session->pageTextNotContains($block_content); // Set block content and reload the page. - \Drupal::state()->set('block_test.content', $block_content); + \Drupal::keyValue('block_test')->set('content', $block_content); $this->getSession()->reload(); // The block placeholder is no longer displayed and the content is visible. @@ -220,66 +55,4 @@ public function testBlockPlaceholder(): void { $assert_session->pageTextContains($block_content); } - /** - * Tests the ability to use a specified block label for field blocks. - */ - public function testFieldBlockLabel(): void { - $assert_session = $this->assertSession(); - $page = $this->getSession()->getPage(); - - $this->drupalLogin($this->drupalCreateUser([ - 'configure any layout', - 'administer node display', - ])); - - $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field'; - $this->drupalGet("$field_ui_prefix/display/default"); - $this->submitForm(['layout[enabled]' => TRUE], 'Save'); - - // Customize the default view mode. - $this->drupalGet("$field_ui_prefix/display/default/layout"); - - // Add a body block whose label will be overridden. - $this->clickLink('Add block'); - $this->clickLink('Body'); - - // Enable the Label Display and set the Label to a modified field - // block label. - $modified_field_block_label = 'Modified Field Block Label'; - $page->checkField('settings[label_display]'); - $page->fillField('settings[label]', $modified_field_block_label); - - // Save the block and layout. - $page->pressButton('Add block'); - $page->pressButton('Save layout'); - - // Revisit the default layout view mode page. - $this->drupalGet("$field_ui_prefix/display/default/layout"); - - // The modified field block label is displayed. - $assert_session->pageTextContains($modified_field_block_label); - } - - /** - * Tests the Block UI when Layout Builder is installed. - */ - public function testBlockUiListing(): void { - $assert_session = $this->assertSession(); - $page = $this->getSession()->getPage(); - - $this->drupalLogin($this->drupalCreateUser([ - 'administer blocks', - ])); - - $this->drupalGet('admin/structure/block'); - $page->clickLink('Place block'); - - // Ensure that blocks expected to appear are available. - $assert_session->pageTextContains('Test HTML block'); - $assert_session->pageTextContains('Block test'); - // Ensure that blocks not expected to appear are not available. - $assert_session->pageTextNotContains('Body'); - $assert_session->pageTextNotContains('Content fields'); - } - }