From 6a28e4bd80b4688dd4bb6f30e4a06ca82ebe71b5 Mon Sep 17 00:00:00 2001
From: "omkar.podey" <omkar.podey@3685158.no-reply.drupal.org>
Date: Thu, 29 Sep 2022 14:13:56 +0000
Subject: [PATCH] Issue #3293148 by kunal.sachdev, omkar.podey: Clean up or
 remove PackageUpdateTest

---
 .../updated_module/1.0.0/src/ChangedClass.php |  17 --
 .../updated_module/1.0.0/src/DeletedClass.php |  17 --
 .../1.0.0/src/LoadedAndDeletedClass.php       |  17 --
 .../1.0.0/src/Plugin/Block/DeletedBlock.php   |  26 --
 .../1.0.0/src/Plugin/Block/IgnoredBlock.php   |  29 ---
 .../1.0.0/src/Plugin/Block/UpdatedBlock.php   |  29 ---
 .../1.0.0/updated_module.module               |   9 -
 .../1.0.0/updated_module.permissions.yml      |   4 -
 .../1.0.0/updated_module.routing.yml          |  12 -
 .../1.0.0/updated_module.services.yml         |   9 -
 .../updated_module/1.1.0/src/AddedClass.php   |  17 --
 .../updated_module/1.1.0/src/ChangedClass.php |  17 --
 .../1.1.0/src/Plugin/Block/AddedBlock.php     |  26 --
 .../1.1.0/src/Plugin/Block/IgnoredBlock.php   |  29 ---
 .../1.1.0/src/Plugin/Block/UpdatedBlock.php   |  29 ---
 .../1.1.0/updated_module.module               |  15 --
 .../1.1.0/updated_module.permissions.yml      |   4 -
 .../1.1.0/updated_module.routing.yml          |  12 -
 .../1.1.0/updated_module.services.yml         |   8 -
 .../package_manager_test_api.services.yml     |  11 -
 .../src/SystemChangeRecorder.php              | 243 ------------------
 .../tests/src/Build/PackageUpdateTest.php     |  92 -------
 22 files changed, 672 deletions(-)
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.0.0/src/ChangedClass.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.0.0/src/DeletedClass.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.0.0/src/LoadedAndDeletedClass.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/DeletedBlock.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/IgnoredBlock.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/UpdatedBlock.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.0.0/updated_module.permissions.yml
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.0.0/updated_module.routing.yml
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.0.0/updated_module.services.yml
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.1.0/src/AddedClass.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.1.0/src/ChangedClass.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/AddedBlock.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/IgnoredBlock.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/UpdatedBlock.php
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.1.0/updated_module.permissions.yml
 delete mode 100644 package_manager/tests/fixtures/updated_module/1.1.0/updated_module.routing.yml
 delete mode 100644 package_manager/tests/modules/package_manager_test_api/package_manager_test_api.services.yml
 delete mode 100644 package_manager/tests/modules/package_manager_test_api/src/SystemChangeRecorder.php

diff --git a/package_manager/tests/fixtures/updated_module/1.0.0/src/ChangedClass.php b/package_manager/tests/fixtures/updated_module/1.0.0/src/ChangedClass.php
deleted file mode 100644
index 1ec6c3b956..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.0.0/src/ChangedClass.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Drupal\updated_module;
-
-/**
- * This class will have a different value in updated_module 1.1.0.
- */
-class ChangedClass {
-
-  /**
-   * The value.
-   *
-   * @var string
-   */
-  public static $value = 'Before Update';
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.0.0/src/DeletedClass.php b/package_manager/tests/fixtures/updated_module/1.0.0/src/DeletedClass.php
deleted file mode 100644
index e638683ba8..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.0.0/src/DeletedClass.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Drupal\updated_module;
-
-/**
- * This class is removed from updated_module 1.1.0.
- */
-class DeletedClass {
-
-  /**
-   * The value.
-   *
-   * @var string
-   */
-  public static $value = 'This class will be deleted';
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.0.0/src/LoadedAndDeletedClass.php b/package_manager/tests/fixtures/updated_module/1.0.0/src/LoadedAndDeletedClass.php
deleted file mode 100644
index 6dd93dd98b..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.0.0/src/LoadedAndDeletedClass.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Drupal\updated_module;
-
-/**
- * This class is loaded in updated_module 1.0.0 and removed in 1.1.0.
- */
-class LoadedAndDeletedClass {
-
-  /**
-   * The value.
-   *
-   * @var string
-   */
-  public static $value = 'This class will be loaded and then deleted';
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/DeletedBlock.php b/package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/DeletedBlock.php
deleted file mode 100644
index e4c501b199..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/DeletedBlock.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-namespace Drupal\updated_module\Plugin\Block;
-
-use Drupal\Core\Block\BlockBase;
-
-/**
- * This block is removed from version 1.1.0 of this module.
- *
- * @Block(
- *   id = "updated_module_deleted_block",
- *   admin_label = @Translation("Deleted block"),
- * )
- */
-class DeletedBlock extends BlockBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function build() {
-    return [
-      '#markup' => $this->t('Goodbye!'),
-    ];
-  }
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/IgnoredBlock.php b/package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/IgnoredBlock.php
deleted file mode 100644
index ce7682274a..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/IgnoredBlock.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace Drupal\updated_module\Plugin\Block;
-
-use Drupal\Core\Block\BlockBase;
-
-/**
- * Defines a block plugin to test plugin reloading during an update.
- *
- * This block should NOT be loaded before updating to version 1.1.0 of this
- * module.
- *
- * @Block(
- *   id = "updated_module_ignored_block",
- *   admin_label = @Translation("1.0.0")
- * )
- */
-class IgnoredBlock extends BlockBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function build() {
-    return [
-      '#markup' => $this->t("I should not be instantiated before the update."),
-    ];
-  }
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/UpdatedBlock.php b/package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/UpdatedBlock.php
deleted file mode 100644
index 4ac05fbc58..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.0.0/src/Plugin/Block/UpdatedBlock.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace Drupal\updated_module\Plugin\Block;
-
-use Drupal\Core\Block\BlockBase;
-
-/**
- * Defines a block plugin to test plugin reloading during an update.
- *
- * In version 1.1.0 of this module, this block exists but its plugin definition
- * and implementation are different.
- *
- * @Block(
- *   id = "updated_module_updated_block",
- *   admin_label = @Translation("1.0.0")
- * )
- */
-class UpdatedBlock extends BlockBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function build() {
-    return [
-      '#markup' => $this->t('1.0.0'),
-    ];
-  }
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.module b/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.module
index 9515fa7c3c..0f90596c5f 100644
--- a/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.module
+++ b/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.module
@@ -16,12 +16,3 @@ function updated_module_hello(): array {
     '#markup' => 'Hello!',
   ];
 }
-
-/**
- * A test function to test if global functions are reloaded during an update.
- *
- * @return string
- */
-function _updated_module_global1(): string {
-  return "pre-update-value";
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.permissions.yml b/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.permissions.yml
deleted file mode 100644
index c0236005ef..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.permissions.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-changed permission:
-  title: 'permission'
-deleted permission:
-  title: 'deleted permission'
diff --git a/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.routing.yml b/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.routing.yml
deleted file mode 100644
index 03a269bb83..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.routing.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-updated_module.changed:
-  path: '/updated-module/changed/pre'
-  defaults:
-    _controller: 'updated_module_hello'
-  requirements:
-    _access: 'TRUE'
-updated_module.deleted:
-  path: '/updated-module/deleted'
-  defaults:
-    _controller: 'updated_module_hello'
-  requirements:
-    _access: 'TRUE'
diff --git a/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.services.yml b/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.services.yml
deleted file mode 100644
index 9eb7adf2b4..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.0.0/updated_module.services.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-services:
-  updated_module.existing_service:
-    class: stdClass
-    properties:
-      value: 'Pre-update value'
-  updated_module.deleted_service:
-    class: stdClass
-    properties:
-      value: 'Deleted service, should not exist after update'
diff --git a/package_manager/tests/fixtures/updated_module/1.1.0/src/AddedClass.php b/package_manager/tests/fixtures/updated_module/1.1.0/src/AddedClass.php
deleted file mode 100644
index ad8c441bd9..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.1.0/src/AddedClass.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Drupal\updated_module;
-
-/**
- * This class only exists in updated_module 1.1.0.
- */
-class AddedClass {
-
-  /**
-   * The value.
-   *
-   * @var string
-   */
-  public static $value = 'This class will be added';
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.1.0/src/ChangedClass.php b/package_manager/tests/fixtures/updated_module/1.1.0/src/ChangedClass.php
deleted file mode 100644
index 2bf7ca010c..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.1.0/src/ChangedClass.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Drupal\updated_module;
-
-/**
- * This class exists in updated_module 1.0.0, but with a different value.
- */
-class ChangedClass {
-
-  /**
-   * The value.
-   *
-   * @var string
-   */
-  public static $value = 'After Update';
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/AddedBlock.php b/package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/AddedBlock.php
deleted file mode 100644
index fd41ce3468..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/AddedBlock.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-namespace Drupal\updated_module\Plugin\Block;
-
-use Drupal\Core\Block\BlockBase;
-
-/**
- * This block doesn't exist in version 1.0.0 of this module.
- *
- * @Block(
- *   id = "updated_module_added_block",
- *   admin_label = @Translation("Added block"),
- * )
- */
-class AddedBlock extends BlockBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function build() {
-    return [
-      '#markup' => $this->t('Hello!'),
-    ];
-  }
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/IgnoredBlock.php b/package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/IgnoredBlock.php
deleted file mode 100644
index db675ccf76..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/IgnoredBlock.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace Drupal\updated_module\Plugin\Block;
-
-use Drupal\Core\Block\BlockBase;
-
-/**
- * Defines a block plugin to test plugin reloading during an update.
- *
- * This block should only be loaded and built after updating to version 1.1.0 of
- * this module.
- *
- * @Block(
- *   id = "updated_module_ignored_block",
- *   admin_label = @Translation("1.1.0")
- * )
- */
-class IgnoredBlock extends BlockBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function build() {
-    return [
-      '#markup' => $this->t('I was ignored before the update.'),
-    ];
-  }
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/UpdatedBlock.php b/package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/UpdatedBlock.php
deleted file mode 100644
index fb014cb33b..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.1.0/src/Plugin/Block/UpdatedBlock.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace Drupal\updated_module\Plugin\Block;
-
-use Drupal\Core\Block\BlockBase;
-
-/**
- * Defines a block plugin to test plugin reloading during an update.
- *
- * In version 1.0.0 of this module, this block exists but its plugin definition
- * and implementation are different.
- *
- * @Block(
- *   id = "updated_module_updated_block",
- *   admin_label = @Translation("1.1.0")
- * )
- */
-class UpdatedBlock extends BlockBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function build() {
-    return [
-      '#markup' => $this->t('1.1.0'),
-    ];
-  }
-
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.module b/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.module
index 0c3da89a0d..0f90596c5f 100644
--- a/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.module
+++ b/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.module
@@ -16,18 +16,3 @@ function updated_module_hello(): array {
     '#markup' => 'Hello!',
   ];
 }
-
-/**
- * A test function to test if global functions are reloaded during an update.
- *
- * @return string
- */
-function _updated_module_global1(): string {
-  return "post-update-value";
-}
-
-/**
- * A test function to test if a new global function will be available after an update.
- */
-function _updated_module_global2(): void {
-}
diff --git a/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.permissions.yml b/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.permissions.yml
deleted file mode 100644
index 926a17a412..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.permissions.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-changed permission:
-  title: 'changed permission'
-added permission:
-  title: 'added permission'
diff --git a/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.routing.yml b/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.routing.yml
deleted file mode 100644
index 525acd210c..0000000000
--- a/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.routing.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-updated_module.changed:
-  path: '/updated-module/changed/post'
-  defaults:
-    _controller: 'updated_module_hello'
-  requirements:
-    _access: 'TRUE'
-updated_module.added:
-  path: '/updated-module/added'
-  defaults:
-    _controller: 'updated_module_hello'
-  requirements:
-    _access: 'TRUE'
diff --git a/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.services.yml b/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.services.yml
index fea0247fe2..1179d2fb06 100644
--- a/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.services.yml
+++ b/package_manager/tests/fixtures/updated_module/1.1.0/updated_module.services.yml
@@ -1,12 +1,4 @@
 services:
-  updated_module.existing_service:
-    class: stdClass
-    properties:
-      value: 'Post-update value'
-  updated_module.added_service:
-    class: stdClass
-    properties:
-      value: 'New service, should not exist before update'
   updated_module.post_apply_subscriber:
     class: Drupal\updated_module\PostApplySubscriber
     arguments:
diff --git a/package_manager/tests/modules/package_manager_test_api/package_manager_test_api.services.yml b/package_manager/tests/modules/package_manager_test_api/package_manager_test_api.services.yml
deleted file mode 100644
index 257393c899..0000000000
--- a/package_manager/tests/modules/package_manager_test_api/package_manager_test_api.services.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-services:
-  package_manager_test_api.system_change_recorder:
-    class: Drupal\package_manager_test_api\SystemChangeRecorder
-    arguments:
-      - '@package_manager.path_locator'
-      - '@state'
-      - '@router.no_access_checks'
-      - '@user.permissions'
-      - '@plugin.manager.block'
-    tags:
-      - { name: event_subscriber }
diff --git a/package_manager/tests/modules/package_manager_test_api/src/SystemChangeRecorder.php b/package_manager/tests/modules/package_manager_test_api/src/SystemChangeRecorder.php
deleted file mode 100644
index 7944040ce6..0000000000
--- a/package_manager/tests/modules/package_manager_test_api/src/SystemChangeRecorder.php
+++ /dev/null
@@ -1,243 +0,0 @@
-<?php
-
-namespace Drupal\package_manager_test_api;
-
-use Drupal\Core\Block\BlockManagerInterface;
-use Drupal\Core\State\StateInterface;
-use Drupal\package_manager\Event\PostApplyEvent;
-use Drupal\package_manager\Event\PostDestroyEvent;
-use Drupal\package_manager\Event\PreApplyEvent;
-use Drupal\package_manager\Event\StageEvent;
-use Drupal\package_manager\PathLocator;
-use Drupal\user\PermissionHandlerInterface;
-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-use Symfony\Component\Routing\RouterInterface;
-
-/**
- * Defines a service for checking system changes during an update.
- */
-class SystemChangeRecorder implements EventSubscriberInterface {
-
-  /**
-   * The path locator service.
-   *
-   * @var \Drupal\package_manager\PathLocator
-   */
-  private $pathLocator;
-
-  /**
-   * The state service.
-   *
-   * @var \Drupal\Core\State\StateInterface
-   */
-  private $state;
-
-  /**
-   * The router service.
-   *
-   * @var \Symfony\Component\Routing\RouterInterface
-   */
-  private $router;
-
-  /**
-   * The permission handler service.
-   *
-   * @var \Drupal\user\PermissionHandlerInterface
-   */
-  private $permissionHandler;
-
-  /**
-   * The block plugin manager.
-   *
-   * @var \Drupal\Core\Block\BlockManagerInterface
-   */
-  private $blockManager;
-
-  /**
-   * Constructs a SystemChangeRecorder object.
-   *
-   * @param \Drupal\package_manager\PathLocator $path_locator
-   *   The path locator service.
-   * @param \Drupal\Core\State\StateInterface $state
-   *   The state service.
-   * @param \Symfony\Component\Routing\RouterInterface $router
-   *   The router service.
-   * @param \Drupal\user\PermissionHandlerInterface $permission_handler
-   *   The permission handler service.
-   * @param \Drupal\Core\Block\BlockManagerInterface $block_manager
-   *   The block plugin manager.
-   */
-  public function __construct(PathLocator $path_locator, StateInterface $state, RouterInterface $router, PermissionHandlerInterface $permission_handler, BlockManagerInterface $block_manager) {
-    $this->pathLocator = $path_locator;
-    $this->state = $state;
-    $this->router = $router;
-    $this->permissionHandler = $permission_handler;
-    $this->blockManager = $block_manager;
-  }
-
-  /**
-   * Records aspects of system state at various points during an update.
-   *
-   * @param \Drupal\package_manager\Event\StageEvent $event
-   *   The stage event.
-   */
-  public function recordSystemState(StageEvent $event): void {
-    // The rest of this method is strongly coupled to updated_module, so if it
-    // isn't installed, bail out now.
-    if (!\Drupal::moduleHandler()->moduleExists('updated_module')) {
-      return;
-    }
-
-    $results = [];
-
-    // Call a function in a loaded file to ensure it doesn't get reloaded after
-    // changes are applied.
-    $results['return value of existing global function'] = _updated_module_global1();
-
-    // Check if a new global function exists after changes are applied.
-    $results['new global function exists'] = function_exists('_updated_module_global2') ? "exists" : "not exists";
-
-    $route_collection = $this->router->getRouteCollection();
-    // Check if changes to an existing route are picked up.
-    $results['path of changed route'] = $route_collection->get('updated_module.changed')
-      ->getPath();
-    // Check if a route removed from the updated module is no longer available.
-    $results['deleted route exists'] = $route_collection->get('updated_module.deleted') ? 'exists' : 'not exists';
-    // Check if a route added in the updated module is available.
-    $results['new route exists'] = $route_collection->get('updated_module.added') ? 'exists' : 'not exists';
-
-    $permissions = $this->permissionHandler->getPermissions();
-    // Check if changes to an existing permission are picked up.
-    $results['title of changed permission'] = $permissions['changed permission']['title'];
-    // Check if a permission removed from the updated module is not available.
-    $results['deleted permission exists'] = array_key_exists('deleted permission', $permissions) ? 'exists' : 'not exists';
-    // Check if a permission added in the updated module is available.
-    $results['new permission exists'] = array_key_exists('added permission', $permissions) ? 'exists' : 'not exists';
-
-    // Check if changes to an existing service are picked up.
-    $this->recordServiceValue('updated_module.existing_service', $results);
-    // Check if a service removed from the updated module is available.
-    $this->recordServiceValue('updated_module.deleted_service', $results);
-    // Check if a service added in the updated module is available.
-    $this->recordServiceValue('updated_module.added_service', $results);
-
-    $phase = $event instanceof PreApplyEvent ? 'pre' : 'post';
-
-    // Check if changes to a block plugin's definition and implementation are
-    // picked up.
-    $this->recordBlockState('updated_module_deleted_block', $results, $phase === 'pre');
-    $this->recordBlockState('updated_module_updated_block', $results, TRUE);
-    $this->recordBlockState('updated_module_added_block', $results, $phase === 'post');
-    // Record the state of a block that was NOT instantiated before the update.
-    $this->recordBlockState('updated_module_ignored_block', $results, $phase === 'post');
-
-    // Check if changes to an existing class are picked up.
-    $this->recordClassValue('ChangedClass', $results);
-    // Check if changes to a class that has not been loaded before the update is
-    // applied, are picked up.
-    $this->recordClassValue('LoadedAndDeletedClass', $results);
-    // We can't check AddedClass and DeletedClass in the "pre" phase, because
-    // class_exists() uses auto-loading, so if we checked these classes in the
-    // "pre" phase, the results will persist into the "post" phase.
-    if ($phase === 'post') {
-      // Check if a class that was removed in the updated module is still
-      // loaded.
-      $this->recordClassValue('DeletedClass', $results);
-      // Check if a class that was added in the updated module is available.
-      $this->recordClassValue('AddedClass', $results);
-    }
-
-    $this->state->set("system_changes:$phase", $results);
-  }
-
-  /**
-   * Records the state of a block plugin.
-   *
-   * @param string $block_id
-   *   Tbe block plugin ID.
-   * @param array $results
-   *   The current set of results, passed by reference.
-   * @param bool $build
-   *   Whether or not to instantiate the block plugin and include its output
-   *   in the results.
-   */
-  private function recordBlockState(string $block_id, array &$results, bool $build): void {
-    if ($this->blockManager->hasDefinition($block_id)) {
-      $results["$block_id block exists"] = 'exists';
-      $plugin_definition = $this->blockManager->getDefinition($block_id);
-      $results["$block_id block label"] = (string) $plugin_definition['admin_label'];
-
-      if ($build) {
-        $build = $this->blockManager->createInstance($block_id)->build();
-        $results["$block_id block output"] = (string) $build['#markup'];
-      }
-    }
-    else {
-      $results["$block_id block exists"] = 'not exists';
-    }
-  }
-
-  /**
-   * Checks if a given class exists, and records its 'value' property.
-   *
-   * @param string $class_name
-   *   The name of the class to check, not including the namespace.
-   * @param array $results
-   *   The current set of results, passed by reference.
-   */
-  private function recordClassValue(string $class_name, array &$results): void {
-    $full_class_name = "Drupal\updated_module\\$class_name";
-    if (class_exists($full_class_name)) {
-      $results["$class_name exists"] = 'exists';
-      $results["value of $class_name"] = $full_class_name::$value;
-    }
-    else {
-      $results["$class_name exists"] = 'not exists';
-    }
-  }
-
-  /**
-   * Checks if a given service exists, and records its ->value property.
-   *
-   * @param string $service_id
-   *   The ID of the service to check.
-   * @param array $results
-   *   The current set of results, passed by reference.
-   */
-  private function recordServiceValue(string $service_id, array &$results): void {
-    if (\Drupal::hasService($service_id)) {
-      $results["$service_id exists"] = 'exists';
-      $results["value of $service_id"] = \Drupal::service($service_id)->value;
-    }
-    else {
-      $results["$service_id exists"] = 'not exists';
-    }
-  }
-
-  /**
-   * Writes the results of ::recordSystemState() to file.
-   *
-   * Build tests do not have access to the Drupal API, so write the results to
-   * a file so the build test can check them.
-   */
-  public function writeResultsToFile(): void {
-    $results = [
-      'pre' => $this->state->get('system_changes:pre'),
-      'post' => $this->state->get('system_changes:post'),
-    ];
-    $dir = $this->pathLocator->getProjectRoot();
-    file_put_contents("$dir/system_changes.json", json_encode($results));
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public static function getSubscribedEvents() {
-    return [
-      PreApplyEvent::class => 'recordSystemState',
-      PostApplyEvent::class => 'recordSystemState',
-      PostDestroyEvent::class => 'writeResultsToFile',
-    ];
-  }
-
-}
diff --git a/package_manager/tests/src/Build/PackageUpdateTest.php b/package_manager/tests/src/Build/PackageUpdateTest.php
index 336f51e8b1..6427cc943a 100644
--- a/package_manager/tests/src/Build/PackageUpdateTest.php
+++ b/package_manager/tests/src/Build/PackageUpdateTest.php
@@ -67,98 +67,6 @@ class PackageUpdateTest extends TemplateProjectTestBase {
     // created this file.
     // @see \Drupal\updated_module\PostApplySubscriber::postApply()
     $this->assertSame('Bravo!', $file_contents['bravo.txt']);
-
-    $results = json_decode($file_contents['system_changes.json'], TRUE);
-    $expected_pre_apply_results = [
-      'return value of existing global function' => 'pre-update-value',
-      'new global function exists' => 'not exists',
-      'path of changed route' => '/updated-module/changed/pre',
-      'deleted route exists' => 'exists',
-      'new route exists' => 'not exists',
-      'title of changed permission' => 'permission',
-      'deleted permission exists' => 'exists',
-      'new permission exists' => 'not exists',
-      'updated_module.existing_service exists' => 'exists',
-      'value of updated_module.existing_service' => 'Pre-update value',
-      'updated_module.deleted_service exists' => 'exists',
-      'value of updated_module.deleted_service' => 'Deleted service, should not exist after update',
-      'updated_module.added_service exists' => 'not exists',
-      'updated_module_deleted_block block exists' => 'exists',
-      'updated_module_deleted_block block label' => 'Deleted block',
-      'updated_module_deleted_block block output' => 'Goodbye!',
-      'updated_module_updated_block block exists' => 'exists',
-      'updated_module_updated_block block label' => '1.0.0',
-      'updated_module_updated_block block output' => '1.0.0',
-      'updated_module_added_block block exists' => 'not exists',
-      // This block is not instantiated until the update is done.
-      'updated_module_ignored_block block exists' => 'exists',
-      'updated_module_ignored_block block label' => '1.0.0',
-      'ChangedClass exists' => 'exists',
-      'value of ChangedClass' => 'Before Update',
-      'LoadedAndDeletedClass exists' => 'exists',
-      'value of LoadedAndDeletedClass' => 'This class will be loaded and then deleted',
-    ];
-    $this->assertSame($expected_pre_apply_results, $results['pre']);
-
-    $expected_post_apply_results = [
-      // An existing functions will now return a new value.
-      'return value of existing global function' => 'post-update-value',
-      // New functions that were added in .module files will be available
-      // because the post-apply event is dispatched in a new request.
-      'new global function exists' => 'exists',
-      // Definitions for existing routes should be updated.
-      'path of changed route' => '/updated-module/changed/post',
-      // Routes deleted from the updated module should not be available.
-      'deleted route exists' => 'not exists',
-      // Routes added to the updated module should be available.
-      'new route exists' => 'exists',
-      // Title of the existing permission should be changed.
-      'title of changed permission' => 'changed permission',
-      // Permissions deleted from the updated module should not be available.
-      'deleted permission exists' => 'not exists',
-      // Permissions added to the updated module should be available.
-      'new permission exists' => 'exists',
-      // The existing generic service should have a new string value.
-      'updated_module.existing_service exists' => 'exists',
-      'value of updated_module.existing_service' => 'Post-update value',
-      // Services deleted from the updated module should not be available.
-      'updated_module.deleted_service exists' => 'not exists',
-      // Services added to the updated module should be available and return
-      // the expected value.
-      'updated_module.added_service exists' => 'exists',
-      'value of updated_module.added_service' => 'New service, should not exist before update',
-      // A block removed from the updated module should not be defined anymore.
-      'updated_module_deleted_block block exists' => 'not exists',
-      // A block that was updated should have a changed definition and
-      // implementation.
-      'updated_module_updated_block block exists' => 'exists',
-      'updated_module_updated_block block label' => '1.1.0',
-      'updated_module_updated_block block output' => '1.1.0',
-      // A block added to the module should be defined.
-      'updated_module_added_block block exists' => 'exists',
-      'updated_module_added_block block label' => 'Added block',
-      'updated_module_added_block block output' => 'Hello!',
-      // A block whose definition and implementation were updated, but was NOT
-      // instantiated before the update, should have an updated definition and
-      // implementation.
-      'updated_module_ignored_block block exists' => 'exists',
-      'updated_module_ignored_block block label' => '1.1.0',
-      'updated_module_ignored_block block output' => 'I was ignored before the update.',
-      // Existing class should still be available, and will be outputting its
-      // new value.
-      'ChangedClass exists' => 'exists',
-      'value of ChangedClass' => 'After Update',
-      // Classes loaded in pre-apply, but deleted from the updated module,
-      // should be unavailable.
-      'LoadedAndDeletedClass exists' => 'not exists',
-      // Classes not loaded before the apply operation and deleted from the updated module
-      // should not be available.
-      'DeletedClass exists' => 'not exists',
-      // Classes added to the updated module should be available.
-      'AddedClass exists' => 'exists',
-      'value of AddedClass' => 'This class will be added',
-    ];
-    $this->assertSame($expected_post_apply_results, $results['post']);
   }
 
 }
-- 
GitLab