php_thread_test.go 886 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package frankenphp
  2. import (
  3. "net/http"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestInitializeTwoPhpThreadsWithoutRequests(t *testing.T) {
  8. initPHPThreads(2)
  9. assert.Len(t, phpThreads, 2)
  10. assert.NotNil(t, phpThreads[0])
  11. assert.NotNil(t, phpThreads[1])
  12. assert.Nil(t, phpThreads[0].mainRequest)
  13. assert.Nil(t, phpThreads[0].workerRequest)
  14. }
  15. func TestMainRequestIsActiveRequest(t *testing.T) {
  16. mainRequest := &http.Request{}
  17. initPHPThreads(1)
  18. thread := phpThreads[0]
  19. thread.mainRequest = mainRequest
  20. assert.Equal(t, mainRequest, thread.getActiveRequest())
  21. }
  22. func TestWorkerRequestIsActiveRequest(t *testing.T) {
  23. mainRequest := &http.Request{}
  24. workerRequest := &http.Request{}
  25. initPHPThreads(1)
  26. thread := phpThreads[0]
  27. thread.mainRequest = mainRequest
  28. thread.workerRequest = workerRequest
  29. assert.Equal(t, workerRequest, thread.getActiveRequest())
  30. }