1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 14:34:04 +00:00
Commit graph

88 commits

Author SHA1 Message Date
43d821ca49 docker: base Dockerfile on php images, misc improvements 2024-10-11 21:29:54 +02:00
a52efe5cf0 wip broadcasting test fixes 2024-10-03 21:34:05 +02:00
232f3ceb4e update prompts dependency 2024-09-27 21:13:20 +02:00
Samuel Štancl
7317d2638a
Postgres RLS + permission controlled database managers (#33)
This PR adds Postgres RLS (trait manager + table manager approach) and permission controlled managers for PostgreSQL.

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2024-04-24 22:32:49 +02:00
lukinovec
6e67ddf7a5
Resolve test to-dos (#45)
* Only retrieve domains if the relationship and the domains table exist (DomianTenantResolver)

* Resolve todo, add other todos

* Use constructor promotion in DeleteDomains

* Fix imports + domain deletion test

* Confirm that turning on resolver caching doesn't break the tests

* Fix Tenant model imports

* Fix code style (php-cs-fixer)

* remove runtime schema check

* temp: enable resolver cache

* make 'autoincrement ids are supported' pass

* disable resolver cache

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2024-04-18 00:22:03 +02:00
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
943b960718 lower laravel/prompts minimal version 2024-04-09 16:16:03 +02:00
489fbb9402 add prompts to tenant:tinker 2024-04-06 01:22:14 +02:00
6f4b9dadf1 add tenant:tinker command 2024-04-03 19:46:27 +02:00
711352db38 make MigrateFreshOverride compatible with Laravel 11.2 2024-04-02 20:19:15 +02:00
Samuel Štancl
a41ad69023
Filesystem logic refactor, improved defaults for cache tenancy (#42)
* refactor FilesystemTenancyBootstrapper

* clean up tests and improve coverage

* minor maintenance mode changes

* Improve tenants:migrate --skip-failing logic

* make tenants:migrate output consistently formatted

* minor RootUrlBootstrapper + misc changes

* cache bootstrapper-related improvements

* Fix code style (php-cs-fixer)

* misc refactor

* Fix code style (php-cs-fixer)

* add %original_storage_path% to fs bootstrapper, improve default config for cache

* rename method

* inject concrete implementations where needed instead of abstracts

* Fix code style (php-cs-fixer)

* refactor DealsWithTenantSymlinks

* remove obsolete phpstan ignore

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2024-04-02 04:26:10 +02:00
Samuel Štancl
32a063b834
Laravel 11 support + Docker improvements (#29)
* wip

* bump jobpipeline dependency

* bump pest dependency

* fix composer.json syntax

* minor changes to docker setup

* more docker changes

* compact pest output, remove unnecessary env vars from composer.json

* minor pest tweaks

* mssql fix

* try enabling colors in CI

* try setting --columns=max for pest in CI

* try setting columns using env var instead of --columns in CI

* Revert "try setting columns using env var instead of --columns in CI"

This reverts commit eb3c177aefa97b0a3140d7f0e89c5012a854ff42.

* replace --compact with --no-progress

* try setting a hardcoded columns value in CI

* remove --columns (doesn't work), add back --compact

* try setting COLUMNS to a hardcoded value in CI

* remove alternative env syntax from CI

* fix PrefixCacheBootstrapperTest on L11, skip on L10

* add one more skip() call

* fix validate.yml

* Simplify schema dump, skip dump-related tests in L10

* Rename 'dump' table to 'example'

* Bring schema dump-related tests together, add comments

* Merge schema path-related tests into one, add comments

* Rename dataset parameter

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
2024-02-18 00:18:31 +01:00
a5800452ac update larastan dependency 2023-12-12 10:53:23 +01:00
lukinovec
e25e7b7961
Single-domain tenants (#16)
* Add SingleDomainTenant

* Add logic for single domain tenants

* Test that the single domain approach works (wip)

* Fix code style (php-cs-fixer)

* Simplify SubdomainTest tests

* Add single domain tenant conditions to DomainTenantResolver

* Test single domain tenants in resolver test

* Fix test name typo

* Improve runUsingBothDomainApproaches()

* Delete extra tenancy()->end()

* Test early identification with both domain approaches

* Test that things work with both domain approaches in the rest of the tests

* Fix falsely passing test

* Fix PHPStan errors

* Change SingleDomainTenant to a contract, add SingleDomainTenant test model

* Fix TenantList domainsCLI()

* Improve setCurrentDomain() check

* Fix code style (php-cs-fixer)

* Add annotation

* Revert getCustomColumns() change

* Add comments

* Use the domain returned by the closure in runUsingBoth..()

* Delete `migrate` from test

* Improve test names

* Use variable instead of repeating the same string multiple times

* Update comment

* Add comment

* Clean up PreventAccess test

* Don't assign domain to a single-use variable

* Update comments

* Uncomment datasets

* Add todo

* Fix user impersonation test

* Don't specify tenant key when creating tenant in runUsingBoth..()

* Improve universal route test

* Improve `runUsingBothDomainApproaches()`

* Add tests specific to single domain tenants

* Get rid of the runUsingBothDomainApproaches method

* Add test file specific for the single domain tenant feature

* Rename test

* Make getCustomColumns() function static

* Positiopn datasets differently

* Fix early id test

* Add prevent MW to route MW in test

* Fix single domain tenant tests

* Delete SingleDomainTenantTest (CI testing)

* Add the test file back

* TUrn APP_DEBUG on temporarily

* Turn debug off

* Try creating tenant with non-unique domain (CI testing)

* dd duplicate tenant records

* Revert testing change

* Make SingleDomainTenant not extend base tenant (VirtualColumn issues)

* Fix early id test

* add todo

* Use dev-master stancl/virtualcolumn

* Make SingleDomainTenant extend the tenant base model

* remove todo

* Clean up EarlyIdentificationTest changes

* Finish test file cleanup

* Fix test

* improve test

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-11-08 11:38:26 +01:00
Abrar Ahmad
bd9bbe8b41
Cache prefix mode for separating tenant caches (#1014)
* cache prefix

* prefix cache bootstrapper and tests

* remove comment

* DI app

* cache prefix base from config

* Create PrefixCacheBootstrapperTest.php

* remove `null` check

* fix phpstan error

* Update PrefixCacheTenancyBootstrapper.php

* Update PrefixCacheBootstrapperTest.php

* add comments

* Update PrefixCacheTenancyBootstrapper.php

* Update PrefixCacheBootstrapperTest.php

* Update config.php

* test names grammar

* user `getTenantKey` method

* assert tenants' data is accessible using the prefix from the central context

* remove unused line

* use proper DI

* build prefix using original prefix

* fix prefix test according to prefix changes

* fix test

* CacheManager dependency injection test

* CacheService class as singleton

* introduce second tenant in test

* use Repository in service class DI

* Update CacheAction.php

* Rename CacheAction to CacheService

* Update prefix bootstrapper and test (`setStore()` in CacheManager and Repository needed)

* Add macro

* Fix code style (php-cs-fixer)

* Simplify cache store refreshing

* Make Tenancy override CacheManager

* Update CacheManager, add refreshStore()

* Fix code style (php-cs-fixer)

* Uncomment cache tagging

* Revert condition in CacheManager to avoid excessive nesting

* Move `Cache::macro()` to a slightly more appropriate place

* Fix code style (php-cs-fixer)

* Use better class for the macro

* Toggle cache tags

* Make CacheManager::$addTags default to `true`

* Add changes to PR to Laravel

* Fix code style (php-cs-fixer)

* Revert changes, add comment

* Add test

* Make `$cache` non-nullable

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* Add and test `nonTenantCacheDrivers`

* Add nonTenantCacheDrivers check

* Test that the prefix stays the same

* Change nonTenantCacheDrivers to tenantCacheStores

* Remove redundant CacheManager extend() call

* Make 'redis' the only tenant cache store in beforeEach, test that tenantCacheStores works

* Remove unused import, change word

* Make CacheService a singleton in a test

* Update test name

* Remove group('prefix')

* Rename CacheManagerService

* Improve specific cache store in a service test

* Improve comment

* Improve tests

* Use my Laravel fork

* Fix code style (php-cs-fixer)

* Downgrade Laravel

* Upgrade Laravel

* Hint Repository implementation instead of contract

* Fix types

* Fix code style (php-cs-fixer)

* Fix test

* Use Laravel fork in ci.yml

* use dev-master before our changes are released in L10

* remove laravel fork from repositories

* use 10.x-dev instead of master

* remove L9 support

* 10.x-dev (fix conflict resolution)

* use the laravel version from the ci matrix for the phpstan job as well

* Revert "use the laravel version from the ci matrix for the phpstan job as well"

This reverts commit 5f3079d2ff.

* Test that non-default stores get prefixed too

* Use new Laravel release, remove L9 support

* Complete L9 support removal

* Specify 10.1.1 as the minimal Laravel version in ci.yml

* Use 10.x-dev

* Prefix all cache stores specified in `$tenantCacheStores`

* Update Laravel

* Use tmpfs in docker-compose

* Add customizing cache store prefixes

* Test cache prefixing customization

* Fix code style (php-cs-fixer)

* Update ci.yml

* Delete tmpfs from docker-compose.yml (there were no benefits)

* Use default prefix generator inline, delete the 'default' key logic

* Fix original prefix logic

* Update tests

* Delete CacheTenancyBootstrapper

* Reset static properties in afterEach

* Use `$this->config` instead of `config()`

* Disable cache tagging by default, add CacheTagBootstrapper

* Fix code style (php-cs-fixer)

* Rename bootstrapper

* Improve CacheManager

* Move logic from separate method to __call

* Make original prefixes customizable

* Add info in comment

* Add defaultPrefix property

* Use `$this->app` instead of `app()`

* Rename bootstrapper

* Fix code style (php-cs-fixer)

* Use a single original prefix

* Update prefix generator logic + tests

* Correct `$addTags` reset in a test

* Update cache tests so that both prefixing and tagging is covered

* Simplify cache tests

* Delete afterEach

* Small testing improvements

* Set `cache.default` in beforeEach

* Update cache prefixing and tests

* Add assertion

* Refactor assertion

* Refactor assertions

* Delete TTL from cache put calls

* Add re-initialization cache assertion

* Assert that cache is null from the beginning

* Merge the tenantCacheStores tests

* Fix formatting

* Improve test name

* Improve tests

* Add cache manager config key

* Fix code style (php-cs-fixer)

* Update defaulting test

* Add todo

* Update comments

* Extract duplicate assertions into a closure

* Update comment

* Add assertions + comment

* Delete redundant config put calls

* Use `tenancy.cache.manager` config instead of `Stancl\Tenancy\CacheManager`

* Change setting to assertion, add comment

* Inline variable & config key assignment

* Delete `cache.default` assertion

* Override cache manager only in CacheTagsBootstrapper

* Fix code style (php-cs-fixer)

* Prefix both drivers by default, add assertions for the second driver where missing

* Clean up global state (static properties) in before/afterEach

* Add docblock to tags bootstrapper

* Delete extra dependency

* Add `illuminate/support` dependency back

* Use `$addTags` approach again

* Fix code style (php-cs-fixer)

* Revert "Fix code style (php-cs-fixer)"

This reverts commit ea805fa231.

* Revert "Use `$addTags` approach again"

This reverts commit 8f5a4e4eb6.

* Add commented CacheTagsBootstrapper with info to the bootstrappers config

* Delete legacy bootstrapper from the bootstrappers config, add info to the bootstrapper's docblock

* Delete "?" from `tenant()?->getTenantKey()

* call generatePrefix() on $bootstrapper

* misc improvements

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-04-24 16:25:51 +02:00
Samuel Štancl
dfd39722a7
bump stancl/jobpipeline to v2.0.0-rc1 2023-03-16 22:20:47 +01:00
lukinovec
e61a26d604
Add L10 support to 4.x (merge 3.x to master) (#1071)
* exclude master from CI

* Add space after 'up' in 'docker-compose up-d' (#900)

* Fix ArgumentCountError on the TenantAssetsController (#894)

* Fix ArgumentCount exception on the TenantAssetsController when no `$path` is provided

* CS

* CS

* Handle null case explicitly

* code style

Co-authored-by: Bram Wubs <bram@sibi.nl>
Co-authored-by: Samuel Štancl <samuel@archte.ch>

* Add support for nested tenant config override (#920)

* feat: add support for nested tenant config override

* test: ensure nested tenant values are mapped

* fix: typo mistake (#954)

* [3.x] Add Vite helper for tenancy (#956)

* Add Vite helper for tenancy

* Move Vite bundler to an Optional Feature

* Rename to foundation vite

* Add ViteBundlerTest

* Add missing end of file

* Update tests

* remove unnecessary end() call

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* rewrite ViteBundlerTest to phpunit syntax

* skip vite test in Laravel < 9

* convert ViteBundler to PHP 7 syntax

* remove import of nonexistent class in older Laravel versions

* remove import of Foundation\Vite in tests

* try to exclude Vite.php from coverage report

* remove typehint

* update channel name

* Cache crash fix (#1048)

* Don't prevent accessing missing Tenant attributes. (#1045)

* [3.x] L10 compatibility (#1065)

* Bump dependencies for Laravel 10

* Update GitHub Actions for Laravel 10

* ci: do not test L10 using PHP 7.3

* drop < L9 support

* use `dispatch_sync` instead of `dispatch_now`

* migrate phpunit configuration

* Update ci.yml

* drop laravel < 9 support

* misc L10 fixes, new docker image

* specify odbc version

* wip

* properly list php versions as strings

* minor changes

* Add `getValue($queryGrammar)` to raw query

* Clean up `isVersion8` code

* rewrite hasFailed assertion

* phpunit schema update

* Upgrade `doctrine/dbal`

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: lukinovec <lukinovec@gmail.com>

* Update ci.yml

* Fix code style (php-cs-fixer)

* Update dependencies

* Change invade version

* Delete ViteBundlerTest

* Fix PHPStan error

* Delete PHPStan error ignore

* Fix CONTRIBUTING.md

* Delete ViteBundler remains

* Bring back ViteBundler

* Convert ViteBundlerTest to Pest

* Update ci.yml

---------

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: Bram Wubs <megawubs@users.noreply.github.com>
Co-authored-by: Bram Wubs <bram@sibi.nl>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: George Bishop <email.georgebishop@gmail.com>
Co-authored-by: Anbuselvan Rocky <15264938+anburocky3@users.noreply.github.com>
Co-authored-by: Wilsen Hernández <13445515+wilsenhc@users.noreply.github.com>
Co-authored-by: Joel Stein <joel@mediatrix.digital>
Co-authored-by: Guilherme Saade <saade@outlook.com.br>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2023-02-20 23:47:10 +01:00
lukinovec
d7a4982cd3
[4.x] Make broadcasting work with Tenancy (#1027)
* Add BroadcastTenancyBootstrapper and TenancyBroadcastManager

* Fix code style (php-cs-fixer)

* Bind original BroadcastManager again on `revert()`

* Fix code style (php-cs-fixer)

* Move manager to correct directory

* Fix property type

* Make BroadcastTenancyBootstrapper a singleton in tests

* Fix code style (php-cs-fixer)

* Bind the original broadcaster instance on `revert()`

* Instead of just forgetting the old broadcaster instance, bind the new one

* Add BroadcastTenancyBootstrapper tests

* Separate the test

* Fix code style (php-cs-fixer)

* Add bootstrapper test

* Add broadcaster channels test

* Clean up BootstrapperTest

* Fix BroadcastingTest

* Add comments to TenancyBroadcastManager

* Add BroadcastTenancyBootstrapper comments

* Simplify BroadcastManager extension, remove setDriver method

* Add comment

* Fix PHPStan errors

* Fix PHPStan errors

* Remove duplicate import

* Fix test

* Delete `::class` from test name

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Create databases for newly created tenants in BroadcastingTest

* move spatie/invade to require

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-02-18 15:52:55 +01:00
Samuel Štancl
c74a7b6fd4 remove debuggable trait, update larastan 2023-01-31 03:59:33 +01:00
Samuel Štancl
87c08cebc4 Merge branch 'master' of github.com:archtechx/tenancy 2023-01-06 02:48:40 +01:00
Samuel Štancl
48fc63fe02 switch to PHP 8.2 2023-01-06 02:38:31 +01:00
Samuel Štancl
a0256fd5f3 Merge branch 'master' of github.com:archtechx/tenancy 2023-01-04 03:27:04 +01:00
Samuel Štancl
32a128d657 lower required php version back to 8.1 2023-01-04 03:08:56 +01:00
Samuel Štancl
d0dd87ab07 bump PHP to 8.2, minor ci fixes 2023-01-04 02:43:10 +01:00
Samuel Štancl
5849089373
Add SessionTenancyBootstrapper (#2)
* Add SessionTenancyBootstrapper

* Fix code style (php-cs-fixer)

* add value to bootstrappers config

* tenant aware call test

* reproduce issue in tests

* fix logic for calling tenant run from central context, finish tests

* change laravel version back

* bump laravel to ^9.38

* add listener to create tenant DBs

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
2022-11-20 02:32:25 +01:00
Abrar Ahmad
99dd862b20
[4.x] [WIP] Add phpstan to CI (#928)
* add phpstan

* resolve phpstan issue from CI

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-11-08 13:47:24 +01:00
Samuel Štancl
0fd54bd685 Merge branch 'master' of github.com:archtechx/tenancy 2022-11-01 12:47:24 +01:00
Samuel Štancl
198f34f5e1
[4.x] Add pending tenants (modified #782) (#869)
* Add readied tenants

Add config for readied tenants
Add `create` and `clear` command
Add Readied scope and static functions
Add tests

* Fix initialize function name

* Add readied events

* Fix readied column cast

* Laravel 6 compatible

* Add readied scope tests

* Rename config from include_in_scope to include_in_queries

* Change terminology to pending

* Update CreatePendingTenants.php

* Laravel 6 compatible

* Update CreatePendingTenants.php

* runForMultiple can scope pending tenants

* Fix issues

* Code and comment style improvements

* Change 'tenant' to 'tenants' in command signature

* Fix code style (php-cs-fixer)

* Rename variables in CreatePendingTenants

* Remove withPending from runForMultiple

* Update tenants option trait

* Update command that use tenants

* Fix code style (php-cs-fixer)

* Improve getTenants condition

* Update config comments

* Minor config comment corrections

* Grammar fix

* Update comments and naming

* Correct comments

* Improve writing

* Remove pending tenant clearing time constraints

* Allow using only one time constraint for clearing the pending tenants

* phpunit to pest

* Fix code style (php-cs-fixer)

* Fix code style (php-cs-fixer)

* [4.x] Optionally delete storage after tenant deletion (#938)

* Add test for deleting storage after tenant deletion

* Save `storage_path()` in a variable after initializing tenant in test

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Add DeleteTenantStorage listener

* Update test name

* Remove storage deletion config key

* Remove tenant storage deletion events

* Move tenant storage deletion to the DeletingTenant event

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* [4.x] Finish incomplete and missing tests (#947)

* complete test sqlite manager customize path

* complete test seed command works

* complete uniqe exists test

* Update SingleDatabaseTenancyTest.php

* refactor the ternary into if condition

* custom path

* simplify if condition

* random dir name

* Update SingleDatabaseTenancyTest.php

* Update CommandsTest.php

* prefix random DB name with custom_

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* [4.x] Add batch tenancy queue bootstrapper (#874)

* exclude master from CI

* Add batch tenancy queue bootstrapper

* add test case

* skip tests for old versions

* variable docblocks

* use Laravel's connection getter and setter

* convert test to pest

* bottom space

* singleton regis in TestCase

* Update src/Bootstrappers/BatchTenancyBootstrapper.php

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* convert batch class resolution to property level

* enabled BatchTenancyBootstrapper by default

* typehint DatabaseBatchRepository

* refactore name

* DI DB manager

* typehint

* Update config.php

* use initialize() twice without end()ing tenancy to assert that previousConnection logic works correctly

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>

* [4.x] Storage::url() support (modified #689) (#909)

* This adds support for tenancy aware  Storage::url() method

* Trigger CI build

* Fixed Link command for Laravel v6, added StorageLink Events, more StorageLink tests, added RemoveStorageSymlinks Job, added Storage Jobs to TenancyServiceProvider stub, renamed misleading config example.

* Fix typo

* Fix code style (php-cs-fixer)

* Update config comments

* Format code in Link command, make writing more concise

* Change "symLinks" to "symlinks"

* Refactor Link command

* Fix test name typo

* Test fetching files using the public URL

* Extract Link command logic into actions

* Fix code style (php-cs-fixer)

* Check if closure is null in CreateStorageSymlinksAction

* Stop using command terminology in CreateStorageSymlinksAction

* Separate the Storage::url() test cases

* Update url_override comments

* Remove afterLink closures, add types, move actions, add usage explanation to the symlink trait

* Fix code style (php-cs-fixer)

* Update public storage URL test

* Fix issue with using str()

* Improve url_override comment, add todos

* add todo comment

* fix docblock style

* Add link command tests back

* Add types to $tenants in the action handle() methods

* Fix typo, update variable name formatting

* Add tests for the symlink actions

* Change possibleTenantSymlinks not to prefix the paths twice while tenancy is initialized

* Fix code style (php-cs-fixer)

* Stop testing storage directory existence in symlink test

* Don't specify full namespace for Tenant model annotation

* Don't specify full namespace in ActionTest

* Remove "change to DI" todo

* Remove possibleTenantSymlinks return annotation

* Remove symlink-related jobs, instantiate and use actions

* Revert "Remove symlink-related jobs, instantiate and use actions"

This reverts commit 547440c887.

* Add a comment line about the possible tenant symlinks

* Correct storagePath and publicPath variables

* Revert "Correct storagePath and publicPath variables"

This reverts commit e3aa8e2086.

* add a todo

Co-authored-by: Martin Vlcek <martin@dontfreakout.eu>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>

* Use HasTenantOptions in Link

* Correct the tenant order in Run command

* Fix code style (php-cs-fixer)

* Fix formatting issue

* Add missing imports

* Fix code style (php-cs-fixer)

* Use HasTenantOptions instead of the old trait name in Up/Down commands

* Fix test name typo

* Remove redundant passing of $withPending to runForMultiple in TenantCollection's runForEach

* Make `with-pending` default to `config('tenancy.pending.include_in_queries')` in HasTenantOptions

* Make `createPending()` return the created tenant

* Fix code style (php-cs-fixer)

* Remove tenant ordering

* Fix code style (php-cs-fixer)

* Remove duplicate tenancy bootstrappers config setting

* Add and use getWithPendingOption method

* Fix code style (php-cs-fixer)

* Add optionNotPassedValue property

* Test using --with-pending and the include_in_queries config value

* Make with-pending VALUE_NONE

* use plural in test names

* fix test names

* add pullPendingTenantFromPool

* Add docblock type

* Import commands

* Fix code style (php-cs-fixer)

* Move pending tenant tests to a more appropriate file

* Delete queuetest from gitignore

* Delete queuetest file

* Add queuetest to gitignore

* Rename pullPendingTenant to pullPending and don't pass bool to that method

* Add a test that checks if pulling a pending tenant removes it from the pool

* bump stancl/virtualcolumn to ^1.3

* Update pending tenant pulling test

* Dynamically get columns for pending queries

* Dynamically get virtual column name in ClearPendingTenants

* Fix ClearPendingTenants bug

* Make test name more accurate

* Update test name

* add a todo

* Update include in queries test name

* Remove `Tenant::query()->delete()` from pending tenant check test

* Rename the pending tenant check test name

* Update HasPending.php

* fix all() call

* code style

* all() -> get()

* Remove redundant `Tenant::all()` call

Co-authored-by: j.stein <joristein@gmail.com>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
Co-authored-by: Riley19280 <rileyaven88@gmail.com>
Co-authored-by: Martin Vlcek <martin@dontfreakout.eu>
2022-10-31 12:14:44 +01:00
Samuel Štancl
ae8b01153a phpstan pro 2022-10-26 12:20:21 +02:00
lukinovec
080b271bb3
[4.x] Drop tenant databases on migrate:fresh (#971)
* Test that `migrate:fresh` deletes tenant databases

* Delete tenants on `migrate:fresh`

* Fix code style (php-cs-fixer)

* Add config key for dropping tenant databases on `migrate:fresh`

* Add MigrateFreshOverride

* Try to override `migrate:fresh` in TenancyServiceProvider

* Update `migrate:fresh` test

* Fix code style (php-cs-fixer)

* Drop tenant databases by default

* Change `migrate:fresh` test to test if the tenant DBs are dropped by default

* Override `migrate:fresh` by extending `FreshCommand` in TenancyServiceProvider

* Update MigrateFreshOverride

* Fix code style (php-cs-fixer)

* Fix commands test

* Simplify handle method

* Fix code style (php-cs-fixer)

* Don't drop tenant DBs on migrate:fresh by default

* Change command overriding

* Update migrate:fresh test

* always register MigrateFreshOverride

* misc

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-10-17 15:19:30 +02:00
Jori Stein
121370ea01
[4.x] Add command to bring the tenants up and down from maintenance and remove deprecated exception (#761)
* Add bring up from maintenance function

* Add up and down tenant maintenance commands

* Rename commands signatures

* Update TenancyServiceProvider.php

* Complying to Laravel maintenance code and parameters

* Update MaintenanceModeTest.php

* Add maintenance mode via commands test

* Update CheckTenantForMaintenanceMode.php

* Update MaintenanceModeTest.php

* Cookie bypass only for > Laravel 8

* minor formatting change, trigger CI

* clean

* Update MaintenanceModeTest.php

* Add comments for using the 'tenants' option in runForMultiple

* improve code

* php-cs-fixer

* fix php cs fixer config

* improve test logic

* remove version check since v4 will be L9+

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-09-29 15:59:14 +02:00
Abrar Ahmad
3542b3f028
update spatie/ignition to support L9 (#930) 2022-08-30 15:21:19 +02:00
Samuel Štancl
8af354c20e get phpstan errors down from 252 to 189 2022-08-30 05:44:23 +02:00
Abrar Ahmad
fb8b9c1614
add phpstan (#926) 2022-08-29 20:55:33 +02:00
Samuel Štancl
40bf28c7d0 general refactor, move more classes under Database namespace 2022-08-27 03:17:16 +02:00
Samuel Štancl
2d7e9dfd89 Add 'composer coverage' 2022-08-26 22:29:40 +02:00
Samuel Štancl
5f41647a6b revert Tenancy changes, fix failing tests 2022-08-26 21:49:09 +02:00
Erik Gaal
ca2eefa30a
[WIP] Use a lighter Docker image, use it in CI (#793)
* Use action services and setup-php in workflow

* Fix codecov

* exclude master from CI

* Add space after 'up' in 'docker-compose up-d' (#900)

* Fix ArgumentCountError on the TenantAssetsController (#894)

* Fix ArgumentCount exception on the TenantAssetsController when no `$path` is provided

* CS

* CS

* Handle null case explicitly

* code style

Co-authored-by: Bram Wubs <bram@sibi.nl>
Co-authored-by: Samuel Štancl <samuel@archte.ch>

* Improve Dockerfile and use it in CI

* Update Dockerfile

* mssql CI health check

* cache key

* Update ci.yml

* Update ci.yml

* Update composer.json

* register dumcommand when L8

* Update ci.yml

* Update composer.json

* Update composer.json

* Update composer.json

* wip

* removed extensions config and php version from matrix

* introduce php-cs-fixer issue for testing

* Fix code style (php-cs-fixer)

* install composer in Docker and remove setup-php step

* added pcov for coverage

* on master branch

* composer test command

* tests above services

* Update ci.yml

* Revert "register dumcommand when L8"

This reverts commit f165fc58ba.

* removed composer cache dependencies

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: Bram Wubs <megawubs@users.noreply.github.com>
Co-authored-by: Bram Wubs <bram@sibi.nl>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2022-08-25 19:52:46 +02:00
Samuel Štancl
05f2a828a1 Better M1 DX 2022-07-22 22:29:56 +02:00
Samuel Štancl
2f3d4b9953 Allow pest plugin 2022-07-22 19:48:56 +02:00
Samuel Štancl
b47c5549ef
[4.x] Migrate tests to Pest (#884)
* Add Pest dependencies

* Add base Pest file

* Convert test cases

* Remove non-compound imports

* Adopt expectation API

* Optimize uses

* Shift cleanup

* phpunit -> pest

* Fix tests in PR #884 PHPUnit to Pest Converter  (#885)

* fixed tests, remove method duplications, restore necessary inner classes

* Update CommandsTest.php

* temporary checks run on `shift-64622` on branch.

* fixed `TestSeeder` class not resolved

* fixed messed up names

* removed `uses` from individual files and add it in `Pest`

* extract tests to helpers

* use pest dataset

* Update AutomaticModeTest.php

* newline

* todo convention

* resolve reviews

* added `// todo@tests`

* remove shift branch from CI workflow

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* check if I have write permission

* Convert newly added tests to Pest

Co-authored-by: Shift <shift@laravelshift.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
2022-07-22 19:26:59 +02:00
Samuel Štancl
4aec6bfda2
add phpunit dependency 2022-06-28 21:47:33 +02:00
Samuel Štancl
eca7b336bc merge 3.x 2022-06-01 14:58:44 +02:00
Erik Gaal
79e3d53b06
[3.x] Compatibility with Laravel 9 (#802)
* Test on Laravel 9

* Don't extend final Kernel class

* Make FilesystemTenancyBootstrapper compatible with Flysystem v3

Co-authored-by: George <jiri.zizka@funfirst.cz>

* Update tenant maintenance mode te be in line with Laravel

* Exclude PHP 7.4 <> L9 combination from testing

* add root_override-related assertions

* getPrefix -> getPathPrefix

* handle / inconsistency in s3 prefix

* Refactor Storage facade changes

Co-authored-by: George <jiri.zizka@funfirst.cz>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-03-08 01:50:25 +01:00
Erik Gaal
9c79267e24
Fix .env loading in development (#799)
* Upgrade vlucas/phpdotenv to ^5.0

`Dotenv::create($paths)` was the syntax for releases before v4

* Remove vlucas/phpdotenv dependency and make it work with newer versions.
2022-02-14 14:31:01 +01:00
Samuel Štancl
5980c46449 wip 2021-12-30 19:46:48 +01:00
Samuel Štancl
9883219544 wip 2021-12-13 13:09:16 +01:00
Samuel Štancl
30a1f9102d
PHP 8 support (#542)
* PHP 8 support, test workflow syntax

* Try using a custom data structure in the workflow

* Try using matrix include

* Default PHP target

* single include

* fix composer package name

* [WIP] Try using dev-master for valuestore

* Update spatie/valuestore constraint to be stable
2020-11-30 17:30:42 +01:00
Andre Sayej
36aabb7883
First try at Laravel 8 (#491) 2020-09-08 21:11:56 +02:00
Samuel Štancl
f483d0b8cf Extract VirtualColumn package 2020-07-06 14:44:49 +02:00