Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run phpunit tests with MySQL #2597

Closed
geraintdong opened this issue May 21, 2020 · 1 comment
Closed

Cannot run phpunit tests with MySQL #2597

geraintdong opened this issue May 21, 2020 · 1 comment

Comments

@geraintdong
Copy link
Contributor

Description:

MySQL tables are not visible when running phpunit tests via docker-compose exec workspace .... or docker-compose run --rm workspace ....

Expected Behavior:

Context information:

Output of git rev-parse HEAD

4f274e3d86e1a209161790514f11acd4eef7bde9

Output of docker version

Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:21:11 2020
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker-compose version

docker-compose version 1.25.5, build 8a1c60f6
docker-py version: 4.1.0
CPython version: 3.7.5
OpenSSL version: OpenSSL 1.1.1f  31 Mar 2020

System info: Mac, Windows or Linux. Include which disto/version

macOS Catalina 10.15.4 (19E287)

Steps to reproduce the issue:

  1. Run docker-compose exec workspace /var/www/app/vendor/bin/phpunit '/path/to/my/file.php'
  2. Run docker-compose exec workspace bash then app/vendor/bin/phpunit '/path/to/my/file.php'

Actual result

After 1st step (weird result)

PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

EEE                                                                 3 / 3 (100%)

Time: 6.37 seconds, Memory: 40.50 MB

There were 3 errors:

1) path/to/my/file.php::a_test_case
Illuminate\Database\QueryException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'homestead.logins' doesn't exist (SQL: select `users`.*, (select `id` from `logins` where `user_id` = `users`.`id` order by `created_at` desc limit 1) as `last_login_id` from `users` where `is_admin` = 1)

........................
........................
........................

ERRORS!
Tests: 3, Assertions: 0, Errors: 3.

After 2nd step (expected behavior)

PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

F.F                                                                 3 / 3 (100%)

Time: 4.33 seconds, Memory: 46.50 MB

There were 2 failures:

1) Tests\Unit\HasWalletTest::it_should_have_seller_pending_balance
Failed asserting that '50.0' matches expected 36.5.

/var/www/app/tests/Unit/HasWalletTest.php:26

2) Tests\Unit\HasWalletTest::it_should_have_correct_pending_balance_of_seller_with_bought_wager
Failed asserting that '1050.0' matches expected 1036.5.

/var/www/app/tests/Unit/HasWalletTest.php:74
@geraintdong
Copy link
Contributor Author

I misconfigured my docker, reinstalling does help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant