1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 14:14:04 +00:00
tenancy/CONTRIBUTING.md
Samuel Štancl eecf6f21c8
Cache prefixing logic rewrite, session scoping improvements, tests refactor (#43)
* Run cache tests on all supported drivers

* update ci healthcheck for memcached

* remove memcached healthcheck

* fix typos in test comments, expand internal.md [ci skip]

* add empty line [ci skip]

* switch to using $store->setPrefix()

* add dynamodb

* refactor try-finally to try-catch

* remove unnecessary clearResolvedInstances() call

* add dual Cache:: and cache() assertions

* add apc

* Flush APCu cache in test setup

* Revert "add dual Cache:: and cache() assertions"

This reverts commit a0bab162fbe2dd0d25e7056ceca4fb7ce54efc77.

* phpstan fix

* Add logic for scoping 'file' disks to FilesystemTenancyBootstrapper

* minor changes, add todos

* refactor how the session.connection is used in the DB session bootstrapper

* add session forgery prevention logic to the db session bootstrapper

* only use the fs bootstrapper for file disk in 'cache data is separated' dataset

* minor session scoping test changes

* Add session scoping logic to FilesystemTenancyBootstrapper, correctly update disk roots even with storage_path_tenancy disabled

* Fix code style (php-cs-fixer)

* update docblock

* make not-null check more explicit

* separate bootstrapper tests, fix swapped test names for two tests

* refactor cache bootstrapper tests

* resolve global cache todo

* expand tests: session separation tests, more filesystem separation assertions; change prefix_base-type config keys to templates/formats

* add apc session scoping test, various session separation bugfixes

* phpstan + minor logic fixes

* prefix_format -> prefix

* fix database session separation test

* revert composer.json changes, update laravel dependencies to expected next release

* only run session scoping logic in cache bootstrapper for redis, memcached, dynamodb, apc; update gitattributes

* tenancy.central_domains -> tenancy.identification.central_domains

* db session separation test: add datasets

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2024-04-09 20:40:27 +02:00

1.9 KiB

Contributing

Code style

php-cs-fixer will fix code style violations in your pull requests.

To run it locally, use composer cs.

Running tests

Run composer docker-up to start the containers. Then run composer test to run the tests.

If you need to pass additional flags to phpunit, use composer test --, e.g. composer test -- --filter="foo". Alternatively, you can use ./test --filter="foo"

If you want to run a specific test (or test file), you can also use ./t 'name of the test'. This is equivalent to ./test --no-coverage --filter 'name of the test' (--no-coverage speeds up the execution time).

When you're done testing, run composer docker-down to shut down the containers.

Debugging tests

If you're developing some feature and you encounter SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry errors, it's likely that some PHP errors were thrown in past test runs and prevented the test cleanup from running properly.

To fix this, simply delete the database memory by shutting down containers and starting them again: composer docker-down && composer docker-up.

Same thing for SQLSTATE[HY000]: General error: 1615 Prepared statement needs to be re-prepared.

Docker on M1

Run composer docker-m1 to symlink docker-compose-m1.override.yml to docker-compose.override.yml. This will reconfigure a few services in the docker compose config to be compatible with M1.

Coverage reports

To run tests and generate coverage reports, use composer test-full.

To view the coverage reports in your browser, use composer coverage (works on macOS; on other operating systems you can manually open coverage/phpunit/html/index.html in your browser).

Rebuilding containers

If you need to rebuild the container for any reason (e.g. a change in Dockerfile), you can use composer docker-rebuild.

PHPStan

Use composer phpstan to run our phpstan suite.