Loading CHANGELOG.txt +2 −0 Original line number Diff line number Diff line Search API 1.x, dev (xxxx-xx-xx): --------------------------------- - #3263875 by Eduardo Morales Alberti, drunken monkey, GrumpySchlag: Fixed Behat integration. - #3355677 by drunken monkey: Fixed incompatibility with PHP 7.3 in ConfigurablePropertyBase. - #3358819 by drunken monkey: Fixed tests against Drupal 10.1. Loading search_api.behat.inc +33 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ */ use Behat\Behat\Hook\Scope\AfterStepScope; use Behat\Gherkin\Node\FeatureNode; use Drupal\DrupalExtension\Context\DrupalSubContextBase; /** Loading @@ -15,6 +16,15 @@ use Drupal\DrupalExtension\Context\DrupalSubContextBase; */ class SearchApiSubContext extends DrupalSubContextBase { /** * Cached tags lists of features, keyed by feature hash. * * @var string[][] * * @see \SearchApiSubContext::getTagsFromFeature() */ protected static $tags; /** * Triggers all queued indexing operations for this page request. * Loading @@ -39,7 +49,7 @@ class SearchApiSubContext extends DrupalSubContextBase { * @AfterStep */ public function indexEntities(AfterStepScope $event) { $tags = $event->getFeature()->getTags(); $tags = static::getTagsFromFeature($event->getFeature()); if (!in_array('search_api', $tags)) { return; } Loading @@ -48,4 +58,26 @@ class SearchApiSubContext extends DrupalSubContextBase { ->destruct(); } /** * Extracts tags from a feature. * * @param \Behat\Gherkin\Node\FeatureNode $feature * Feature node from which to extract the tags. * * @return string[] * The tags list of the feature. */ public static function getTagsFromFeature(FeatureNode $feature): array { $feature_hash = md5($feature->getFile()); if (!isset(static::$tags[$feature_hash])) { $tags = []; foreach ($feature->getScenarios() as $scenario) { $scenario_tags = $scenario->getTags(); $tags = array_unique(array_merge($tags, $scenario_tags), SORT_REGULAR); } static::$tags[$feature_hash] = $tags; } return static::$tags[$feature_hash]; } } Loading
CHANGELOG.txt +2 −0 Original line number Diff line number Diff line Search API 1.x, dev (xxxx-xx-xx): --------------------------------- - #3263875 by Eduardo Morales Alberti, drunken monkey, GrumpySchlag: Fixed Behat integration. - #3355677 by drunken monkey: Fixed incompatibility with PHP 7.3 in ConfigurablePropertyBase. - #3358819 by drunken monkey: Fixed tests against Drupal 10.1. Loading
search_api.behat.inc +33 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ */ use Behat\Behat\Hook\Scope\AfterStepScope; use Behat\Gherkin\Node\FeatureNode; use Drupal\DrupalExtension\Context\DrupalSubContextBase; /** Loading @@ -15,6 +16,15 @@ use Drupal\DrupalExtension\Context\DrupalSubContextBase; */ class SearchApiSubContext extends DrupalSubContextBase { /** * Cached tags lists of features, keyed by feature hash. * * @var string[][] * * @see \SearchApiSubContext::getTagsFromFeature() */ protected static $tags; /** * Triggers all queued indexing operations for this page request. * Loading @@ -39,7 +49,7 @@ class SearchApiSubContext extends DrupalSubContextBase { * @AfterStep */ public function indexEntities(AfterStepScope $event) { $tags = $event->getFeature()->getTags(); $tags = static::getTagsFromFeature($event->getFeature()); if (!in_array('search_api', $tags)) { return; } Loading @@ -48,4 +58,26 @@ class SearchApiSubContext extends DrupalSubContextBase { ->destruct(); } /** * Extracts tags from a feature. * * @param \Behat\Gherkin\Node\FeatureNode $feature * Feature node from which to extract the tags. * * @return string[] * The tags list of the feature. */ public static function getTagsFromFeature(FeatureNode $feature): array { $feature_hash = md5($feature->getFile()); if (!isset(static::$tags[$feature_hash])) { $tags = []; foreach ($feature->getScenarios() as $scenario) { $scenario_tags = $scenario->getTags(); $tags = array_unique(array_merge($tags, $scenario_tags), SORT_REGULAR); } static::$tags[$feature_hash] = $tags; } return static::$tags[$feature_hash]; } }