Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ drupal7:
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MarkupContext
- Drupal\DrupalExtension\Context\BlockContext
filters:
tags: "@d7"
extensions:
Expand Down
2 changes: 1 addition & 1 deletion features/blackbox.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Feature: Test DrupalContext
Given I am at "community"
When I click "IRC" in the "content" region
Then I should see "Page status" in the "right sidebar"
And I should see the link "Drupal News" in the "footer" region
And I should see the link "Drupal News" in the "footer" region

Scenario: Viewing content in a region
Given I am on the homepage
Expand Down
6 changes: 6 additions & 0 deletions features/block.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@d7
Feature: Block
Test placement of blocks

Scenario: Test whether block placement is working
Given I place block "navigation" of module "system" at region "sidebar_first" of theme "bartik"
30 changes: 30 additions & 0 deletions src/Drupal/DrupalExtension/Context/BlockContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Drupal\DrupalExtension\Context;

use Behat\MinkExtension\Context\RawMinkContext;
use Behat\Behat\Context\TranslatableContext;

/**
* Extensions to the Mink Extension.
*/
class BlockContext extends RawDrupalContext implements TranslatableContext {

/**
* Returns list of definition translation resources paths.
*
* @return array
*/
public static function getTranslationResources() {
return glob(__DIR__ . '/../../../../i18n/*.xliff');
}

/**
* @Given I place block :delta of module :module at region :region of theme :theme
*/
public function assertPlaceBlockNew($delta, $module, $region, $theme) {
$this->placeBlock($delta, $module, $region, $theme);
$this->getSession()->getPage()->find("block-$module-$delta");
}

}
4 changes: 4 additions & 0 deletions src/Drupal/DrupalExtension/Context/RawDrupalContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,4 +603,8 @@ public function loggedInWithRole($role) {
return $this->loggedIn() && $this->getUserManager()->currentUserHasRole($role);
}

public function placeBlock($delta, $module, $region, $theme) {
$this->getDriver()->placeBlock($delta, $module, $region, $theme);
}

}