Symfony phpunit undefined method Kernel::bootstrapEnv() - symfony

After installing PHPUnit following :
https://symfony.com/doc/current/testing.html
# In bin/phpunit
App\Kernel
To its path in my project. I get the error :
Call to undefined method My\Bundle\Path\Kernel::bootstrapEnv()
When I run bin/phpunit
Can anyone help me understand the reasons it's behaving this way? I'm starting to believe, the bin/phpunit script has not been updated for Symfony 4.
Thank you!

Try to comment this 3 lines in your bin/phpunit file :
// $classLoader = require dirname(__DIR__).'/vendor/autoload.php';
// App\Kernel::bootstrapEnv('test');
// $classLoader->unregister();

Related

Symfony 5 doctrine_migrations error on script boot

As far as i can tell, i can't see any other questions that ask this, so here goes:
I've been running the latest Symfony, for a side project, and encountered this error as i was writing the app. Nothing i do now fixes it, not even re-installing symfony, and i have no idea what the problem even is. I am getting the error:
The parameter "doctrine_migrations.dir_name" has a dependency on a
non-existent parameter "kernel.root_dir". Did you mean one of these:
"kernel.project_dir", "kernel.cache_dir", "kernel.logs_dir"?
It seems that you are using the undefined kernel.root_dir variable in your config/packages/doctrine_migrations.yaml config file.
You should replace it by kernel.project_dir:
# config/packages/doctrine_migrations.yaml
doctrine_migrations:
dir_name: '%kernel.project_dir%/src/Migrations'
See: https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html#configuration
Just to document the root cause.
Symfony 5 removed kernel.root_dir parameters. Doctrine Migrations Bundle uses it as default value for dir_name.
It's been discussed. See https://github.com/doctrine/DoctrineMigrationsBundle/issues/305 and https://github.com/doctrine/DoctrineMigrationsBundle/pull/295.
SOLUTION: right now (Symfony 5 and Migrations bundle 2.1.x), you should not delete doctrine_migrations.yaml. Leave it there with a dir_name that does not raise en error.
at this point i am assuming it is a symfony bug, so i will close this question. Thanks for everyone's help!
try
composer remove orm
composer require symfony/orm-pack

DependencyInjection Error - migration Symfony2 to Symfony3 - The argument "x" doesn't exist

I am performing migration from Symfony 2.7 to Symfony 3+. Multiple components and dependencies have been updated.
I managed to fix configurations issues regarding firewall setup, forms and some extenstions (services).
Sorting one problem introduced me to another.
Now each time I run php bin/console I get an error:
[Symfony\Component\DependencyInjection\Exception\OutOfBoundsException]
The argument "3" doesn't exist.
I have tried to run it with -v or -vvv option and I only got:
Exception trace:
() at /xx/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php:242
Symfony\Component\DependencyInjection\Definition->getArgument() at /xx/vendor/sonata-project/core-bundle/DependencyInjection/Compiler/FormFactoryCompilerPass.php:48
Sonata\CoreBundle\DependencyInjection\Compiler\FormFactoryCompilerPass->process() at /xx/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php:139
Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /xx/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:710
Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /xx/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:515
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /xx/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:117
Symfony\Component\HttpKernel\Kernel->boot() at /xx/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:68
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /xx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
Symfony\Component\Console\Application->run() at /xx/bin/console:28
It looks like the issue with container compliation:
http://symfony.com/doc/current/components/dependency_injection/compilation.html
Some old setup passed validation but it is not consumed properly by DependencyInjection Compiler.
I have fallowing questions:
How I can debug it?
What can cause problem like this?
How to fix it?
Thanks!

sf2 : Unknown "asset" function in "#Twig/Exception/exception_full.html.twig" at line 4

I'm using Symfony 3.1
I have this error when I run app_dev.php :
Unknown "asset" function in "#Twig/Exception/exception_full.html.twig"
at line 4.
I already checked my config.yml, and it contains these values :
framework:
assets:
base_path: ~
...
I don't know what to do... I hope someone can help me. Thank you !
EDIT : Problem solved. I had to remove custom twig filters in my config.yml... :)
Try to set:
assets: ~
Issue about same problem
https://github.com/symfony/symfony/issues/17291
Edit:
Please also check that`s symfony assets component was installed.
The symfony/asset component is required, even in 3.0, by the FrameworkBundle
As you can see:
https://github.com/symfony/framework-bundle/blob/master/composer.json
Another way run update symfony to latest version and update all depend

PhpUnit Artisan:call explode expects parameter 2 to be string

I'm trying to test a Laravel 5.1 controller with PhpUnit, for that im creating a class inheriting from TestCase, and using DatabaseTransactions and WithoutMiddleware traits.
Within the class im implementing the setUpBeforeClass method which contains:
Artisan::call('migrate:refresh');
When i try to run the test I get the following error:
1) JugadoresControllerTest::test_Index_trae_arreglo_de_jugadores
ErrorException: explode() expects parameter 2 to be string, array given
/home/vagrant/.composer/vendor/illuminate/support/helpers.php:390
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Support/Arr.php:319
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Support/Collection.php:428
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1548
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:53
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:79
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:74
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Container/Container.php:503
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Console/Command.php:150
/home/vagrant/Code/marcadores/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:259
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Console/Application.php:62
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:152
/home/vagrant/Code/marcadores/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:210
/home/vagrant/Code/marcadores/tests/unit/JugadoresControllerTest.php:34
/home/vagrant/Code/marcadores/tests/unit/JugadoresControllerTest.php:34
/home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:151
/home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:103
Hope anyone can helpme!
I don't know if you ever figured this out, but I ran into a similar problem when trying to run phpunit tests under laravel 5.1. Apparently I had some out-of-date vendor builds on my global composer install (as reverenced by your error: /home/vagrant/.composer/vendor/illuminate/support/helpers.php:390)
All I did was cd to my composer directory:
cd /home/vagrant/.composer and ran composer update
This updated my global composer and everything worked as expected.

Grunt : JASMINE is not supported anymore

i created an angular application with yeoman, when i executed grunt command i got the following error
Running "karma:unit" (karma) task
WARN [config]: JASMINE is not supported anymore.
Please use `frameworks = ["jasmine"];` instead.
WARN [config]: JASMINE_ADAPTER is not supported anymore.
Please use `frameworks = ["jasmine"];` instead.
WARN [config]: LOG_INFO is not supported anymore.
Please use `karma.LOG_INFO` instead.
ERROR [config]: Config file must export a function!
module.exports = function(config) {
config.set({
// your config
});
};
how do i solve this error ?
It's just those two predefined terms (JASMINE and JASMINE_ADAPTER)
that should not be used any more. All you have to do is open the
config file ./config/karma.conf.js and comment out those terms and add
frameworks = ["jasmine"];.
Via Yasuhiro Yoshida
apart from #sheplu's answer, there are additional changes that need to be done in karma.conf.js, you can see it in https://gist.github.com/sivakumar-kailasam/6421378
this gist solves your problem of 'Config file must be a export a function!'
The official docs has these changes as well http://karma-runner.github.io/0.10/config/configuration-file.html

Resources