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

Should phpunit be a dependency? #13

Open
brockfanning opened this issue Mar 1, 2023 · 3 comments
Open

Should phpunit be a dependency? #13

brockfanning opened this issue Mar 1, 2023 · 3 comments

Comments

@brockfanning
Copy link

Hi all, I am right at the beginning of trying this out, but got hit by the same error mentioned in #4. I was just wondering if phpunit should be a dependency, since it seems to be necessary.

@robertfausk
Copy link
Owner

Hi, first at all: nice, that you give it a try!:)

Can you please provide a minimum example project (in github)?
Or at least the result of vendor/bin/behat -vvv and the content of your behat.yml and composer.json?

PS: phpunit is used a dev dependency in this library (robertfausk/behat-panther-extension) which is used just for developing
image

@brockfanning
Copy link
Author

Hi @robertfausk sure thing, here goes:

composer.json

{
    "require": {
        "robertfausk/behat-panther-extension": "^1.1"
    }
}

behat.yml

default:
  extensions:
    Robertfausk\Behat\PantherExtension: ~
    Behat\MinkExtension:
      base_url: https://example.com/
      javascript_session: javascript_chrome
      sessions:
        default:
          panther: ~
        javascript_chrome:
          panther:
            options:
              browser: 'chrome'
              webServerDir: '%paths.base%/web'

vendor/bin/behat -vvv

PHP Fatal error:  Uncaught Error: Class "PHPUnit\Framework\TestCase" not found in /var/www/html/vendor/symfony/panther/src/PantherTestCase.php:41
Stack trace:
#0 /var/www/html/vendor/composer/ClassLoader.php(582): include()
#1 /var/www/html/vendor/composer/ClassLoader.php(433): Composer\Autoload\{closure}('/var/www/html/v...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Symfony\\Compone...')
#3 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1042): ReflectionClass->newInstanceArgs(Array)
#4 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1165): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#5 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#6 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1011): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, false)
#7 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1165): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#8 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#9 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1572): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array)
#10 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1067): Symfony\Component\DependencyInjection\ContainerBuilder->callMethod(Object(Behat\Mink\Mink), Array, Array)
#11 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(567): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, false, 'mink')
#12 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1163): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('mink', 1, Array, false)
#13 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Reference), Array, false)
#14 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1011): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, false)
#15 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1165): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#16 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#17 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1572): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array)
#18 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1067): Symfony\Component\DependencyInjection\ContainerBuilder->callMethod(Object(Behat\Testwork\EventDispatcher\TestworkEventDispatcher), Array, Array)
#19 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1165): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true)
#20 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Definition), Array, true)
#21 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1011): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, true)
#22 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1165): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true)
#23 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Definition), Array, true)
#24 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, true)
#25 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1011): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, true)
#26 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(567): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true, 'cli.command')
#27 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(512): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('cli.command', 1)
#28 /var/www/html/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php(161): Symfony\Component\DependencyInjection\ContainerBuilder->get('cli.command')
#29 /var/www/html/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php(122): Behat\Testwork\Cli\Application->createCommand(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /var/www/html/vendor/symfony/console/Application.php(171): Behat\Testwork\Cli\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /var/www/html/vendor/behat/behat/bin/behat(34): Symfony\Component\Console\Application->run()
#32 /var/www/html/vendor/bin/behat(120): include('/var/www/html/v...')
#33 {main}
  thrown in /var/www/html/vendor/symfony/panther/src/PantherTestCase.php on line 41

Fatal error: Uncaught Error: Class "PHPUnit\Framework\TestCase" not found in /var/www/html/vendor/symfony/panther/src/PantherTestCase.php:41
Stack trace:
#0 /var/www/html/vendor/composer/ClassLoader.php(582): include()
#1 /var/www/html/vendor/composer/ClassLoader.php(433): Composer\Autoload\{closure}('/var/www/html/v...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Symfony\\Compone...')
#3 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1042): ReflectionClass->newInstanceArgs(Array)
#4 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1165): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#5 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#6 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1011): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, false)
#7 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1165): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#8 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#9 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1572): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array)
#10 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1067): Symfony\Component\DependencyInjection\ContainerBuilder->callMethod(Object(Behat\Mink\Mink), Array, Array)
#11 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(567): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, false, 'mink')
#12 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1163): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('mink', 1, Array, false)
#13 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Reference), Array, false)
#14 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1011): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, false)
#15 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1165): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#16 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Definition), Array, false)
#17 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1572): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array)
#18 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1067): Symfony\Component\DependencyInjection\ContainerBuilder->callMethod(Object(Behat\Testwork\EventDispatcher\TestworkEventDispatcher), Array, Array)
#19 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1165): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true)
#20 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Definition), Array, true)
#21 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1011): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, true)
#22 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1165): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true)
#23 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Definition), Array, true)
#24 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1111): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, true)
#25 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1011): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, true)
#26 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(567): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true, 'cli.command')
#27 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(512): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('cli.command', 1)
#28 /var/www/html/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php(161): Symfony\Component\DependencyInjection\ContainerBuilder->get('cli.command')
#29 /var/www/html/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php(122): Behat\Testwork\Cli\Application->createCommand(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /var/www/html/vendor/symfony/console/Application.php(171): Behat\Testwork\Cli\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /var/www/html/vendor/behat/behat/bin/behat(34): Symfony\Component\Console\Application->run()
#32 /var/www/html/vendor/bin/behat(120): include('/var/www/html/v...')
#33 {main}
  thrown in /var/www/html/vendor/symfony/panther/src/PantherTestCase.php on line 41

Notably if I remove the MinkExtension part from the behat.yml, I do not see the error. So, if the behat.yml is just this:

default:
  extensions:
    Robertfausk\Behat\PantherExtension: ~

Then I get the usual output:

No scenarios
No steps
0m0.00s (3.37Mb)

@robertfausk
Copy link
Owner

This is cause this library uses robertfausk/mink-panther-driver which is build on top of symfony/panther.
symfony/panther seems to expect to have one of symfony/framework-bundle or phpunit/phpunit to be installed.
https://github.com/symfony/panther/blob/main/src/PantherTestCase.php#L16-L17

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

2 participants