diff --git a/core/composer.json b/core/composer.json index b0afdde..38e2005 100644 --- a/core/composer.json +++ b/core/composer.json @@ -31,10 +31,8 @@ "behat/mink": "~1.6", "behat/mink-goutte-driver": "~1.1", "fabpot/goutte": "^2.0.3", - "masterminds/html5": "~2.1" - }, - "require-dev": { - "drupal/drupal-extension": "1.0.x-dev" + "masterminds/html5": "~2.1", + "drupal/drupal-extension": "~3.0" }, "autoload": { "psr-4": { diff --git a/core/modules/behat/behat.install b/core/modules/behat/behat.install index 5931a64..84502ff 100644 --- a/core/modules/behat/behat.install +++ b/core/modules/behat/behat.install @@ -1,21 +1,20 @@ set('default.extensions.Behat\MinkExtension\Extension.base_url', $base_url) - ->set('default.extensions.Drupal\DrupalExtension\Extension.drupal.drupal_root', DRUPAL_ROOT) - ->save(); - $config = \Drupal::service('config.storage'); - $data = $config->read('behat.dist'); + $behat_conf = Yaml::parse(DRUPAL_ROOT . '/' . \Drupal::moduleHandler()->getModule('behat')->getPath() . '/config/behat.yml.dist'); + $behat_conf['default']['extensions']['Behat\MinkExtension']['base_url'] = $base_url; + $behat_conf['default']['extensions']['Drupal\DrupalExtension']['drupal']['drupal_root'] = $base_url; // Write to file. - $dumper = new \Symfony\Component\Yaml\Dumper(); - $yaml = $dumper->dump($data, PHP_INT_MAX); + $yaml = Yaml::dump($behat_conf, PHP_INT_MAX); $destination = 'public://behat.yml'; $status = file_unmanaged_save_data($yaml, $destination, FILE_EXISTS_RENAME); diff --git a/core/modules/behat/config/behat.yml.dist b/core/modules/behat/config/behat.yml.dist new file mode 100644 index 0000000..498120c --- /dev/null +++ b/core/modules/behat/config/behat.yml.dist @@ -0,0 +1,30 @@ +default: + suites: + default: + contexts: + - FeatureContext + - Drupal\DrupalExtension\Context\DrupalContext + - Drupal\DrupalExtension\Context\MessageContext + - Drupal\DrupalExtension\Context\MinkContext + - Drupal\DrupalExtension\Context\MarkupContext + extensions: + Behat\MinkExtension: + goutte: ~ + selenium2: ~ + base_url: ~ + Drupal\DrupalExtension: + blackbox: ~ + api_driver: 'drupal' + drupal: + drupal_root: ~ + region_map: + content: "#content" + footer: "#footer" + left header: "#header-left" + right header: "#header-right" + right sidebar: "#aside-region" + selectors: + message_selector: '.messages' + error_message_selector: '.messages.error' + success_message_selector: '.messages.status' + warning_message_selector: '.messages.warning' \ No newline at end of file diff --git a/core/modules/behat/config/install/behat.dist.yml b/core/modules/behat/config/install/behat.dist.yml deleted file mode 100644 index e8c2119..0000000 --- a/core/modules/behat/config/install/behat.dist.yml +++ /dev/null @@ -1,14 +0,0 @@ -default: - extensions: - Behat\MinkExtension\Extension: - goutte: ~ - default_session: goutte - javascript_session: selenium2 - selenium2: - wd_host: 'http://127.0.0.1:4444/wd/hub' - base_url: ~ - Drupal\DrupalExtension\Extension: - blackbox: ~ - api_driver: drupal - drupal: - drupal_root: ~ diff --git a/core/modules/behat/config/schema/behat.schema.yml b/core/modules/behat/config/schema/behat.schema.yml new file mode 100644 index 0000000..ca71370 --- /dev/null +++ b/core/modules/behat/config/schema/behat.schema.yml @@ -0,0 +1,7 @@ +behat.settings: + type: config_object + label: 'Behat module settings' + mapping: + format: + type: string + label: 'Logging format' diff --git a/core/modules/behat/includes/behat.inc b/core/modules/behat/includes/behat.inc index c954b65..17028f1 100644 --- a/core/modules/behat/includes/behat.inc +++ b/core/modules/behat/includes/behat.inc @@ -1,6 +1,14 @@ TRUE)); $parser = behat_get_parser(); $features = array(); foreach ($feature_files as $feature_file) { + /* @var Behat\Gherkin\Node\FeatureNode $feature */ $feature = $parser->parse(file_get_contents($feature_file->uri)); - $feature->setFile($feature_file->uri); $feature->drupalModule = $module->getName(); - $features[$feature_file->filename] = $feature; + $features[$feature->getFile()] = $feature; } return $features; @@ -85,7 +93,7 @@ function behat_discover_module_features(\Drupal\Core\Extension\Extension $module * @return string * The system path for the module's Behat features directory. */ -function behat_module_features_path(\Drupal\Core\Extension\Extension $module) { +function behat_module_features_path(Extension $module) { $system_path = DRUPAL_ROOT . '/' . $module->getPath() . '/tests/features'; return $system_path; @@ -119,14 +127,13 @@ function behat_module_bootstrap_path($module) { * @param \Behat\Gherkin\Node\FeatureNode $feature * A Behat feature. */ -function behat_register_feature_scenarios(\Behat\Gherkin\Node\FeatureNode $feature) { +function behat_register_feature_scenarios(FeatureNode $feature) { $feature_location = behat_convert_absolute_to_relative_path($feature->getFile()); $scenarios = $feature->getScenarios(); foreach ($scenarios as $scenario) { $data['title'] = $scenario->getTitle(); - // @todo Figure out why this isn't getting the feature! - $data['feature'] = $scenario->getFeature()->getTitle(); + $data['feature'] = $feature->getTitle(); $data['location'] = $feature_location . ':' . $scenario->getLine(); $data['module'] = $feature->drupalModule; $entity = entity_create('behat_scenario', $data); @@ -139,7 +146,7 @@ function behat_register_feature_scenarios(\Behat\Gherkin\Node\FeatureNode $featu /** * Returns a Behat Parser object for parsing Gherkin. * - * @return object + * @return \Behat\Gherkin\Parser * An Behat\Gherkin\Parser object initialized with default English keywords. */ function behat_get_parser() { @@ -198,7 +205,7 @@ function behat_convert_absolute_to_relative_path($absolute_path) { * @return bool * TRUE if the module has behat scenarios registered with behat. */ -function behat_module_is_registered(\Drupal\Core\Extension\Extension $module) { +function behat_module_is_registered(Extension $module) { $query = 'SELECT bsid FROM {behat_scenario}'; $query .= ' WHERE module=:module LIMIT 1'; $result = db_query($query, array(':module' => $module->getName())); @@ -217,7 +224,7 @@ function behat_module_is_registered(\Drupal\Core\Extension\Extension $module) { * An array of locations for registered scenarios for the given module, keyed * by entitiy id. */ -function behat_get_module_scenario_registrations(\Drupal\Core\Extension\Extension $module) { +function behat_get_module_scenario_registrations(Extension $module) { $query = 'SELECT bsid, location FROM {behat_scenario}'; $query .= ' WHERE module=:module'; $result = db_query($query, array(':module' => $module->getName())); @@ -233,7 +240,7 @@ function behat_get_module_scenario_registrations(\Drupal\Core\Extension\Extensio * The id for this location. */ function behat_deregister_scenario($bsid) { - entity_delete('behat_scenario', $bsid); + Scenario::load($bsid)->delete(); } /** @@ -241,15 +248,12 @@ function behat_deregister_scenario($bsid) { * * @param Drupal\Core\Extension\Extension $module * The module to deregister. - * - * @return bool - * FALSE if the given entity type isn't compatible to the CRUD API. */ -function behat_deregister_module_scenarios(\Drupal\Core\Extension\Extension $module) { +function behat_deregister_module_scenarios(Extension $module) { $scenario_registrations = behat_get_module_scenario_registrations($module); $entity_ids = array_keys($scenario_registrations); - return entity_delete_multiple('behat_scenario', $entity_ids); + entity_delete_multiple('behat_scenario', $entity_ids); } /** @@ -285,7 +289,7 @@ function behat_set_env_param($key, $value) { unset($behat_params[$param_key]); } } - $behat_params_value = drupal_http_build_query($behat_params); + $behat_params_value = UrlHelper::buildQuery($behat_params); return putenv("BEHAT_PARAMS=$behat_params_value"); } @@ -387,8 +391,7 @@ function behat_format_arguments_build($formats) { if ($format == 'junit') { $dest_dir = 'public://behat'; $output_dir = file_prepare_directory($dest_dir, FILE_CREATE_DIRECTORY); - $wrapper = file_stream_wrapper_get_instance_by_uri($dest_dir); - $output_dest = $wrapper->realpath(); + $output_dest = \Drupal::service('file_system')->realpath($dest_dir); $out_dests[$format] = $output_dest; } // Other formats are written to stdout. @@ -432,8 +435,7 @@ function behat_tags_argument_build($tags) { * A snippet of behat command containing the configuration flag. */ function behat_config_argument_build() { - $config_file = drupal_realpath('public://behat.yml'); - + $config_file = \Drupal::service('file_system')->realpath('public://behat.yml'); return '--config ' . $config_file; } @@ -447,7 +449,6 @@ function behat_config_argument_build() { * The output of the executed command. */ function behat_execute_tests_command($command) { - $command = implode(' ', $command); $process = new \Symfony\Component\Process\Process($command); $process->run(function ($type, $buffer) { diff --git a/core/modules/behat/src/Entity/Scenario.php b/core/modules/behat/src/Entity/Scenario.php index 512f89f..ff1c64d 100644 --- a/core/modules/behat/src/Entity/Scenario.php +++ b/core/modules/behat/src/Entity/Scenario.php @@ -20,17 +20,19 @@ * @ContentEntityType( * id = "behat_scenario", * label = @Translation("Behat scenario"), - * controllers = { - * "storage" = "Drupal\Core\Entity\ContentEntityDatabaseStorage", - * "access" = "Drupal\Core\EntityAccessController", - * "list_builder" = "Drupal\Core\EntityListBuilder", + * handlers = { + * "storage" = "Drupal\behat\ScenarioStorage", + * "storage_schema" = "Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema", + * "access" = "Drupal\Core\Entity\EntityAccessControlHandler", + * "list_builder" = "Drupal\Core\Entity\EntityListBuilder", * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", * }, * admin_permission = "administer behat scenario", * base_table = "behat_scenario", * uri_callback = "behat_scenario_uri", * fieldable = FALSE, - * translatable = TRUE, + * translatable = FALSE, + * render_cache = FALSE, * entity_keys = { * "id" = "bsid", * "uuid" = "uuid" diff --git a/core/modules/behat/src/Form/SettingsForm.php b/core/modules/behat/src/Form/SettingsForm.php index 7efaacd..cbe622c 100644 --- a/core/modules/behat/src/Form/SettingsForm.php +++ b/core/modules/behat/src/Form/SettingsForm.php @@ -56,7 +56,6 @@ function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $this->config('behat.settings') ->set('format', $form_state['values']['log']) ->save(); @@ -64,4 +63,11 @@ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); } + /** + * {@inheritdoc} + */ + protected function getEditableConfigNames() { + return ['behat.settings']; + } + } diff --git a/core/modules/behat/src/ScenarioStorage.php b/core/modules/behat/src/ScenarioStorage.php index cb2f616..bce2fe7 100644 --- a/core/modules/behat/src/ScenarioStorage.php +++ b/core/modules/behat/src/ScenarioStorage.php @@ -7,14 +7,21 @@ namespace Drupal\behat; -use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\Query\QueryInterface; -use Drupal\Core\Entity\ContentEntityDatabaseStorage; +use Drupal\Core\Entity\Sql\SqlContentEntityStorage; /** * Defines a Controller class for taxonomy terms. */ -class ScenarioStorage extends ContentEntityDatabaseStorage { +class ScenarioStorage extends SqlContentEntityStorage { + + /** + * {@inheritdoc} + * + * We don't need to store behat scenario entities as they will be + * automatically recreated during next install. + */ + public function hasData() { + return FALSE; + } } diff --git a/core/modules/quickedit/tests/features/Quickedit.feature b/core/modules/quickedit/tests/features/Quickedit.feature index f51f002..2b06de0 100644 --- a/core/modules/quickedit/tests/features/Quickedit.feature +++ b/core/modules/quickedit/tests/features/Quickedit.feature @@ -4,7 +4,7 @@ Feature: Quick edit Link @api @javascript Scenario: Quick Edit Link appears in the content when Quick edit link is clicked. Given I am logged in as a user with the "administrator" role - And I am viewing my "article" node with the title "Aardvark" + And I am viewing my "article" with the title "Aardvark" When I click the element with css selector "button.toolbar-icon-edit" And I should see "Open Add new comment configuration options" in the "button.trigger" element And I click the element with CSS selector "button.trigger"