MigrateBlockTest.php in Style Switcher 8.2        
                          
                  
                        
  
  
  
  
File
  tests/src/Kernel/Migrate/d7/MigrateBlockTest.php
  
    View source  
  <?php
namespace Drupal\Tests\styleswitcher\Kernel\Migrate\d7;
use Drupal\block\Entity\Block;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
class MigrateBlockTest extends MigrateDrupal7TestBase {
  
  public static $modules = [
    'styleswitcher',
    'block',
  ];
  
  protected function setUp() {
    parent::setUp();
    $this
      ->loadFixture(__DIR__ . '/../../../../fixtures/migrate/drupal7.styleswitcher.php');
    
    $this->container
      ->get('theme_installer')
      ->install([
      'bartik',
      'seven',
    ]);
    $this
      ->installConfig(static::$modules);
    
    $config = $this
      ->config('system.theme');
    $config
      ->set('default', 'bartik');
    $config
      ->set('admin', 'seven');
    $config
      ->save();
    $this
      ->executeMigrations([
      'd7_styleswitcher_block',
    ]);
    block_rebuild();
  }
  
  public function testBlockMigration() {
    $block = Block::load('bartik_styleswitcher_styleswitcher');
    $this
      ->assertTrue($block instanceof Block);
    
    $this
      ->assertSame('styleswitcher_styleswitcher', $block
      ->getPluginId());
    $this
      ->assertSame('sidebar_first', $block
      ->getRegion());
    $this
      ->assertSame('bartik', $block
      ->getTheme());
    $this
      ->assertSame(TRUE, $block
      ->status());
    $config = $this
      ->config('block.block.bartik_styleswitcher_styleswitcher');
    $this
      ->assertSame('Switch Styles', $config
      ->get('settings.label'));
    $this
      ->assertSame('visible', $config
      ->get('settings.label_display'));
    
    $non_existent_blocks = [
      'seven_styleswitcher_styleswitcher',
    ];
    $this
      ->assertTrue(empty(Block::loadMultiple($non_existent_blocks)));
  }
}
 
Classes
        
  
  
      
      
         
      
                  | Name   | Description | 
    
    
          
                  | MigrateBlockTest | Tests migration of the Style Switcher block to a configuration entity. |