많은 것을 시도했지만이 문제에 붙어 있습니다. 내 응용 프로그램에서 테스트를 시도합니다 (Laravel5.3 사용). 개발을위한 My DB는 MySQL이지만, sqlite "메모리"데이터베이스로 테스트하고 싶습니다.Laravel PhpUnit 해당 테이블 없음
내가이 오류를 가지고 테스트를 시작하려고 할 때마다 : 일반 오류 : 1 그러한 테이블 : groupe_user는
그것은 sqlite가 데이터베이스에 테이블을 이동하지 않는 것 같다. 내가 뭘 잘못하고 있는지 보지 않습니다.
누군가 내게 도움이된다면 testcase 파일과 마이그레이션 파일을 넣어두면 좋을 것입니다.
TestCase.php :
<?php
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
{
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$unitTesting = true;
$testEnvironment = 'testing';
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
return $app;
}
public function setUp()
{
parent::setUp();
$this->createApplication();
$this->prepareForTests();
}
private function prepareForTests()
{
Artisan::call('migrate');
Artisan::call('db:seed');
}
public function tearDown()
{
parent::tearDown();
}
}
그리고 피벗 테이블로 마이그레이션 파일 :
class CreateGroupesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('groupes', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 100);
$table->timestamps();
});
//Création de la table pivot groupe_user avec les cléfs étrangères
Schema::create('groupe_user', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->index()->nullable();
$table->integer('groupe_id')->unsigned()->index()->nullable();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('groupe_id')->references('id')->on('groupes');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('groupes');
}
} 시청
감사합니다.
편집 : 내 AuthTest.php
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\User;
class AuthTest extends TestCase
{
use DatabaseMigrations;
public function testAuthLogin()
{
$user = factory(App\User::class)->create();
//Test du login
$this->visit('/login')
->see('Se Connecter')
->type('[email protected]', 'email')
->type('lorem85', 'password')
->press('Se connecter');
}
당신은'사용 DatabaseMigrations를 추가해야합니다;'당신의 시험을 –
https://laravel.com/docs/5.3/database-testing 워드 프로세서에 따라 난 그냥 쇼의 시작을 위해 내 게시물을 편집 할거야 내 파일 중 하나. – Exarkun