I am testing my laravel application using laravel dusk but the problem is that I am unable to use assertDatabaseHasfunction. When I run php artisan dusk command I got this error:
PHP Fatal error: Class 'PHPUnit_Framework_Constraint' not found in
vendor\laravel\framework\src\Illuminate\Foundation\Testing\Constraints\HasIn
Database.php on line 8
Here is my code:
$this->assertDatabaseHas('teams', [
'name' => $data['team_name'],
]);
Please check your version of phpunit:
phpunit --version
If you are are running v6 you might have trouble because it expects a namespaced class. In that case you either have to switch to an older version of phpunit, e.g. locally installed for your project and then run like this:
php vendor/bin/phpunit --version
or you might have to update your Laravel-project, which is probably more work as you might have to change parts of your code.
Related
I'm trying to run unit tests using PHPUnit in a CI/CD setup. The problem is that I'm getting the following error:
PHPUnit testing framework version 6 or greater is required when running on PHP 7.0 or greater. Run the command 'composer run-script drupal-phpunit-upgrade' in order to fix this.
But I have the correct version of PHPUnit with PHP 7.2.14. I tried running the suggested command but nothing works.
vendor/bin/phpunit --version
PHPUnit 6.5.13 by Sebastian Bergmann and contributors.
Hope someone with experience has an idea.
Regards.
Probably version of PHP for cli and cgi could be different. As you are running phpunit from console, try also run php -v to find out which version is used for console.
Also, you error message suggest you:
Run the command 'composer run-script drupal-phpunit-upgrade' in order to fix this.
Probably that will fix your issue
I found out what the issue was... It seems that there was a previous installation of PHPUnit, with a version of 4.5, somewhere on the server outside my Drupal project. I manually updated that version to and now it works.
I have a bunch of Phinx seeds which used to run fine
php vendor/bin/phinx seed:run
My seeds are located in var/www/html/db/seeds folder
I recently upgraded my VM to php 7.0 (Also upgraded to 16.04 LTS box), now I get the following output & error when I try to run phinx seeds:
ubuntu#ubuntu-xenial:/var/www/html$ sudo vendor/bin/phinx seed:run
Phinx by Rob Morgan - https://phinx.org. version 0.5.4
using config file ./phinx.yml
using config parser yaml
using migration path /var/www/html/db/migrations
using seed path /var/www/html/db/seeds
warning no environment specified, defaulting to: development
using adapter mysql
using database closecall
[InvalidArgumentException]
The seed class "" does not exist
To reiterate, seeds were running fine, upgraded to php 7.0 and now they're not.
Migrations still run completely fine, however.
I've removed all seeds bar one:
<?php
use Phinx\Seed\AbstractSeed;
class CategorySeeder extends AbstractSeed
{
public function run()
{
$data = array(
array(
'name' => 'Confined Spaces'
)
);
}
}
To debug with, still gives the same error.
Try:
php vendor/bin/phinx seed:run -s CategorySeeder
for a Laravel 5.1 project I am trying to setup a beta version of this project on a shared hoster. Everything works fine except for artisan.
I do login through ssh and move to the Laravel project directory and the not matter what php artisan command I use I get following error:
PHP Fatal error: Class 'Illuminate\Queue\ConsoleServiceProvider' not found in /www/htdocs///vendor/laravel/framework/src/Illuminate/Foundation/Application.php on line 543
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Illuminate\Queue\ConsoleServiceProvider' not found
Any ideas on what could be wrong?
The autoloading should work correctly as the project works fine using the browser.
The steps by #manix helped me a lot:
Delete file bootstrap/cache/services.json
call composer update
run php artisan optimize
When i try to show list of available routes artisan returns the following error:
$ php artisan route:list
[ReflectionException]
Class API does not exist
It worked a while ago but now i can't get it to work.
Laravel version is:
$ php artisan -V
Laravel Framework version 5.1.10 (LTS)
Is it possible to debug somehow this error?
You can find what's wrong in the storage/logs/laravel-YYYY-MM-DD.log file.
Check it, resolve and run artisan again.
What's your php version ? I think, if you are under php5.5, then change the shell.
I am trying to execute an migration in laravel, I ran the following command:
php artisan migrate
and php throw me:
PHP fatal error: Class 'schema' not found in C://.... on line 14
I am using php 5.4.17 and Laravel 4.1.*
The Composer autoloader is case sensitive, so you'll need to use Schema::... functions in your migrations, not schema::... ones.