InstallerRouterTest.php in Drupal 9        
                          
                  
                        
  
  
  
  
File
  core/tests/Drupal/FunctionalTests/Installer/InstallerRouterTest.php
  
    View source  
  <?php
namespace Drupal\FunctionalTests\Installer;
use Drupal\Core\Routing\RoutingEvents;
use Drupal\Core\Serialization\Yaml;
use Drupal\Core\Test\PerformanceTestRecorder;
class InstallerRouterTest extends InstallerTestBase {
  
  protected $profile = 'test_profile';
  
  protected $defaultTheme = 'stark';
  
  protected function prepareEnvironment() {
    parent::prepareEnvironment();
    $info = [
      'type' => 'profile',
      'core_version_requirement' => '*',
      'name' => 'Router testing profile',
      'install' => [
        'router_test',
        'router_installer_test',
      ],
    ];
    
    $path = $this->siteDirectory . '/profiles/test_profile';
    mkdir($path, 0777, TRUE);
    file_put_contents("{$path}/test_profile.info.yml", Yaml::encode($info));
    $settings_services_file = DRUPAL_ROOT . '/sites/default/default.services.yml';
    copy($settings_services_file, $this->siteDirectory . '/services.yml');
    PerformanceTestRecorder::registerService($this->siteDirectory . '/services.yml', TRUE);
  }
  
  public function testInstalled() {
    $this
      ->assertSession()
      ->statusCodeEquals(200);
    
    $this
      ->assertSame(3, \Drupal::service('core.performance.test.recorder')
      ->getCount('event', RoutingEvents::FINISHED));
    $this
      ->assertStringEndsWith('/core/install.php/router_installer_test/test1', \Drupal::state()
      ->get('router_installer_test_modules_installed'));
    $this
      ->assertStringEndsWith('/core/install.php/router_test/test1', \Drupal::state()
      ->get('router_test_install'));
  }
}