sebastianbergmann / phpunit

The PHP Unit Testing framework.
https://phpunit.de/
BSD 3-Clause "New" or "Revised" License
19.7k stars 2.2k forks source link

Data provider specified for test is invalid. Unable to locate factory with name [default] #3090

Closed Saibamen closed 6 years ago

Saibamen commented 6 years ago
Q A
PHPUnit version 6.5.8
PHP version 7.2.3
Installation Method Composer

Some data in dataProvider didn't work:

public static function multilangualGuestProvider()
    {
        return [
            [factory(Guest::class)->create()]
        ];
    }

    /**
     * @param $guests
     *
     * @dataProvider multilangualGuestProvider
     */
    public function testEditValidId($guests)
    {
        $guest = factory(Guest::class)->create();

Output:

1) Warning
The data provider specified for GuestTest::testEditValidId is invalid.
Unable to locate factory with name [default] [App\Models\Guest].

But without using DataProvider (public function testEditValidId()) it works correctly.

Composer info | sort:

barryvdh/laravel-debugbar             v3.1.4             PHP Debugbar in...
barryvdh/laravel-ide-helper           v2.4.3             Laravel IDE Hel...
barryvdh/reflection-docblock          v2.0.4
codacy/coverage                       dev-master 4988cd0 Sends PHP test ...
codeclimate/php-test-reporter         dev-master 22b07b8 PHP client for ...
composer/ca-bundle                    1.1.1              Lets you find a...
dnoegel/php-xdg-base-dir              0.1                implementation ...
doctrine/annotations                  v1.6.0             Docblock Annota...
doctrine/cache                        v1.7.1             Caching library...
doctrine/collections                  v1.5.0             Collections Abs...
doctrine/common                       v2.8.1             Common Library ...
doctrine/dbal                         v2.7.1             Database Abstra...
doctrine/inflector                    v1.3.0             Common String M...
doctrine/instantiator                 1.1.0              A small, lightw...
doctrine/lexer                        v1.0.1             Base library fo...
egulias/email-validator               2.1.3              A library for v...
erusev/parsedown                      1.7.1              Parser for Mark...
fideloper/proxy                       3.3.4              Set trusted pro...
filp/whoops                           2.1.14             php error handl...
fzaninotto/faker                      v1.7.1             Faker is a PHP ...
gitonomy/gitlib                       v1.0.3             Library for acc...
guzzle/guzzle                         v3.8.1             Guzzle is a PHP...
hamcrest/hamcrest-php                 v2.0.0             This is the PHP...
jakub-onderka/php-console-color       0.1
jakub-onderka/php-console-highlighter v0.3.2
laravel/browser-kit-testing           v2.0.1             Provides backwa...
laravel/framework                     v5.5.40            The Laravel Fra...
laravel/tinker                        v1.0.5             Powerful REPL f...
laravelcollective/html                v5.5.4             HTML and Form B...
league/flysystem                      1.0.44             Filesystem abst...
maximebf/debugbar                     v1.15.0            Debug bar in th...
mockery/mockery                       1.0                Mockery is a si...
monolog/monolog                       1.23.0             Sends your logs...
mtdowling/cron-expression             v1.2.1             CRON for PHP: C...
myclabs/deep-copy                     1.7.0              Create deep cop...
neronmoon/scriptsdev                  v0.1.2             Scripts-dev beh...
nesbot/carbon                         1.25.0             A simple API ex...
nikic/php-parser                      v3.1.5             A PHP parser wr...
padraic/humbug_get_contents           1.1.2              Secure wrapper ...
padraic/phar-updater                  v1.0.6             A thing to make...
paragonie/random_compat               v2.0.12            PHP 5.x polyfil...
phar-io/manifest                      1.0.1              Component for r...
phar-io/version                       1.0.1              Library for han...
phpdocumentor/reflection-common       1.0.1              Common reflecti...
phpdocumentor/reflection-docblock     4.3.0              With this compo...
phpdocumentor/type-resolver           0.4.0
phpspec/prophecy                      1.7.5              Highly opiniona...
phpunit/php-code-coverage             5.3.2              Library that pr...
phpunit/php-file-iterator             1.4.5              FilterIterator ...
phpunit/php-text-template             1.2.1              Simple template...
phpunit/php-timer                     1.0.9              Utility class f...
phpunit/php-token-stream              2.0.2              Wrapper around ...
phpunit/phpunit-mock-objects          5.0.6              Mock Object lib...
phpunit/phpunit                       6.5.8              The PHP Unit Te...
psr/container                         1.0.0              Common Containe...
psr/log                               1.0.2              Common interfac...
psr/simple-cache                      1.0.1              Common interfac...
psy/psysh                             v0.8.18            An interactive ...
ramsey/uuid                           3.7.3              Formerly rhumsa...
satooshi/php-coveralls                v1.1.0             PHP client libr...
sebastian/code-unit-reverse-lookup    1.0.1              Looks up which ...
sebastian/comparator                  2.1.3              Provides the fu...
sebastian/diff                        2.0.1              Diff implementa...
sebastian/environment                 3.1.0              Provides functi...
sebastian/exporter                    3.1.0              Provides the fu...
sebastian/global-state                2.0.0              Snapshotting of...
sebastian/object-enumerator           3.0.3              Traverses array...
sebastian/object-reflector            1.1.1              Allows reflecti...
sebastian/recursion-context           3.0.0              Provides functi...
sebastian/resource-operations         1.0.0              Provides a list...
sebastian/version                     2.0.1              Library that he...
stevegrunwell/lost-in-translation     v1.0.0             Uncover missing...
swiftmailer/swiftmailer               v6.0.2             Swiftmailer, fr...
symfony/class-loader                  v3.4.8             Symfony ClassLo...
symfony/config                        v4.0.8             Symfony Config ...
symfony/console                       v3.4.8             Symfony Console...
symfony/css-selector                  v3.4.8             Symfony CssSele...
symfony/debug                         v3.4.8             Symfony Debug C...
symfony/dom-crawler                   v3.4.8             Symfony DomCraw...
symfony/event-dispatcher              v4.0.8             Symfony EventDi...
symfony/filesystem                    v4.0.8             Symfony Filesys...
symfony/finder                        v3.4.8             Symfony Finder ...
symfony/http-foundation               v3.4.8             Symfony HttpFou...
symfony/http-kernel                   v3.4.8             Symfony HttpKer...
symfony/polyfill-mbstring             v1.7.0             Symfony polyfil...
symfony/polyfill-php70                v1.7.0             Symfony polyfil...
symfony/process                       v3.4.8             Symfony Process...
symfony/routing                       v3.4.8             Symfony Routing...
symfony/stopwatch                     v4.0.8             Symfony Stopwat...
symfony/thanks                        v1.0.7             Give thanks (in...
symfony/translation                   v4.0.8             Symfony Transla...
symfony/var-dumper                    v3.4.8             Symfony mechani...
symfony/yaml                          v4.0.8             Symfony Yaml Co...
theseer/tokenizer                     1.1.0              A small library...
tijsverkoyen/css-to-inline-styles     2.2.1              CssToInlineStyl...
vlucas/phpdotenv                      v2.4.0             Loads environme...
webmozart/assert                      1.3.0              Assertions to v...
sebastianbergmann commented 6 years ago

Thank you for your report.

Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting.

Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue.

Saibamen commented 6 years ago

"Fixed": https://github.com/laravel/framework/issues/23847