Updated: Comment #10

Problem/Motivation

When I run the scenario "Scenario: Test ability to create nodes" from api.feature, I get the exception

No ability to create nodes in Drupal\Driver\DrushDriver

Is it supposed to throw this exception?

Proposed resolution

1. Use the devel_generate module
2. In behat.yml, set the default api driver and drupal_root. (See comment #6)
3. See #1823602: Need a framework for creating nodes (in drush driver)

Remaining tasks

Choose a solution and implement it. (or propose others)

Comments

kssundar’s picture

Title: Exception "No ability to create nodes in Drupal\Driver\DrushDriver" » Exception "No ability to create nodes in Drupal\Driver\DrushDriver" (api.feature)

Adjusting title

jhedstrom’s picture

Title: Exception "No ability to create nodes in Drupal\Driver\DrushDriver" (api.feature) » Add ability to create nodes in Drupal\Driver\DrushDriver
Category: bug » feature

Until there is a way to create nodes in Drush, this is intentional. It has been suggested that one way to do this would be to use the devel_generate module, but that's a pretty big assumption that people would have that module.

jjozwiak’s picture

I'm getting the same error while running the following feature that Ryan Weaver presented at Drupalcon Portland. Has anything changed on this between last November and June? Somehow it worked for him. Ideas why I'm getting this error?

Feature: Node Management

Background: Given I am logged in as a user with the "administrator" role

Scenario: Edit Node
	Given I am viewing a "page" node with the title "Cool Beans!"
	When I click "Edit" in the "Body" region
	And I fill in the following:
		| Body | Ipsum |
	And I press "Save"
	Then I should see "Ipsum" in the "Body" region
b2f’s picture

@jjozwiak
Have your configured your behat.yml with a drush alias or Drupal path ?
Then you seem to have forgotten the @api tag above your Scenario (or Feature), because your must be using a Drupal installation / API to login with a role.

Did you write on top:

@api
Feature: Node Management
jhedstrom’s picture

As I said in #2 there is currently no way to create nodes via the drush driver (drush itself has no built in code to create nodes).

alexkb’s picture

In your behat.yml, if you set the default api driver and the drupal_root, then your create node scenarios should work, albeit a bit slower (using drupal web instead of drush). e.g.

  Drupal\DrupalExtension\Extension:
    api_driver: "drupal"
    blackbox: ~
      drush:
        alias: devsite
      drupal:
        drupal_root: 'c:\wamp\vhosts\devsite\docroot'
pbuyle’s picture

I doubt Drush itself will ever provide a command to create node. AFAIK, there is no standardized serialization of a node (in Drupal 7), so a create node command will either have an awful number of dynamic options or rely on a non standardized node serialization.

But the presence of contrib Drush commands, or worse contrib modules installed on the tested site, is a big assumption that the Behat Drupal Extension should probably not make.

An option may be for Behat Drupal Extension to provide the additional Drush commands needed by the Drush Driver. The command file(s) can be included in Drush when run through the Drush Driver using the --include option (see `drush topic docs-configuration`).

Once such a system is in place, a custom Behat tailored 'add node' command could be added.

pbuyle’s picture

areke’s picture

Issue summary: View changes

Use summary template

areke’s picture

Issue summary: View changes

Fix typo

eliza411’s picture

Status: Active » Closed (duplicate)

I'm closing this in favor of Jonathan's issue so there's just one place to look for progress: #1823602: Need a framework for creating nodes (in drush driver)