github.com/goravel/framework@v1.13.9/testing/test_case_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/suite"
     7  
     8  	consolemocks "github.com/goravel/framework/contracts/console/mocks"
     9  )
    10  
    11  type TestCaseSuite struct {
    12  	suite.Suite
    13  	mockArtisan *consolemocks.Artisan
    14  	testCase    *TestCase
    15  }
    16  
    17  func TestTestCaseSuite(t *testing.T) {
    18  	suite.Run(t, new(TestCaseSuite))
    19  }
    20  
    21  // SetupTest will run before each test in the suite.
    22  func (s *TestCaseSuite) SetupTest() {
    23  	s.mockArtisan = consolemocks.NewArtisan(s.T())
    24  	s.testCase = &TestCase{}
    25  	artisanFacades = s.mockArtisan
    26  }
    27  
    28  func (s *TestCaseSuite) TestSeed() {
    29  	s.mockArtisan.On("Call", "db:seed").Once()
    30  	s.testCase.Seed()
    31  
    32  	s.mockArtisan.On("Call", "db:seed --seeder mock").Once()
    33  	s.testCase.Seed(&MockSeeder{})
    34  }
    35  
    36  func (s *TestCaseSuite) TestRefreshDatabase() {
    37  	s.mockArtisan.On("Call", "migrate:refresh").Once()
    38  	s.testCase.RefreshDatabase()
    39  }
    40  
    41  type MockSeeder struct{}
    42  
    43  func (m *MockSeeder) Signature() string {
    44  	return "mock"
    45  }
    46  
    47  func (m *MockSeeder) Run() error {
    48  	return nil
    49  }