33namespace Drupal \Tests \block \Functional ;
44
55use Drupal \Component \Utility \Html ;
6+ use Drupal \language \Entity \ConfigurableLanguage ;
7+ use Drupal \language \Plugin \LanguageNegotiation \LanguageNegotiationUrl ;
68use Drupal \Tests \BrowserTestBase ;
79
810/**
@@ -288,6 +290,24 @@ public function testMachineNameSuggestion() {
288290 * Tests the block placement indicator.
289291 */
290292 public function testBlockPlacementIndicator () {
293+ // Test the block placement indicator with using the domain as URL language
294+ // indicator. This causes destination query parameters to be absolute URLs.
295+ \Drupal::service ('module_installer ' )->install (['language ' , 'locale ' ]);
296+ $ this ->container = \Drupal::getContainer ();
297+ ConfigurableLanguage::createFromLangcode ('it ' )->save ();
298+ $ config = $ this ->config ('language.types ' );
299+ $ config ->set ('negotiation.language_interface.enabled ' , [
300+ LanguageNegotiationUrl::METHOD_ID => -10 ,
301+ ]);
302+ $ config ->save ();
303+ $ config = $ this ->config ('language.negotiation ' );
304+ $ config ->set ('url.source ' , LanguageNegotiationUrl::CONFIG_DOMAIN );
305+ $ config ->set ('url.domains ' , [
306+ 'en ' => \Drupal::request ()->getHost (),
307+ 'it ' => 'it.example.com ' ,
308+ ]);
309+ $ config ->save ();
310+
291311 // Select the 'Powered by Drupal' block to be placed.
292312 $ block = [];
293313 $ block ['id ' ] = strtolower ($ this ->randomMachineName ());
@@ -296,11 +316,30 @@ public function testBlockPlacementIndicator() {
296316
297317 // After adding a block, it will indicate which block was just added.
298318 $ this ->drupalPostForm ('admin/structure/block/add/system_powered_by_block ' , $ block , t ('Save block ' ));
299- $ this ->assertUrl ('admin/structure/block/list/classy?block-placement= ' . Html::getClass ($ block ['id ' ]));
319+ $ this ->assertSession ()-> addressEquals ('admin/structure/block/list/classy?block-placement= ' . Html::getClass ($ block ['id ' ]));
300320
301- // Resaving the block page will remove the block indicator.
321+ // Resaving the block page will remove the block placement indicator.
302322 $ this ->drupalPostForm (NULL , [], t ('Save blocks ' ));
303- $ this ->assertUrl ('admin/structure/block/list/classy ' );
323+ $ this ->assertSession ()->addressEquals ('admin/structure/block/list/classy ' );
324+
325+ // Place another block and test the remove functionality works with the
326+ // block placement indicator. Click the first 'Place block' link to bring up
327+ // the list of blocks to place in the first available region.
328+ $ this ->clickLink ('Place block ' );
329+ // Select the first available block.
330+ $ this ->clickLink ('Place block ' );
331+ $ block = [];
332+ $ block ['id ' ] = strtolower ($ this ->randomMachineName ());
333+ $ block ['theme ' ] = 'classy ' ;
334+ $ this ->submitForm ([], 'Save block ' );
335+ $ this ->assertSession ()->addressEquals ('admin/structure/block/list/classy?block-placement= ' . Html::getClass ($ block ['id ' ]));
336+
337+ // Removing a block will remove the block placement indicator.
338+ $ this ->clickLink ('Remove ' );
339+ $ this ->submitForm ([], 'Remove ' );
340+ // @todo https://www.drupal.org/project/drupal/issues/2980527 this should be
341+ // 'admin/structure/block/list/classy' but there is a bug.
342+ $ this ->assertSession ()->addressEquals ('admin/structure/block ' );
304343 }
305344
306345 /**
0 commit comments