majacirkova's avatar

I want to test class with acceptance testing and gets me this error: Fatal error: Call to a member function connection() on a non-object in C:\wamp\www\project\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 3146

Hello guys , I want to test class with acceptance testing , and when i execute this line: php codecept.phar run acceptance PROBACept.php

This is code for PROBACept.php class :

<?php
require '_bootstrap.php';
$I = new AcceptanceTester($scenario);
$I->wantTo('perform actions and see result');

Also in my _bootstrap.php class this is code:

<?php
require 'C:\wamp\www\project\vendor\autoload.php';

// Here you can initialize variables that will be available to your tests
$ccc = \App\Messages\Models\Message::all();

So when i run test gets me this error:

Codeception PHP Testing Framework v2.1.2
Powered by PHPUnit 4.8.2 by Sebastian Bergmann and contributors.

Fatal error: Call to a member function connection() on a non-object in C:\wamp\www\project\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 3146

Call Stack:
    0.0122     673552   1. {main}() C:\wamp\www\project\codecept.phar:0
    0.0225    1844640   2. require_once('phar://C:/wamp/www/project/codecept.phar/codecept') C:\wamp\www\project\codecept.phar:7
    0.0412    4317968   3. Symfony\Component\Console\Application->run() phar://C:/wamp/www/project/codecept.phar/codecept:34
    0.0447    4707936   4. Symfony\Component\Console\Application->doRun() phar://C:/wamp/www/project/codecept.phar/vendor/symfony/console/Application.php:126
    0.0450    4708808   5. Symfony\Component\Console\Application->doRunCommand() phar://C:/wamp/www/project/codecept.phar/vendor/symfony/console/Application.php:195
    0.0450    4709264   6. Symfony\Component\Console\Command\Command->run() phar://C:/wamp/www/project/codecept.phar/vendor/symfony/console/Application.php:878
    0.0456    4714400   7. Codeception\Command\Run->execute() phar://C:/wamp/www/project/codecept.phar/vendor/symfony/console/Command/Command.php:259
    0.1193    9888208   8. Codeception\Codecept->run() phar://C:/wamp/www/project/codecept.phar/src/Codeception/Command/Run.php:184
    0.1240    9894088   9. Codeception\Codecept->runSuite() phar://C:/wamp/www/project/codecept.phar/src/Codeception/Codecept.php:172
    3.4735   11988856  10. Codeception\SuiteManager->run() phar://C:/wamp/www/project/codecept.phar/src/Codeception/Codecept.php:200
    3.4735   11989240  11. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() phar://C:/wamp/www/project/codecept.phar/src/Codeception/SuiteManager.php:148
    3.4736   11989848  12. Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() phar://C:/wamp/www/project/codecept.phar/vendor/symfony/event-dispatcher/EventDispatcher.php:53
    3.4737   11992008  13. call_user_func:{phar://C:/wamp/www/project/codecept.phar/vendor/symfony/event-dispatcher/EventDispatcher.php:164}() phar://C:/wamp/www/project/codecept.phar/vendor/symfony/event-dispatcher/EventDispatcher.php:164
    3.4737   11992096  14. Codeception\Subscriber\Bootstrap->loadBootstrap() phar://C:/wamp/www/project/codecept.phar/vendor/symfony/event-dispatcher/EventDispatcher.php:164
    3.4740   11994272  15. require_once('C:\wamp\www\project\tests\acceptance\_bootstrap.php') phar://C:/wamp/www/project/codecept.phar/src/Codeception/Subscriber/Bootstrap.php:34
    3.4988   14545520  16. Illuminate\Database\Eloquent\Model::all() C:\wamp\www\project\tests\acceptance\_bootstrap.php:5
    3.5000   14598440  17. Illuminate\Database\Eloquent\Model->newQuery() C:\wamp\www\project\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:662
    3.5000   14598544  18. Illuminate\Database\Eloquent\Model->newQueryWithoutScopes() C:\wamp\www\project\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1802
    3.5000   14598616  19. Illuminate\Database\Eloquent\Model->newBaseQueryBuilder() C:\wamp\www\project\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1828
    3.5000   14598664  20. Illuminate\Database\Eloquent\Model->getConnection() C:\wamp\www\project\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1887
    3.5000   14598712  21. Illuminate\Database\Eloquent\Model::resolveConnection() C:\wamp\www\project\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:3112




FATAL ERROR. TESTS NOT FINISHED.
Call to a member function connection() on a non-object
in C:\wamp\www\project\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:3146

Thanks a lot.

0 likes
1 reply

Please or to participate in this conversation.