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

BadMethodCallException: Call to undefined method Illuminate\Database\Query\Builder::user() #56

Closed
sebestenyb opened this issue May 29, 2016 · 1 comment

Comments

@sebestenyb
Copy link

Hi there,

Using the package causing the following error in unit tests:

1) ExampleTest::testBasicExample
BadMethodCallException: Call to undefined method Illuminate\Database\Query\Builder::user()

/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2343
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1422
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:3506
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:692
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php:184
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:693
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:664
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:644
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:322
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php:181
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php:142
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:675
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:644
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:322
/Users/balazssebesteny/Sites/laravel-auditing-test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:646
/Users/balazssebesteny/Sites/laravel-auditing-test/tests/ExampleTest.php:30

See my config in #55

The test I'm using:

<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

use App\User;
use App\Test;

use OwenIt\Auditing\Log;

class ExampleTest extends TestCase
{

    use DatabaseMigrations;

    /**
     * A basic functional test example.
     *
     * @return void
     */
    public function testBasicExample()
    {

        $user = factory(User::class)->create();
        $this->actingAs($user);
        $test = factory(Test::class)->create();
        dump(Log::all()->toArray());
        $this->assertTrue(true);
    }
}


The issue can be worked around by removing the eager loading of the user and owner properties from the the Log class.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants