使用sqlite进行的Laravel测试不';不创建用户表

使用sqlite进行的Laravel测试不';不创建用户表,laravel,sqlite,testing,Laravel,Sqlite,Testing,我对拉威尔的考试有问题。 我不知道为什么不创建users表,因为所有其他表都可以 用于测试的数据库是在以下内存中运行的Sqlite: 我的PHP单元配置文件(phpunit.xml) tests/Unit/RoleTest.php <?php namespace Tests\Unit; use Tests\TestCase; use Illuminate\Foundation\Testing\DatabaseMigrations; use Ill

我对拉威尔的考试有问题。 我不知道为什么不创建users表,因为所有其他表都可以

用于测试的数据库是在以下内存中运行的Sqlite:

我的PHP单元配置文件(phpunit.xml)

tests/Unit/RoleTest.php

    <?php

    namespace Tests\Unit;

    use Tests\TestCase;
    use Illuminate\Foundation\Testing\DatabaseMigrations;
    use Illuminate\Foundation\Testing\DatabaseTransactions;

    class RoleTest extends TestCase
    {

        use DatabaseMigrations;

        protected $role;
        protected $permission;


        public function setUp() {

            parent::setUp();
            $this->role = factory('App\Model\ACL\Role')->create();
            $this->permission = factory('App\Model\ACL\Permission')->create();
        }


        /** @test */
        public function a_role_has_permissions ()
        {

            $this->assertInstanceOf(
        'Illuminate\Database\Eloquent\Collection', $this->role->permissions
            );
        }

        /** @test */
        public function a_role_gives_permission_to ()
        {
            $permission = $this->role->givePermissionTo($this->permission);
            $this->assertInstanceOf('App\Model\ACL\Permission', $permission);

        }


        /** @test */
        public function a_role_has_permission ()
        {
            $permission = $this->role->givePermissionTo($this->permission);
            $this->assertTrue($this->role->hasPermission($this->permission));
        }


        /** @test */
        public function a_role_has_many_users ()
        {

            $this->assertInstanceOf(
                'Illuminate\Database\Eloquent\Collection', $this->role->users
            );

        }
    }

出于某种原因,我不知道为什么,我错过了迁移中的“s”,即创建用户表

但我是如何在代码中丢失“s”的:O 哈哈

这是一个愚蠢的错误

      use Illuminate\Support\Facades\Schema;
      use Illuminate\Database\Schema\Blueprint;
      use Illuminate\Database\Migrations\Migration;

      class CreateUsersTable extends Migration
      {
          /**
           * Run the migrations.
           *
           * @return void
           */
          public function up()
          {
              Schema::create('user', function (Blueprint $table) {

                  $table->increments('id');
                  $table->integer('status')->nullable()->default(1);
                  $table->string('name');
                  $table->string('email')->unique();
                  $table->string('password');
                  $table->string('sysid', 20)->nullable();
                  $table->string('avatar')->nullable();
                  $table->string('cpf', 18)->nullable();

                  $table->rememberToken();
                  $table->timestamps();
              });
          }

          /**
           * Reverse the migrations.
           *
           * @return void
           */
          public function down()
          {
              Schema::dropIfExists('user');
          }
      }
    <?php

    namespace Tests\Unit;

    use Tests\TestCase;
    use Illuminate\Foundation\Testing\DatabaseMigrations;
    use Illuminate\Foundation\Testing\DatabaseTransactions;

    class RoleTest extends TestCase
    {

        use DatabaseMigrations;

        protected $role;
        protected $permission;


        public function setUp() {

            parent::setUp();
            $this->role = factory('App\Model\ACL\Role')->create();
            $this->permission = factory('App\Model\ACL\Permission')->create();
        }


        /** @test */
        public function a_role_has_permissions ()
        {

            $this->assertInstanceOf(
        'Illuminate\Database\Eloquent\Collection', $this->role->permissions
            );
        }

        /** @test */
        public function a_role_gives_permission_to ()
        {
            $permission = $this->role->givePermissionTo($this->permission);
            $this->assertInstanceOf('App\Model\ACL\Permission', $permission);

        }


        /** @test */
        public function a_role_has_permission ()
        {
            $permission = $this->role->givePermissionTo($this->permission);
            $this->assertTrue($this->role->hasPermission($this->permission));
        }


        /** @test */
        public function a_role_has_many_users ()
        {

            $this->assertInstanceOf(
                'Illuminate\Database\Eloquent\Collection', $this->role->users
            );

        }
    }
    1) Tests\Unit\RoleTest::a_role_has_many_users
    Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table: users (SQL: select "users".*, "role_user"."role_id" as "pivot_role_id", "role_user"."user_id" as "pivot_user_id" from "users" inner join "role_user" on "users"."id" = "role_user"."user_id" where "role_user"."role_id" = 1)


    Caused by
    PDOException: SQLSTATE[HY000]: General error: 1 no such table: users