Skip to content

Commit

Permalink
Fix some test fails, add hook calls
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanjfshaw committed Jan 2, 2017
1 parent 3c7071d commit 1a09fea
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 9 deletions.
2 changes: 1 addition & 1 deletion features/bootstrap/FeatureContext.php
Expand Up @@ -68,7 +68,7 @@ public function alterUserParameters(EntityScope $scope) {
}

/**
* Hook into user creation to test `@beforeUserCreate`
* Hook into user creation to test `@beforeEntityCreate`
*
* @beforeEntityCreate
*/
Expand Down
15 changes: 7 additions & 8 deletions features/entity.feature
Expand Up @@ -16,14 +16,12 @@ Feature: EntityContext
| fredbloggs | fredbloggs@example.com |
When I am at "admin/people"
Then I should see "johndoe"
When I click "johndoe"
And I click "Edit"
When I click "Edit" in the "johndoe" row
Then the "mail" field should contain "johndoe@example.com"
When I am at "admin/people"
Then I should see "fredbloggs"
When I click "fredbloggs"
And I click "Edit"
Then the "mail" field should contain "fredbloggs@example.com"
When I click "Edit" in the "fredbloggs" row
Then the "mail" field should contain "fredbloggs@example.com"

Scenario: Test entities have been cleaned up after previous scenario
When I am at "admin/people"
Expand All @@ -36,8 +34,7 @@ Feature: EntityContext
| johndoe | johndoe@example.com |
When I am at "admin/people"
Then I should see "johndoe"
When I click "johndoe"
And I click "Edit"
When I click "Edit" in the "johndoe" row
Then the "mail" field should contain "johndoe@example.com"

Scenario: Test single bundled entity in "Given a :bundle :entity_type entity"
Expand Down Expand Up @@ -122,7 +119,9 @@ Feature: EntityContext
| name | johndoe |
| mail | johndoe@example.com |
Then I should see "johndoe" in the ".page-title" element
When I click "Edit"
When I am at "admin/people"
Then I should see "johndoe"
When I click "Edit" in the "johndoe" row
Then the "mail" field should contain "johndoe@example.com"

Scenario: Test bundled entity in "Given I am viewing a :bundle :entity_type entity:"
Expand Down
25 changes: 25 additions & 0 deletions src/Drupal/DrupalExtension/Hook/Call/AfterEntityCreate.php
@@ -0,0 +1,25 @@
<?php

namespace Drupal\DrupalExtension\Hook\Call;

use Drupal\DrupalExtension\Hook\Scope\OtherEntityScope;

/**
* AfterEntityCreate hook class.
*/
class AfterEntityCreate extends EntityHook {

/**
* Initializes hook.
*/
public function __construct($filterString, $callable, $description = null) {
parent::__construct(OtherEntityScope::AFTER, $filterString, $callable, $description);
}

/**
* {@inheritdoc}
*/
public function getName() {
return 'AfterEntityCreate';
}
}
26 changes: 26 additions & 0 deletions src/Drupal/DrupalExtension/Hook/Call/BeforeEntityCreate.php
@@ -0,0 +1,26 @@
<?php

namespace Drupal\DrupalExtension\Hook\Call;

use Drupal\DrupalExtension\Hook\Scope\OtherEntityScope;

/**
* BeforeEntityCreate hook class.
*/
class BeforeEntityCreate extends EntityHook {

/**
* Initializes hook.
*/
public function __construct($filterString, $callable, $description = null) {
parent::__construct(OtherEntityScope::BEFORE, $filterString, $callable, $description);
}

/**
* {@inheritdoc}
*/
public function getName() {
return 'BeforeEntityCreate';
}

}

0 comments on commit 1a09fea

Please sign in to comment.