Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Behatbundle Laravel Package

ezsystems/behatbundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require --dev ezsystems/behatbundle --no-scripts --no-plugins
    composer sync-recipes ezsystems/behatbundle --force -v
    

    Ensure your project uses Ibexa DXP (formerly eZ Platform) as a dependency.

  2. Configure behat.yml:

    default:
      suites:
        default:
          contexts:
            - Ibexa\BehatBundle\Context\FeatureContext
            - Ibexa\BehatBundle\Context\ContentContext
            - Ibexa\BehatBundle\Context\UiContext
          filters:
            tags: "@wip"
    
  3. First Test Case: Create a feature file (e.g., features/login.feature):

    Feature: User login
      Scenario: Successful login
        Given I am on the login page
        When I fill in "email" with "user@example.com"
        And I fill in "password" with "password123"
        And I press "Login"
        Then I should see "Welcome"
    
  4. Run Tests:

    vendor/bin/behat
    

Key First Use Case

Test a content creation workflow in Ibexa DXP:

Feature: Create a content item
  Scenario: Publish an article
    Given I am logged in as "admin"
    When I create a content item of type "article"
    And I fill in "title" with "My Article"
    And I press "Save and Publish"
    Then I should see "My Article" in the content list

Implementation Patterns

Workflows

  1. SiteAccess Management: Use Ibexa\BehatBundle\Context\SiteContext to switch between siteaccesses:

    Given I switch to siteaccess "admin"
    
  2. Content Operations: Leverage ContentContext for CRUD operations:

    When I create a content item of type "article" under "/1/2"
    And I update its field "intro" with "Updated intro"
    
  3. UI Testing: Use UiContext for frontend interactions:

    When I click on "Edit" link for content item "My Article"
    Then I should see "Edit Article" in the title
    
  4. Authentication: Test user flows with UserContext:

    Given I am logged in as "editor" with password "password"
    

Integration Tips

  • Custom Contexts: Extend existing contexts (e.g., FeatureContext) for domain-specific logic:

    namespace App\Behat\Context;
    
    use Ibexa\BehatBundle\Context\FeatureContext;
    
    class CustomFeatureContext extends FeatureContext
    {
        public function assertCustomBehavior()
        {
            // Custom assertions
        }
    }
    

    Register in behat.yml:

    contexts:
      - App\Behat\Context\CustomFeatureContext
    
  • Data Fixtures: Use Ibexa\BehatBundle\Context\DataContext to load fixtures:

    Given I load fixtures from "path/to/fixtures.yml"
    
  • API Testing: Combine with HttpContext for API endpoints:

    When I send a GET request to "/api/content"
    Then the response status code should be 200
    
  • Parallel Testing: Configure Behat’s --tags and --group flags for parallel execution:

    vendor/bin/behat --tags "@smoke" --group "content"
    

Gotchas and Tips

Pitfalls

  1. SiteAccess Configuration:

    • Ensure config/siteaccesses.yml is properly set up. Missing siteaccesses will cause SiteContext failures.
    • Debug with:
      vendor/bin/ibexa:siteaccess:list
      
  2. Context Loading Order:

    • Behat loads contexts in alphabetical order. Explicitly order dependencies in behat.yml:
      contexts:
        - Ibexa\BehatBundle\Context\FeatureContext
        - Ibexa\BehatBundle\Context\ContentContext  # Depends on FeatureContext
      
  3. Database Transactions:

    • Tests run in transactions by default. Use @noTransaction tag for tests requiring DB persistence:
      @noTransaction
      Scenario: Test with persistent data
      
  4. Deprecated Commands:

    • Commands like ezplatform:behat:init are deprecated. Use ibexa:behat:init (v9.0+).
  5. Allure Reports:

    • Removed in v8.3.18+. Use alternative reporters like behat-html-formatter.

Debugging Tips

  • Enable Verbose Output:

    vendor/bin/behat -v
    
  • Step Definitions: Override steps in FeatureContext for debugging:

    public function iCreateAContentItemOfType($type, $location = null)
    {
        try {
            return parent::iCreateAContentItemOfType($type, $location);
        } catch (\Exception $e) {
            throw new \Exception("Failed to create content: " . $e->getMessage());
        }
    }
    
  • Screenshot on Failure: Configure behat.yml to capture screenshots:

    extensions:
      Behat\MinkExtension:
        screenshots_directory: tests/_output/screenshots
        show_cmd: open
    

Extension Points

  1. Custom Step Definitions: Extend FeatureContext or create new contexts:

    namespace App\Behat\Context;
    
    use Behat\Behat\Context\Context;
    use Behat\Behat\Hook\Scope\BeforeScenarioScope;
    
    class HookContext implements Context
    {
        /**
         * @BeforeScenario
         */
        public static function beforeScenario(BeforeScenarioScope $scope)
        {
            // Setup logic (e.g., clear cache)
        }
    }
    
  2. Environment-Specific Config: Use behat.yml environment variables:

    default:
      extensions:
        Behat\MinkExtension:
          base_url: "%env(BEHAT_BASE_URL)%"
    
  3. Custom Fixtures: Load fixtures dynamically:

    use Ibexa\BehatBundle\Context\DataContext;
    
    class CustomDataContext extends DataContext
    {
        public function loadCustomFixtures($path)
        {
            $this->loadFixturesFromYaml($path);
        }
    }
    
  4. Hooks for Setup/Teardown: Use Behat hooks for test lifecycle management:

    /**
     * @BeforeScenario
     */
    public function clearCache()
    {
        $this->getContainer()->get('ezpublish.cache_manager')->clearAll();
    }
    

Configuration Quirks

  • SiteAccess Auto-Detection: The bundle auto-detects siteaccesses from config/siteaccesses.yml. Override with:

    Ibexa\BehatBundle\Context\SiteContext:
      siteaccess: "custom_siteaccess"
    
  • Content Type Limitations: Ensure content types exist in the test environment. Use:

    Given I load content type "article" from "config/contenttypes/article.yml"
    
  • Locale Handling: Set default locale in behat.yml:

    Ibexa\BehatBundle\Context\LocaleContext:
      default_locale: "eng-GB"
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor