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 Feb 11, 2018
1 parent 1907340 commit c0aafe9
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
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static 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
Original file line number Diff line number Diff line change
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 "[email protected]"
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 "[email protected]"
When I click "Edit" in the "fredbloggs" row
Then the "mail" field should contain "[email protected]"

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 "[email protected]"

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 "[email protected]"

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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 c0aafe9

Please sign in to comment.