ConfigInstallerSyncTest.php in Configuration installer 8        
                          
                  
                        
  
  
  
  
  
File
  tests/src/Functional/ConfigInstallerSyncTest.php
  
    View source  
  <?php
namespace Drupal\Tests\config_installer\Functional;
use Drupal\Core\Config\FileStorage;
class ConfigInstallerSyncTest extends ConfigInstallerTestBase {
  
  protected $syncDir;
  
  protected function setUp() {
    $this->syncDir = 'public://' . $this
      ->randomMachineName(128);
    parent::setUp();
  }
  
  public function testInstaller() {
    
    parent::testInstaller();
    
    $this
      ->assertEqual(drupal_realpath($this->syncDir), config_get_config_directory(CONFIG_SYNC_DIRECTORY), 'The sync directory has been updated during the installation.');
    $this
      ->assertEqual(USER_REGISTER_ADMINISTRATORS_ONLY, \Drupal::config('user.settings')
      ->get('register'), 'Ensure standard_install() does not overwrite user.settings::register.');
    $this
      ->assertEqual([], \Drupal::entityDefinitionUpdateManager()
      ->getChangeSummary(), 'There are no entity or field definition updates.');
  }
  
  protected function setUpSyncForm() {
    
    drupal_mkdir($this->syncDir);
    
    $this
      ->extractTarball($this
      ->getTarball(), $this->syncDir);
    
    $sync = new FileStorage($this->syncDir);
    $user_settings = $sync
      ->read('user.settings');
    $user_settings['register'] = USER_REGISTER_ADMINISTRATORS_ONLY;
    $sync
      ->write('user.settings', $user_settings);
    
    $sync
      ->write('foo.bar', []);
    $this
      ->drupalPostForm(NULL, [
      'sync_directory' => drupal_realpath($this->syncDir),
    ], 'Save and continue');
    $this
      ->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
    $this
      ->assertText('Configuration foo.bar depends on the foo extension that will not be installed after import.');
    
    $sync
      ->delete('foo.bar');
    $this
      ->drupalPostForm(NULL, [
      'sync_directory' => drupal_realpath($this->syncDir),
    ], 'Save and continue');
  }
}