Skip to content

Commit fcb1122

Browse files
committed
Issue #313: Step definition for placing block
1 parent 203929d commit fcb1122

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

behat.yml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ drupal7:
6464
- Drupal\DrupalExtension\Context\DrupalContext
6565
- Drupal\DrupalExtension\Context\MinkContext
6666
- Drupal\DrupalExtension\Context\MarkupContext
67+
- Drupal\DrupalExtension\Context\BlockContext
6768
filters:
6869
tags: "@d7"
6970
extensions:

features/blackbox.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Feature: Test DrupalContext
1313
Given I am at "community"
1414
When I click "IRC" in the "content" region
1515
Then I should see "Page status" in the "right sidebar"
16-
And I should see the link "Drupal News" in the "footer" region
16+
And I should see the link "Drupal News" in the "footer" region
1717

1818
Scenario: Viewing content in a region
1919
Given I am on the homepage

features/block.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@d7
2+
Feature: Block
3+
Test placement of blocks
4+
5+
Scenario: Test whether block placement is working
6+
Given I place block "navigation" of module "system" at region "sidebar_first" of theme "bartik"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Drupal\DrupalExtension\Context;
4+
5+
use Behat\MinkExtension\Context\RawMinkContext;
6+
use Behat\Behat\Context\TranslatableContext;
7+
8+
/**
9+
* Extensions to the Mink Extension.
10+
*/
11+
class BlockContext extends RawDrupalContext implements TranslatableContext {
12+
13+
/**
14+
* Returns list of definition translation resources paths.
15+
*
16+
* @return array
17+
*/
18+
public static function getTranslationResources() {
19+
return glob(__DIR__ . '/../../../../i18n/*.xliff');
20+
}
21+
22+
/**
23+
* @Given I place block :delta of module :module at region :region of theme :theme
24+
*/
25+
public function assertPlaceBlockNew($delta, $module, $region, $theme) {
26+
$this->placeBlock($delta, $module, $region, $theme);
27+
$this->getSession()->getPage()->find("block-$module-$delta");
28+
}
29+
30+
}

src/Drupal/DrupalExtension/Context/RawDrupalContext.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,4 +603,8 @@ public function loggedInWithRole($role) {
603603
return $this->loggedIn() && $this->getUserManager()->currentUserHasRole($role);
604604
}
605605

606+
public function placeBlock($delta, $module, $region, $theme) {
607+
$this->getDriver()->placeBlock($delta, $module, $region, $theme);
608+
}
609+
606610
}

0 commit comments

Comments
 (0)