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

Eloquent: Parameter must be an array or an object that implements Countable #19380

Closed
alihamze opened this issue May 28, 2017 · 0 comments

Comments

@alihamze
Copy link
Contributor

commented May 28, 2017

  • Laravel Version: 5.4.23
  • PHP Version: 7.2.0-dev (cli) (built: May 27 2017 22:53:52)
  • Database Driver & Version: MySQL

Description:

Tests using a factory to create a model fail on PHP Nightly builds. I am running my tests on TravisCI and they run fine on PHP 7.0 & PHP 7.1 but fail on PHP Nightly on this line with the error ErrorException: count(): Parameter must be an array or an object that implements Countable.

Full Trace:

ErrorException: count(): Parameter must be an array or an object that implements Countable
/home/travis/build/alihamze/ProjectName/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:928
/home/travis/build/alihamze/ProjectName/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:906
/home/travis/build/alihamze/ProjectName/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1151
/home/travis/build/alihamze/ProjectName/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1247
/home/travis/build/alihamze/ProjectName/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:146
/home/travis/build/alihamze/ProjectName/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:149
/home/travis/build/alihamze/ProjectName/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:129
/home/travis/build/alihamze/ProjectName/tests/Unit/UserTest.php:15

Line 15 of UserTest.php is

$company = factory(\App\Company::class)->create();

The Company factory is defined as follows:

$factory->define(App\Company::class, function (Faker\Generator $faker) {
		return [
			'name'                => $faker->company,
			'billing_customer_id' => str_random(10),
		];
	});

Steps To Reproduce:

  1. Run a test that creates a model using it's factory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.