Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Call to a member function json() on null #34

@soullivaneuh

Description

@soullivaneuh

Behat config:

default:
    calls:
        error_reporting: 14335 # E_ALL & ~E_USER_DEPRECATED
    extensions:
        Behat\Symfony2Extension: ~
        Behat\WebApiExtension: ~
        Behat\MinkExtension:
            sessions:
                default:
                    symfony2: ~
    suites:
        default:
            contexts:
             - Behat\WebApiExtension\Context\WebApiContext
             - \FeatureContext

Behat feature:

Feature: api/security
  In order to fully or partially access the api
  I need to have the good rights

  Scenario: API as anonymous
    Given I am on "/api/user"
    And the response status code should be 401
    And the response should contain json:
    """
    {
       "error" : "invalid_grant",
       "error_description" : "No API key given."
    }
    """

Result:

$ behat features/api/security.feature 
Feature: api/security
  In order to fully or partially access the api
  I need to have the good rights

  Scenario: API as anonymous                   # features/api/security.feature:5
    Given I am on "/api/user"                  # FeatureContext::visit()
    And the response status code should be 401 # FeatureContext::assertResponseStatus()
PHP Fatal error:  Call to a member function json() on null in project/vendor/behat/web-api-extension/src/Context/WebApiContext.php on line 244
[...]

Is that an issue or a misconfiguration?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions