0

I want to use the DB object in a set of Codeception tests I am running inside Laravel. Specifically, I want to do this as part of the _before of the test:

DB::table('name')->truncate();

At the beginning on my TestCest.php file I have this:

use \AcceptanceTester;
namespace App\Modules\Admin\Controllers;
use DB;

However, the DB object wont let me use it - I get a message

Failed to login

when I run the codecept tests.

I am certain I am missing something basic about setting up the DB object, but I cannot figure it out.

1

1 Answer 1

1

This is how I solved it.

In tests/_bootstrap.php I placed the following code

// This is global bootstrap for autoloading
require __DIR__.'/../../bootstrap/autoload.php';
require __DIR__.'/../../bootstrap/start.php';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.