Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with laravel 8 #89

Open
MWL91 opened this issue Oct 3, 2020 · 8 comments
Open

Not working with laravel 8 #89

MWL91 opened this issue Oct 3, 2020 · 8 comments

Comments

@MWL91
Copy link

MWL91 commented Oct 3, 2020

This is not working with new version of Laravel.
Also behat/mink-extension doesn't work with new symfony kernel.

I found solution for that, and used friends-of-behat/symfony-extension, but then this library returns me with

Class 'Symfony\Component\HttpKernel\Client' not found

How can I resolve this problem?

@MWL91
Copy link
Author

MWL91 commented Oct 4, 2020

Solution for that was quitely easy, you just need to change class use Symfony\Component\HttpKernel\Client; into use Symfony\Component\HttpKernel\HttpKernelBrowser as Client;.

To do that, overwrite KernelDriver class using composer.

In composer add this:

"autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        },
        "files": [
            "behat-overwrite/KernelDriver.php"
        ]
    },

And create file behat-overwrite/KernelDriver.php with contents below:

<?php

namespace Laracasts\Behat\Driver;

use Behat\Mink\Driver\BrowserKitDriver;
use Symfony\Component\HttpKernel\HttpKernelBrowser as Client;
use Symfony\Component\HttpKernel\HttpKernelInterface;

class KernelDriver extends BrowserKitDriver
{

    /**
     * Create a new KernelDriver.
     *
     * @param HttpKernelInterface $app
     * @param string|null         $baseUrl
     */
    public function __construct(HttpKernelInterface $app, $baseUrl = null)
    {
        parent::__construct(new Client($app), $baseUrl);
    }

    /**
     * Refresh the driver.
     *
     * @param HttpKernelInterface $app
     * @return KernelDriver
     */
    public function reboot($app)
    {
        return $this->__construct($app);
    }

}

It will works then fine :)

@MWL91
Copy link
Author

MWL91 commented Oct 4, 2020

I've created Pull Request #90 for that.
If you want you can try also user my fork adding

"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/MWL91/Behat-Laravel-Extension"
        }
    ]

and dev-require "laracasts/behat-laravel-extension": "dev-master as 1.1.1"

@Evoke-PHP
Copy link

In the "require-dev" section of composer.json I found that I also needed to add the following:

"friends-of-behat/mink-browserkit-driver": "dev-master as 1.3.4",
"friends-of-behat/mink-extension": "dev-master as 2.3.1",

@MWL91
Copy link
Author

MWL91 commented Feb 12, 2021

Yes, but you dont need to do that If you are not using mink :)

@TimothyDLewis
Copy link

TimothyDLewis commented Dec 13, 2022

This worked great, until I went to deploy this code to a non-local/testing environment. All my behat/mink stuff was in composer.json under require-dev, so on startup, I got the following error:

[Error]
Class "Behat\Mink\Driver\BrowserKitDriver" not found
Exception trace:
.../behat-overwrite/KernelDriver.php:9

Which points to:

use Behat\Mink\Driver\BrowserKitDriver;

So, if you have all of your behat/mink stuff in require-dev (as you should, since it's for testing), make sure you modify your composer.php to match:

"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    },
    "files": [
        "behat-overwrite/KernelDriver.php"
    ]
},

Basically, add "behat-overwrite/KernelDriver.php" to "autoload-dev"'s "files" array instead of "autoload" (non-dev)

@soulcodex
Copy link

soulcodex commented Feb 5, 2023

@TimothyDLewis @MWL91 @Evoke-PHP @JeffreyWay in order to bring support for Behat as an option to write acceptance test in laravel I have created a new repository / behat-extension. Do you know anyone interested in supporting / helping / maintaining with me this component? The library its already updated but i just give support from PHP 8.0

image

It's a private repository at the moment, but if someone wants access I can give you access

@MWL91
Copy link
Author

MWL91 commented Feb 6, 2023

Make it public 😉

@soulcodex
Copy link

soulcodex commented Feb 6, 2023

@MWL91 Its already public 😄 Laravel Behat Extension and available from Packagist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants