How to use contains method of child class

Best Atoum code snippet using child.contains

CompileBlockExtendsTests.php

Source:CompileBlockExtendsTests.php Github

copy

Full Screen

1<?php2/**3* Smarty PHPunit tests for Block Extends4*5* @package PHPunit6* @author Uwe Tews7*/8/**9* class for block extends compiler tests10*/11class CompileBlockExtendsTests extends PHPUnit_Framework_TestCase12{13 public function setUp()14 {15 $this->smarty = SmartyTests::$smarty;16 SmartyTests::init();17 $this->smarty->setTemplateDir(array('./templates/compileblockextends/','./templates/'));18 }19 static function isRunnable()20 {21 return true;22 }23 /**24 * clear folders25 */26 public function clear()27 {28 $this->smarty->clearAllCache();29 $this->smarty->clearCompiledTemplate();30 }31 /**32 * test block default outout33 */34 public function testBlockDefault_000_1()35 {36 $result = $this->smarty->fetch('eval:{block name=test}-- block default --{/block}');37 $this->assertEquals('-- block default --', $result);38 }39 public function testBlockDefault_000_2()40 {41 $this->smarty->assign ('foo', 'another');42 $result = $this->smarty->fetch('eval:{block name=test}-- {$foo} block default --{/block}');43 $this->assertEquals('-- another block default --', $result);44 }45 /**46 * test just call of parent template, no blocks predefined47 */48 public function testCompileBlockParent_001()49 {50 $result = $this->smarty->fetch('001_parent.tpl');51 $this->assertContains('Default Title', $result);52 }53 /**54 * test child/parent template chain55 */56 public function testCompileBlockChild_002()57 {58 $result = $this->smarty->fetch('002_child.tpl');59 $this->assertContains('Page Title', $result);60 }61 /**62 * test child/parent template chain with prepend63 */64 public function testCompileBlockChildPrepend_003()65 {66 $result = $this->smarty->fetch('003_child_prepend.tpl');67 $this->assertContains("prepend - Default Title", $result);68 }69 /**70 * test child/parent template chain with apppend71 */72 public function testCompileBlockChildAppend_004()73 {74 $result = $this->smarty->fetch('004_child_append.tpl');75 $this->assertContains("Default Title - append", $result);76 }77 /**78 * test child/parent template chain with apppend and shorttags79 */80 public function testCompileBlockChildAppendShortag_005()81 {82 $result = $this->smarty->fetch('005_child_append_shorttag.tpl');83 $this->assertContains("Default Title - append", $result);84 }85 /**86 * test child/parent template chain with {$this->smarty.block.child)87 */88 public function testCompileBlockChildSmartyChild_006()89 {90 $result = $this->smarty->fetch('006_child_smartychild.tpl');91 $this->assertContains('here is >child text< included', $result);92 }93 /**94 * test child/parent template chain with {$this->smarty.block.parent)95 */96 public function testCompileBlockChildSmartyParent_007()97 {98 $result = $this->smarty->fetch('007_child_smartyparent.tpl');99 $this->assertContains('parent block Default Title is here', $result);100 }101 /**102 * test child/parent template chain loading plugin103 */104 public function testCompileBlockChildPlugin_008()105 {106 $result = $this->smarty->fetch('008_child_plugin.tpl');107 $this->assertContains('escaped &lt;text&gt;', $result);108 }109 /**110 * test parent template with nested blocks111 */112 public function testCompileBlockParentNested_009()113 {114 $result = $this->smarty->fetch('009_parent_nested.tpl');115 $this->assertContains('Title with -default- here', $result);116 }117 /**118 * test child/parent template chain with nested block119 */120 public function testCompileBlockChildNested_010()121 {122 $result = $this->smarty->fetch('010_child_nested.tpl');123 $this->assertContains('Title with -content from child- here', $result);124 }125 /**126 * test child/parent template chain with nested block and include127 */128 public function testCompileBlockChildNestedInclude_011()129 {130 $result = $this->smarty->fetch('011_grandchild_nested_include.tpl');131 $this->assertContains('hello world', $result);132 }133 /**134 * test grandchild/child/parent template chain135 */136 public function testCompileBlockGrandChild_012()137 {138 $result = $this->smarty->fetch('012_grandchild.tpl');139 $this->assertContains('Grandchild Page Title', $result);140 }141 /**142 * test grandchild/child/parent template chain prepend143 */144 public function testCompileBlockGrandChildPrepend_013()145 {146 $result = $this->smarty->fetch('013_grandchild_prepend.tpl');147 $this->assertContains('grandchild prepend - Page Title', $result);148 }149 /**150 * test grandchild/child/parent template chain with {$this->smarty.block.child}151 */152 public function testCompileBlockGrandChildSmartyChild_014()153 {154 $result = $this->smarty->fetch('014_grandchild_smartychild.tpl');155 $this->assertContains('child title with - grandchild content - here', $result);156 }157 /**158 * test grandchild/child/parent template chain append159 */160 public function testCompileBlockGrandChildAppend_015()161 {162 $result = $this->smarty->fetch('015_grandchild_append.tpl');163 $this->assertContains('Page Title - grandchild append', $result);164 }165 /**166 * test grandchild/child/parent template chain with nested block167 */168 public function testCompileBlockGrandChildNested_016()169 {170 $result = $this->smarty->fetch('016_grandchild_nested.tpl');171 $this->assertContains('child title with -grandchild content- here', $result);172 }173 /**174 * test grandchild/child/parent template chain with nested {$this->smarty.block.child}175 */176 public function testCompileBlockGrandChildNested_017()177 {178 $result = $this->smarty->fetch('017_grandchild_nested.tpl');179 $this->assertContains('child pre -grandchild content- child post', $result);180 }181 /**182 * test nested child block with hide183 */184 public function testCompileBlockChildNestedHide_018()185 {186 $result = $this->smarty->fetch('018_child_nested_hide.tpl');187 $this->assertContains('nested block', $result);188 $this->assertNotContains('should be hidden', $result);189 }190 /**191 * test nested child block with hide and auto_literal = false192 */193 public function testCompileBlockChildNestedHideAutoLiteralFalse_019()194 {195 $this->smarty->auto_literal = false;196 $result = $this->smarty->fetch('019_child_nested_hide_autoliteral.tpl');197 $this->assertContains('nested block', $result);198 $this->assertNotContains('should be hidden', $result);199 }200 /**201 * test child/parent template chain starting in subtempates202 */203 public function testCompileBlockStartSubTemplates_020()204 {205 $result = $this->smarty->fetch('020_include_root.tpl');206 $this->assertContains('page 1', $result);207 $this->assertContains('page 2', $result);208 $this->assertContains('page 3', $result);209 $this->assertContains('block 1', $result);210 $this->assertContains('block 2', $result);211 $this->assertContains('block 3', $result);212 }213 /**214 * test grandchild/child/parent dependency test1215 */216 public function testCompileBlockGrandChildMustCompile_021_1()217 {218 $this->smarty->caching = true;219 $this->smarty->cache_lifetime = 1000;220 $tpl = $this->smarty->createTemplate('021_grandchild.tpl');221 $this->assertFalse($tpl->isCached());222 $result = $this->smarty->fetch($tpl);223 $this->assertContains('Grandchild Page Title', $result);224 $this->smarty->template_objects = null;225 $tpl2 = $this->smarty->createTemplate('021_grandchild.tpl');226 $this->assertTrue($tpl2->isCached());227 $result = $this->smarty->fetch($tpl2);228 $this->assertContains('Grandchild Page Title', $result);229 }230 /**231 * test grandchild/child/parent dependency test2232 */233 public function testCompileBlockGrandChildMustCompile_021_2()234 {235 touch($this->smarty->getTemplateDir(0) . '021_grandchild.tpl');236 $this->smarty->caching = true;237 $this->smarty->cache_lifetime = 1000;238 $tpl = $this->smarty->createTemplate('021_grandchild.tpl');239 $this->assertFalse($tpl->isCached());240 $result = $this->smarty->fetch($tpl);241 $this->assertContains('Grandchild Page Title', $result);242 $this->smarty->template_objects = null;243 $tpl2 = $this->smarty->createTemplate('021_grandchild.tpl');244 $this->assertTrue($tpl2->isCached());245 $result = $this->smarty->fetch($tpl2);246 $this->assertContains('Grandchild Page Title', $result);247 }248 /**249 * test grandchild/child/parent dependency test3250 */251 public function testCompileBlockGrandChildMustCompile_021_3()252 {253 touch($this->smarty->getTemplateDir(0) . '021_child.tpl');254 $this->smarty->caching = true;255 $this->smarty->cache_lifetime = 1000;256 $tpl = $this->smarty->createTemplate('021_grandchild.tpl');257 $this->assertFalse($tpl->isCached());258 $result = $this->smarty->fetch($tpl);259 $this->assertContains('Grandchild Page Title', $result);260 $this->smarty->template_objects = null;261 $tpl2 = $this->smarty->createTemplate('021_grandchild.tpl');262 $this->assertTrue($tpl2->isCached());263 $result = $this->smarty->fetch($tpl2);264 $this->assertContains('Grandchild Page Title', $result);265 }266 /**267 * test grandchild/child/parent dependency test4268 */269 public function testCompileBlockGrandChildMustCompile_021_4()270 {271 touch($this->smarty->getTemplateDir(0) . '021_parent.tpl');272 $this->smarty->caching = true;273 $this->smarty->cache_lifetime = 1000;274 $tpl = $this->smarty->createTemplate('021_grandchild.tpl');275 $this->assertFalse($tpl->isCached());276 $result = $this->smarty->fetch($tpl);277 $this->assertContains('Grandchild Page Title', $result);278 $this->smarty->template_objects = null;279 $tpl2 = $this->smarty->createTemplate('021_grandchild.tpl');280 $this->assertTrue($tpl2->isCached());281 $result = $this->smarty->fetch($tpl2);282 $this->assertContains('Grandchild Page Title', $result);283 }284 /**285 * test dirt in child templates286 */287 public function testDirt_022()288 {289 $result = $this->smarty->fetch('022_child.tpl');290 $this->assertEquals('Page Title', $result);291 }292 /**293 * test {strip} outside {block]294 */295 public function testChildStrip_023()296 {297 $result = $this->smarty->fetch('023_child.tpl');298 $this->assertContains('<div id="header"><div>Demo</div></div>', $result);299 }300 /**301 * test {$this->smarty.block.child} for not existing child {block]302 */303 public function testNotExistingChildBlock_024()304 {305 $result = $this->smarty->fetch('024_parent.tpl');306 $this->assertContains('no >< child', $result);307 }308 /**309 * test {$this->smarty.block.child} outside {block]310 */311 public function testSmartyBlockChildOutsideBlock_025()312 {313 try {314 $result = $this->smarty->fetch('025_parent.tpl');315 } catch (Exception $e) {316 $this->assertContains('used outside', $e->getMessage());317 return;318 }319 $this->fail('Exception for {$this->smarty.block.child} used outside {block} has not been raised.');320 }321 /**322 * test {$this->smarty.block.parent} outside {block]323 */324 public function testSmartyBlockParentOutsideBlock_026()325 {326 try {327 $result = $this->smarty->fetch('026_parent.tpl');328 } catch (Exception $e) {329 $this->assertContains('used outside', $e->getMessage());330 return;331 }332 $this->fail('Exception for {$this->smarty.block.parent} used outside {block} has not been raised.');333 }334 /**335 * test {$this->smarty.block.parent} in parent template336 */337 public function testSmartyBlockParentInParent_027()338 {339 try {340 $result = $this->smarty->fetch('027_parent.tpl');341 } catch (Exception $e) {342 $this->assertContains('in parent template', $e->getMessage());343 return;344 }345 $this->fail('Exception for illegal {$this->smarty.block.parent} in parent template has not been raised.');346 }347 /**348 * test variable file name in {extends}349 */350 public function testVariableExtends_028()351 {352 $this->smarty->assign('foo','028_parent.tpl');353 try {354 $result = $this->smarty->fetch('028_child.tpl');355 } catch (Exception $e) {356 $this->assertContains('variable template file name not allowed', $e->getMessage());357 return;358 }359 $this->fail('Exception for illegal variable template file name not been raised.');360 }361 /**362 * test variable file name in {include}363 */364 public function testVariableExtends_029()365 {366 $this->smarty->assign('foo','helloworld.tpl');367 try {368 $result = $this->smarty->fetch('029_parent.tpl');369 } catch (Exception $e) {370 $this->assertContains('variable template file names not allow within {block} tags', $e->getMessage());371 return;372 }373 $this->fail('Exception for illegal variable template file name not been raised.');374 }375 /**376 * test nocache on different levels377 */378 public function testNocacheBlock_030_1()379 {380 $this->smarty->caching = 1;381 $this->smarty->assign('b1','b1_1');382 $this->smarty->assign('b3','b3_1');383 $this->smarty->assign('b4','b4_1');384 $this->smarty->assign('b5','b5_1');385 $this->smarty->assign('b6','b6_1');386 $result = $this->smarty->fetch('030_grandchild.tpl');387 $this->assertContains('parent b1 b1_1*parent b2*grandchild b3 b3_1*include b3 b6_1*grandchild b6 b6_1*', $result);388 $this->assertContains('child b4 b4_1*grandchild b4 b4_1**', $result);389 $this->assertContains('child b5 b5_1*grandchild b5 b5_1**', $result);390 $this->assertContains('child b61 b6_1*include 61 b6_1*grandchild b6 b6_1*', $result);391 $this->assertContains('child b62 b6_1*include 62 b6_1*grandchild b6 b6_1*', $result);392 $this->assertContains('child b63 b6_1*grandchild b6 b6_1*', $result);393 $this->assertContains('child b64 b6_1*include b64 b6_1*grandchild b6 b6_1*', $result);394 $this->assertContains('parent include b6_1*grandchild b6 b6_1*', $result);395 $this->assertContains('parent include2 grandchild b6 b6_1*', $result);396 }397 /**398 * test nocache on different levels399 */400 public function testNocacheBlock_030_2()401 {402 $this->smarty->caching = 1;403 $this->smarty->assign('b1','b1_2');404 $this->smarty->assign('b3','b3_2');405 $this->smarty->assign('b4','b4_2');406 $this->smarty->assign('b5','b5_2');407 $this->smarty->assign('b6','b6_2');408 $result = $this->smarty->fetch('030_grandchild.tpl');409 $this->assertContains('parent b1 b1_2*parent b2*grandchild b3 b3_2*include b3 b6_2*grandchild b6 b6_2*', $result);410 $this->assertContains('child b4 b4_1*grandchild b4 b4_2**', $result);411 $this->assertContains('child b5 b5_2*grandchild b5 b5_2**', $result);412 $this->assertContains('child b61 b6_1*include 61 b6_1*grandchild b6 b6_1*', $result);413 $this->assertContains('child b62 b6_2*include 62 b6_2*grandchild b6 b6_2*', $result);414 $this->assertContains('child b63 b6_1*grandchild b6 b6_2*', $result);415 $this->assertContains('child b64 b6_1*include b64 b6_2*grandchild b6 b6_2*', $result);416 $this->assertContains('parent include b6_2*grandchild b6 b6_2*', $result);417 $this->assertContains('parent include2 grandchild b6 b6_2*', $result);418 }419}...

Full Screen

Full Screen

MenuBlockTest.php

Source:MenuBlockTest.php Github

copy

Full Screen

1<?php2namespace Drupal\Tests\menu_block\Functional;3use Drupal\Tests\BrowserTestBase;4/**5 * Tests for the menu_block module.6 *7 * @group menu_block8 */9class MenuBlockTest extends BrowserTestBase {10 /**11 * {@inheritdoc}12 */13 public static $modules = [14 'block',15 'menu_block',16 'menu_block_test',17 ];18 /**19 * {@inheritdoc}20 */21 protected $defaultTheme = 'stark';22 /**23 * An administrative user to configure the test environment.24 *25 * @var \Drupal\user\Entity\User|false26 */27 protected $adminUser;28 /**29 * The menu link plugin manager.30 *31 * @var \Drupal\Core\Menu\MenuLinkManagerInterface32 */33 protected $menuLinkManager;34 /**35 * The block storage.36 *37 * @var \Drupal\Core\Entity\EntityStorageInterface38 */39 protected $blockStorage;40 /**41 * The block view builder.42 *43 * @var \Drupal\Core\Entity\EntityViewBuilderInterface44 */45 protected $blockViewBuilder;46 /**47 * The menu link content storage.48 *49 * @var \Drupal\Core\Entity\EntityStorageInterface50 */51 protected $menuLinkContentStorage;52 /**53 * The module handler service.54 *55 * @var \Drupal\Core\Extension\ModuleHandlerInterface56 */57 protected $moduleHandler;58 /**59 * An array containing the menu link plugin ids.60 *61 * @var array62 */63 protected $links;64 /**65 * {@inheritdoc}66 */67 public function setUp() {68 parent::setUp();69 $this->menuLinkManager = \Drupal::service('plugin.manager.menu.link');70 $this->blockStorage = \Drupal::service('entity_type.manager')71 ->getStorage('block');72 $this->blockViewBuilder = \Drupal::service('entity_type.manager')73 ->getViewBuilder('block');74 $this->menuLinkContentStorage = \Drupal::service('entity_type.manager')75 ->getStorage('menu_link_content');76 $this->moduleHandler = \Drupal::moduleHandler();77 $this->links = $this->createLinkHierarchy();78 // Create and log in an administrative user.79 $this->adminUser = $this->drupalCreateUser([80 'administer blocks',81 'access administration pages',82 ]);83 $this->drupalLogin($this->adminUser);84 }85 /**86 * Creates a simple hierarchy of links.87 */88 protected function createLinkHierarchy() {89 // First remove all the menu links in the menu.90 $this->menuLinkManager->deleteLinksInMenu('main');91 // Then create a simple link hierarchy:92 // - parent menu item93 // - child-1 menu item94 // - child-1-1 menu item95 // - child-1-2 menu item96 // - child-2 menu item.97 $base_options = [98 'provider' => 'menu_block',99 'menu_name' => 'main',100 ];101 $parent = $base_options + [102 'title' => 'parent menu item',103 'link' => ['uri' => 'internal:/menu-block-test/hierarchy/parent'],104 ];105 /** @var \Drupal\menu_link_content\MenuLinkContentInterface $link */106 $link = $this->menuLinkContentStorage->create($parent);107 $link->save();108 $links['parent'] = $link->getPluginId();109 $child_1 = $base_options + [110 'title' => 'child-1 menu item',111 'link' => ['uri' => 'internal:/menu-block-test/hierarchy/parent/child-1'],112 'parent' => $links['parent'],113 ];114 $link = $this->menuLinkContentStorage->create($child_1);115 $link->save();116 $links['child-1'] = $link->getPluginId();117 $child_1_1 = $base_options + [118 'title' => 'child-1-1 menu item',119 'link' => ['uri' => 'internal:/menu-block-test/hierarchy/parent/child-1/child-1-1'],120 'parent' => $links['child-1'],121 ];122 $link = $this->menuLinkContentStorage->create($child_1_1);123 $link->save();124 $links['child-1-1'] = $link->getPluginId();125 $child_1_2 = $base_options + [126 'title' => 'child-1-2 menu item',127 'link' => ['uri' => 'internal:/menu-block-test/hierarchy/parent/child-1/child-1-2'],128 'parent' => $links['child-1'],129 ];130 $link = $this->menuLinkContentStorage->create($child_1_2);131 $link->save();132 $links['child-1-2'] = $link->getPluginId();133 $child_2 = $base_options + [134 'title' => 'child-2 menu item',135 'link' => ['uri' => 'internal:/menu-block-test/hierarchy/parent/child-2'],136 'parent' => $links['parent'],137 ];138 $link = $this->menuLinkContentStorage->create($child_2);139 $link->save();140 $links['child-2'] = $link->getPluginId();141 return $links;142 }143 /**144 * Checks if all menu block configuration options are available.145 */146 public function testMenuBlockFormDisplay() {147 $this->drupalGet('admin/structure/block/add/menu_block:main');148 $this->assertSession()->pageTextContains('Initial visibility level');149 $this->assertSession()->pageTextContains('Number of levels to display');150 $this->assertSession()->pageTextContains('Expand all menu links');151 $this->assertSession()->pageTextContains('Fixed parent item');152 $this->assertSession()153 ->pageTextContains('Make the initial visibility level follow the active menu item.');154 $this->assertSession()->pageTextContains('Theme hook suggestion');155 }156 /**157 * Checks if all menu block settings are saved correctly.158 */159 public function testMenuBlockUi() {160 $block_id = 'main';161 $this->drupalPostForm('admin/structure/block/add/menu_block:main', [162 'id' => $block_id,163 'settings[label]' => 'Main navigation',164 'settings[label_display]' => FALSE,165 'settings[level]' => 2,166 'settings[depth]' => 6,167 'settings[expand]' => TRUE,168 'settings[parent]' => 'main:',169 'settings[follow]' => TRUE,170 'settings[follow_parent]' => 'active',171 'settings[suggestion]' => 'main',172 'region' => 'primary_menu',173 ], 'Save block');174 $block = $this->blockStorage->load($block_id);175 $block_settings = $block->get('settings');176 $this->assertSame(2, $block_settings['level']);177 $this->assertSame(6, $block_settings['depth']);178 $this->assertTrue($block_settings['expand']);179 $this->assertSame('main:', $block_settings['parent']);180 $this->assertTrue($block_settings['follow']);181 $this->assertSame('active', $block_settings['follow_parent']);182 $this->assertSame('main', $block_settings['suggestion']);183 }184 /**185 * Tests the menu_block level option.186 */187 public function testMenuBlockLevel() {188 // Add new menu block.189 $block_id = 'main';190 $this->drupalPostForm('admin/structure/block/add/menu_block:main', [191 'id' => $block_id,192 'settings[label]' => 'Main navigation',193 'settings[label_display]' => FALSE,194 'settings[level]' => 1,195 'region' => 'primary_menu',196 ], 'Save block');197 // Check if the parent menu item is visible, but the child menu items not.198 $this->drupalGet('<front>');199 $this->assertSession()->pageTextContains('parent menu item');200 $this->assertSession()->pageTextNotContains('child-1 menu item');201 $this->assertSession()->pageTextNotContains('child-1-1 menu item');202 $this->assertSession()->pageTextNotContains('child-2 menu item');203 $this->drupalPostForm('admin/structure/block/manage/' . $block_id, [204 'settings[level]' => 2,205 ], 'Save block');206 // Check if the menu items of level 2 are visible, but not the parent menu207 // item.208 $this->drupalGet('menu-block-test/hierarchy/parent');209 $this->assertSession()->pageTextContains('child-1 menu item');210 $this->assertSession()->pageTextContains('child-2 menu item');211 $this->assertSession()->pageTextNotContains('parent menu item');212 $this->assertSession()->pageTextNotContains('child-1-1 menu item');213 }214 /**215 * Tests the menu_block depth option.216 */217 public function testMenuBlockDepth() {218 // Add new menu block.219 $block_id = 'main';220 $this->drupalPostForm('admin/structure/block/add/menu_block:main', [221 'id' => $block_id,222 'settings[label]' => 'Main navigation',223 'settings[label_display]' => FALSE,224 'settings[level]' => 1,225 'settings[depth]' => 1,226 'settings[expand]' => TRUE,227 'region' => 'primary_menu',228 ], 'Save block');229 // Check if the parent menu item is visible, but the child menu items not.230 $this->drupalGet('<front>');231 $this->assertSession()->pageTextContains('parent menu item');232 $this->assertSession()->pageTextNotContains('child-1 menu item');233 $this->assertSession()->pageTextNotContains('child-1-1 menu item');234 $this->assertSession()->pageTextNotContains('child-2 menu item');235 $this->drupalPostForm('admin/structure/block/manage/' . $block_id, [236 'settings[depth]' => 2,237 ], 'Save block');238 // Check if the menu items of level 2 are visible, but not the parent menu239 // item.240 $this->drupalGet('menu-block-test/hierarchy/parent');241 $this->assertSession()->pageTextContains('parent menu item');242 $this->assertSession()->pageTextContains('child-1 menu item');243 $this->assertSession()->pageTextContains('child-2 menu item');244 $this->assertSession()->pageTextNotContains('child-1-1 menu item');245 $this->drupalPostForm('admin/structure/block/manage/' . $block_id, [246 'settings[depth]' => 0,247 ], 'Save block');248 // Check if the menu items of level 2 are visible, but not the parent menu249 // item.250 $this->drupalGet('<front>');251 $this->assertSession()->pageTextContains('parent menu item');252 $this->assertSession()->pageTextContains('child-1 menu item');253 $this->assertSession()->pageTextContains('child-2 menu item');254 $this->assertSession()->pageTextContains('child-1-1 menu item');255 }256 /**257 * Tests the menu_block expand option.258 */259 public function testMenuBlockExpand() {260 $block_id = 'main';261 $this->drupalPostForm('admin/structure/block/add/menu_block:main', [262 'id' => $block_id,263 'settings[label]' => 'Main navigation',264 'settings[label_display]' => FALSE,265 'settings[level]' => 1,266 'settings[expand]' => TRUE,267 'region' => 'primary_menu',268 ], 'Save block');269 // Check if the parent menu item is visible, but the child menu items not.270 $this->drupalGet('<front>');271 $this->assertSession()->pageTextContains('parent menu item');272 $this->assertSession()->pageTextContains('child-1 menu item');273 $this->assertSession()->pageTextContains('child-1-1 menu item');274 $this->assertSession()->pageTextContains('child-2 menu item');275 $this->drupalPostForm('admin/structure/block/manage/' . $block_id, [276 'settings[expand]' => FALSE,277 ], 'Save block');278 $this->drupalGet('<front>');279 $this->assertSession()->pageTextContains('parent menu item');280 $this->assertSession()->pageTextNotContains('child-1 menu item');281 $this->assertSession()->pageTextNotContains('child-1-1 menu item');282 $this->assertSession()->pageTextNotContains('child-2 menu item');283 }284 /**285 * Tests the menu_block parent option.286 */287 public function testMenuBlockParent() {288 $block_id = 'main';289 $this->drupalPostForm('admin/structure/block/add/menu_block:main', [290 'id' => $block_id,291 'settings[label]' => 'Main navigation',292 'settings[label_display]' => FALSE,293 'settings[parent]' => 'main:' . $this->links['parent'],294 'region' => 'primary_menu',295 ], 'Save block');296 $this->drupalGet('<front>');297 $this->assertSession()->pageTextNotContains('parent menu item');298 $this->assertSession()->pageTextContains('child-1 menu item');299 $this->assertSession()->pageTextNotContains('child-1-1 menu item');300 $this->drupalPostForm('admin/structure/block/manage/' . $block_id, [301 'settings[parent]' => 'main:' . $this->links['child-1'],302 ], 'Save block');303 $this->assertSession()->pageTextNotContains('parent menu item');304 $this->assertSession()->pageTextNotContains('child-1 menu item');305 $this->assertSession()->pageTextContains('child-1-1 menu item');306 $this->assertSession()->pageTextContains('child-1-2 menu item');307 }308 /**309 * Tests the menu_block follow and follow_parent option.310 */311 public function testMenuBlockFollow() {312 $block_id = 'main';313 $this->drupalPostForm('admin/structure/block/add/menu_block:main', [314 'id' => $block_id,315 'settings[label]' => 'Main navigation',316 'settings[label_display]' => FALSE,317 'settings[follow]' => TRUE,318 'settings[follow_parent]' => 'child',319 'region' => 'primary_menu',320 ], 'Save block');321 $this->drupalGet('<front>');322 $this->assertSession()->pageTextContains('parent menu item');323 $this->assertSession()->pageTextNotContains('child-1 menu item');324 $this->assertSession()->pageTextNotContains('child-1-1 menu item');325 $this->drupalGet('menu-block-test/hierarchy/parent');326 $this->assertSession()->pageTextNotContains('parent menu item');327 $this->assertSession()->pageTextContains('child-1 menu item');328 $this->assertSession()->pageTextContains('child-2 menu item');329 $this->drupalGet('menu-block-test/hierarchy/parent/child-1');330 $this->assertSession()->pageTextNotContains('parent menu item');331 $this->assertSession()->pageTextNotContains('child-1 menu item');332 $this->assertSession()->pageTextContains('child-1-1 menu item');333 $this->assertSession()->pageTextContains('child-1-2 menu item');334 $this->assertSession()->pageTextNotContains('child-2 menu item');335 $this->drupalPostForm('admin/structure/block/manage/' . $block_id, [336 'settings[follow_parent]' => 'active',337 ], 'Save block');338 $this->drupalGet('<front>');339 $this->assertSession()->pageTextContains('parent menu item');340 $this->assertSession()->pageTextNotContains('child-1 menu item');341 $this->assertSession()->pageTextNotContains('child-1-1 menu item');342 $this->drupalGet('menu-block-test/hierarchy/parent');343 $this->assertSession()->pageTextContains('parent menu item');344 $this->assertSession()->pageTextContains('child-1 menu item');345 $this->assertSession()->pageTextNotContains('child-1-1 menu item');346 }347 /**348 * Tests the menu_block suggestion option.349 */350 public function testMenuBlockSuggestion() {351 $block_id = 'main';352 $this->drupalPostForm('admin/structure/block/add/menu_block:main', [353 'id' => $block_id,354 'settings[label]' => 'Main navigation',355 'settings[label_display]' => FALSE,356 'settings[suggestion]' => 'mainnav',357 'region' => 'primary_menu',358 ], 'Save block');359 /** @var \Drupal\block\BlockInterface $block */360 $block = $this->blockStorage->load($block_id);361 $plugin = $block->getPlugin();362 // Check theme suggestions for block template.363 $variables = [];364 $variables['elements']['#configuration'] = $plugin->getConfiguration();365 $variables['elements']['#plugin_id'] = $plugin->getPluginId();366 $variables['elements']['#id'] = $block->id();367 $variables['elements']['#base_plugin_id'] = $plugin->getBaseId();368 $variables['elements']['#derivative_plugin_id'] = $plugin->getDerivativeId();369 $variables['elements']['content'] = [];370 $suggestions = $this->moduleHandler->invokeAll('theme_suggestions_block', [$variables]);371 $base_theme_hook = 'menu_block';372 $hooks = [373 'theme_suggestions',374 'theme_suggestions_' . $base_theme_hook,375 ];376 $this->moduleHandler->alter($hooks, $suggestions, $variables, $base_theme_hook);377 $this->assertSame($suggestions, [378 'block__menu_block',379 'block__menu_block',380 'block__menu_block__main',381 'block__main',382 'block__menu_block__mainnav',383 ], 'Found expected block suggestions.');384 // Check theme suggestions for menu template.385 $variables = [386 'menu_name' => 'main',387 'menu_block_configuration' => $plugin->getConfiguration(),388 ];389 $suggestions = $this->moduleHandler->invokeAll('theme_suggestions_menu', [$variables]);390 $base_theme_hook = 'menu';391 $hooks = [392 'theme_suggestions',393 'theme_suggestions_' . $base_theme_hook,394 ];395 $this->moduleHandler->alter($hooks, $suggestions, $variables, $base_theme_hook);396 $this->assertSame($suggestions, [397 'menu__main',398 'menu__mainnav',399 ], 'Found expected menu suggestions.');400 }401}...

Full Screen

Full Screen

contains

Using AI Code Generation

copy

Full Screen

1$child = new Child();2$child->contains('hello');3$parent = new Parent();4$parent->contains('hello');5$parent = new Parent();6$parent->contains('hello');7$child = new Child();8$child->contains('hello');9$parent = new Parent();10$parent->contains('hello');11$child = new Child();12$child->contains('hello');13$parent = new Parent();14$parent->contains('hello');15$child = new Child();16$child->contains('hello');17$child = new Child();18$child->contains('hello');19$parent = new Parent();20$parent->contains('hello');21$child = new Child();22$child->contains('hello');23$parent = new Parent();24$parent->contains('hello');25$child = new Child();26$child->contains('hello');27$parent = new Parent();28$parent->contains('hello');29$child = new Child();30$child->contains('hello');31$child = new Child();32$child->contains('hello');33$parent = new Parent();34$parent->contains('hello');

Full Screen

Full Screen

contains

Using AI Code Generation

copy

Full Screen

1$child = new child();2echo $child->contains('a');3$parent = new parent();4echo $parent->contains('a');5$child = new child();6echo $child->contains('a');7$parent = new parent();8echo $parent->contains('a');9$child = new child();10echo $child->contains('a');11$parent = new parent();12echo $parent->contains('a');13$child = new child();14echo $child->contains('a');15$parent = new parent();16echo $parent->contains('a');17$child = new child();18echo $child->contains('a');19$parent = new parent();20echo $parent->contains('a');21$child = new child();22echo $child->contains('a');23$parent = new parent();24echo $parent->contains('a');25$child = new child();26echo $child->contains('a');27$parent = new parent();28echo $parent->contains('a');29$child = new child();30echo $child->contains('a');31$parent = new parent();32echo $parent->contains('a');

Full Screen

Full Screen

contains

Using AI Code Generation

copy

Full Screen

1$child = new Child();2$child->contains("Hello World");3$parent = new Parent();4$parent->contains("Hello World");5Recommended Posts: PHP | __call() Magic Method6PHP | __callStatic() Magic Method7PHP | __set_state() Magic Method8PHP | __wakeup() Magic Method9PHP | __sleep() Magic Method10PHP | __invoke() Magic Method11PHP | __set() Magic Method12PHP | __get() Magic Method13PHP | __isset() Magic Method14PHP | __unset() Magic Method15PHP | __clone() Magic Method16PHP | __debugInfo() Magic Method17PHP | __destruct() Magic Method18PHP | __construct() Magic Method19PHP | __tostring() Magic Method20PHP | __autoload() Magic Method21PHP | __halt_compiler() Magic Method22PHP | __halt_compiler() Magic Method23PHP | __autoload() Magic Method24PHP | __debugInfo() Magic Method25PHP | __clone() Magic Method26PHP | __unset() Magic Method27PHP | __isset() Magic Method28PHP | __get() Magic Method29PHP | __set() Magic Method30PHP | __invoke() Magic Method31PHP | __sleep() Magic Method32PHP | __wakeup() Magic Method33PHP | __set_state() Magic

Full Screen

Full Screen

contains

Using AI Code Generation

copy

Full Screen

1$child = new Child();2$child->contains("Hello World");3$child = new Child();4$child->contains("Hello World");5$child = new Child();6$child->contains("Hello World");7$child = new Child();8$child->contains("Hello World");9$child = new Child();10$child->contains("Hello World");11$child = new Child();12$child->contains("Hello World");13$child = new Child();14$child->contains("Hello World");15$child = new Child();16$child->contains("Hello World");17$child = new Child();18$child->contains("Hello World");19$child = new Child();20$child->contains("Hello World");21$child = new Child();22$child->contains("Hello World");23$child = new Child();24$child->contains("Hello World");25$child = new Child();26$child->contains("Hello World");27$child = new Child();28$child->contains("Hello World");29$child = new Child();30$child->contains("Hello World");31$child = new Child();32$child->contains("Hello World");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger contains code on LambdaTest Cloud Grid

Execute automation tests with contains on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful