crazyfactory / php-package-boilerplate

0 stars 0 forks source link

Should we add a test bootstrap file? #7

Open dacgray opened 6 years ago

dacgray commented 6 years ago

In codeception.yml add:

settings: 
    bootstrap: _bootstrap.php 

Add _bootstrap.php to tests/unit/

dacgray commented 6 years ago

It's easier to remove the setting if it is necessary than to search up how to add it if needed.

Alternatively this could be explained in the readme.

cyberhck commented 6 years ago

what would the bootstrap do? because AFAIU, a class under unit test won't be needing anything at all, if needed, we'll have to provide them by ourselves, that's supposed to be mocked out.

IMO: It doesn't make sense to add bootstrap to unit, but for integration tests, we should add one (it's easy to test a lot of things)

dacgray commented 6 years ago

We need it in shop-mailer to include a mocking class.

If we do this in the test file it still is global.

Linting fails with the warning:

 1 | WARNING | A file should declare new symbols (classes, functions,
   |         | constants, etc.) and cause no other side effects, or
   |         | it should execute logic with side effects, but should
   |         | not do both. The first symbol is defined on line 10
   |         | and the first side effect is on line 8.