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

363 commits

Author SHA1 Message Date
lukinovec
93aaba3e11 Merge branch 'master' of github.com:archtechx/tenancy into cache-prefix 2023-02-02 10:51:09 +01:00
Abrar Ahmad
758fbc8a75
Use polymorphic table for mapping resources to tenants (#997)
* wip

* Fix code style (php-cs-fixer)

* adjust tests

* Update ResourceSyncingPolymorphicTest.php

* Update SyncMaster.php

* correct method name

* Update ResourceSyncingPolymorphicTest.php

* use BelongsToMany return type

* separate pivot model for each approach

* ability to publish migrations

* remove unsed import

* use resource migrations from asset

* anonymous migration for `tenant_resources` table

* rename file

* rename classes

* trait

* add back using statement

* revert to unset change

* use unset approach

* use unset approach

* Assert `tenants` are accessible

* Update ResourceSyncingUsingPolymorphicTest.php

* improve `tenants` assertions

* improve assertions

* remove `getResourceTenantModelName` method and use config

* use `BelongsToMany` for `tenants` method return type

* Fix code style (php-cs-fixer)

* revert type

* use correct key

* test right resources are accessible from the tenant

* Update tests/ResourceSyncingUsingPolymorphicTest.php

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2023-02-02 06:39:35 +01:00
lukinovec
c3e3a33ed0 Fix test 2023-02-01 11:51:28 +01:00
Abrar Ahmad
087733d5db
Allow defining the tenant connection template using array syntax in config (#1040)
* `template_tenant_connection` can be array or string

* Update TenantDatabaseManagerTest.php

* Update TenantDatabaseManagerTest.php

* Update TenantDatabaseManagerTest.php

* Update DatabaseConfig.php

* partial database config for template

* Update tests/TenantDatabaseManagerTest.php

Co-authored-by: lukinovec <lukinovec@gmail.com>

* update test name

* improve test names

* add comments

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2023-02-01 07:02:03 +01:00
lukinovec
342c67fe02
Add skip-failing option to the Migrate command (#945)
* Add and test Migrate command's skip-failing option

* Improve naming

* Move migration event dispatching inside try block

* Change test name

* Fix skip-failing test

* Use QueryException instead of Exception

* Correct TenantDatabaseDoesNotExistException import

* Correct test

* Check for the the testing env in DB bootstrapper

* Correct the Migrate command

* Fix code style (php-cs-fixer)

* add docs todo

* Add QueryException to the Migrat command try/catch

* Return status codes in Migrate

* Fix code style (php-cs-fixer)

* Add test for not stopping tenants:migrate after the first failure

* Update Migrate command

* Fix code style (php-cs-fixer)

* Fix code style (php-cs-fixer)

* Use `getTenants()`

* Use withtenantDatabases where needed

* Add withTenantDatabases to test

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-02-01 06:55:26 +01:00
lukinovec
ba8cfdda85
Merge branch 'master' into cache-prefix 2023-01-31 08:17:22 +01:00
Samuel Štancl
c74a7b6fd4 remove debuggable trait, update larastan 2023-01-31 03:59:33 +01:00
lukinovec
8deeef25be Improve tests 2023-01-06 08:34:56 +01:00
lukinovec
caa0c87153 Improve comment 2023-01-06 07:22:07 +01:00
lukinovec
1104aba4ef Improve specific cache store in a service test 2023-01-06 07:20:37 +01:00
lukinovec
d945d1facc Rename CacheManagerService 2023-01-06 07:17:55 +01:00
lukinovec
52db2a0c06 Remove group('prefix') 2023-01-05 16:49:49 +01:00
lukinovec
507df55b4c Update test name 2023-01-05 16:45:25 +01:00
lukinovec
5ea5299ed1 Make CacheService a singleton in a test 2023-01-05 16:37:43 +01:00
lukinovec
b38aee0a6a Remove unused import, change word 2023-01-05 16:28:33 +01:00
lukinovec
7f10b9af41 Make 'redis' the only tenant cache store in beforeEach, test that tenantCacheStores works 2023-01-05 16:24:37 +01:00
lukinovec
42381d00e2 Remove redundant CacheManager extend() call 2023-01-05 16:14:20 +01:00
lukinovec
f8f0e1e5da
Merge branch 'master' into cache-prefix 2023-01-05 15:07:59 +01:00
lukinovec
ffefe1b45c Test that the prefix stays the same 2023-01-05 13:05:39 +01:00
lukinovec
4b0df42f8a Add and test nonTenantCacheDrivers 2023-01-05 12:47:03 +01:00
lukinovec
1c21c66913
Make $cache non-nullable
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2023-01-05 11:42:12 +01:00
lukinovec
a59d5a1069 Add test 2023-01-04 15:08:09 +01:00
Samuel Štancl
a0256fd5f3 Merge branch 'master' of github.com:archtechx/tenancy 2023-01-04 03:27:04 +01:00
Samuel Štancl
d0dd87ab07 bump PHP to 8.2, minor ci fixes 2023-01-04 02:43:10 +01:00
lukinovec
0f892f1585
Make tenants able to have custom mail credentials (#989)
* Replace MailManager singleton with an instance of a custom mail manager which always resolves the mailers instead of getting the cached ones

* Fix code style (php-cs-fixer)

* Add MailTenancyBootstrapper

* Add MailTenancyBootstrapper to tenancy.bootstrappers config (commented out)

* Fix code style (php-cs-fixer)

* Make credentials map a public static property

* Always resolve only the mailers specified in the mailersToNotCache public static property

* Fix typo in comment

* Update TenancyServiceProvider comment

* add todo

* Add comments to TenancyMailManager, rename property

* Remove the configKey array check

* Simplify bootstrap method

* Change $credentialsMap so that config keys are the keys, and the tenant property names are the values

* Rename $mailersToAlwaysResolve to $tenantMailers

* Update comment

* Update comment

* Rename variable in TenancyServiceProvider comment

* Scaffold tests

* Update comments after review

* Uncomment MailTenancyBootstrapper in config

* Use array_key_exists instead of null check

* Split config logic into methods

* Update mapping credentials

* Add tests for the added logic

* Fix code style (php-cs-fixer)

* Delete default 'smtp' mailer in $tenantMailers

* Add separate method to pick the appropriate mail credentials map preset

* Specify test name

* Move mail bootstrapper tests to BootstrapperTest

* Depend less on the default mailer by adding a static `$mailer` property

* Use static property for map presets

* Comment out MailTenancyBootstrapper from config

* Add return types to MailTenancyBootstrapper methods

* Update test name

* Move MailManager extension to MailTenancyBootstrapper

* Fix code style (php-cs-fixer)

* Update config reverting test

* Use `invade()` instead of ReflectionClass

* Fix constructor parameter formatting

* Delete TenancyMailManager, update tests

* Add return type

* Update comment

* Update MailTest

* Delete `group('mailer')`

* Delete bindNewMailManagerInstance()

* Delete remaining `group('mailer')`

* Fix comment

* Fix comment

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-01-04 02:12:25 +01:00
Abrar Ahmad
f42f08cb87
Add session state when impersonating tenant (#1029)
* wip

* Fix code style (php-cs-fixer)

* Update TenantUserImpersonationTest.php

* renamed method

* update method name in test

* rename session key

* fix test

* Update src/Features/UserImpersonation.php

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

* Update UserImpersonation.php

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2022-12-17 02:08:03 +01:00
lukinovec
21dc69e358
Use invade in BootstrapperTest (#1033) 2022-12-15 15:03:03 +01:00
lukinovec
7092f4c856 Make CacheManager::$addTags default to true 2022-12-14 16:21:45 +01:00
lukinovec
87efdd2954 Toggle cache tags 2022-12-13 05:25:57 +01:00
lukinovec
9ec0b6dae3 Make Tenancy override CacheManager 2022-12-12 17:05:53 +01:00
lukinovec
825a565fa2 Update prefix bootstrapper and test (setStore() in CacheManager and Repository needed) 2022-12-08 16:24:54 +01:00
lukinovec
4c33df1aa5 Rename CacheAction to CacheService 2022-12-07 14:48:52 +01:00
Abrar Ahmad
974414a12d Update CacheAction.php 2022-12-07 18:26:10 +05:00
Abrar Ahmad
19255fd98f use Repository in service class DI 2022-12-07 18:24:55 +05:00
Abrar Ahmad
2f91309990 introduce second tenant in test 2022-12-01 14:59:13 +05:00
Abrar Ahmad
6c955acd13 CacheService class as singleton 2022-12-01 14:58:13 +05:00
Abrar Ahmad
222686ec1d CacheManager dependency injection test 2022-12-01 13:53:45 +05:00
Abrar Ahmad
70ee83b3b7 fix test 2022-11-30 13:27:15 +05:00
Abrar Ahmad
3407faf811 fix prefix test according to prefix changes 2022-11-30 13:25:39 +05:00
Abrar Ahmad
2901d0190c remove unused line 2022-11-29 18:11:10 +05:00
Abrar Ahmad
b920a2905e assert tenants' data is accessible using the prefix from the central context 2022-11-29 17:13:04 +05:00
Samuel Štancl
b2dc0844eb Merge branch 'master' of github.com:tenancy-for-laravel/v4 2022-11-29 10:19:12 +01:00
lukinovec
7d3298c6bb
Improve code of pending tenants (#1025)
* Remove `--all` option from ClearPendingTenants

* Improve query formatting

* Remove redundant test

* Convert time constrait options to int

* Improve CreatePendingTenants success message
2022-11-29 09:31:07 +01:00
Abrar Ahmad
eef58bd93d test names grammar 2022-11-28 12:50:14 +05:00
Abrar Ahmad
73c5655bc8
Manual mode improvements (use correct event type, add new listeners) (#1013)
* fix issue and add test

* Update CreateTenantConnection.php

* add purge call

* Update ManualModeTest.php

* use tenant connection and central connection listener

* Update ManualModeTest.php

* fix test

* improvements

* Update ManualModeTest.php

* add comment

* simplify comment

Co-authored-by: Samuel Štancl <samuel@archte.ch>
2022-11-25 03:09:31 +01:00
Abrar Ahmad
3cff2e3ba9 Update PrefixCacheBootstrapperTest.php 2022-11-24 12:05:19 +05:00
lukinovec
ea19117870
Use the hardcoded default path in TenantDump only if the path isn't configured (#1019)
* Use the hardcoded tenant dump path only if the path isn't configured

* Test generating tenant dump at the configured path
2022-11-23 13:12:29 +01:00
Abrar Ahmad
2c0a8f4ef9 Update PrefixCacheBootstrapperTest.php 2022-11-23 12:59:51 +05:00
lukinovec
cb7567a88a
[4.x] Make TenantDump work when called outside the tenant context (#1015)
* Run TenantDump as passed tenant

* Fix code style (php-cs-fixer)

* Fix `tenants:dump` tests

* Update dump command test

* Remove redundant `tenant-schema.dump` unlinking

* Delete duplicate test

* Update test name

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2022-11-23 08:38:20 +01:00
Abrar Ahmad
c4f9324aa8 Create PrefixCacheBootstrapperTest.php 2022-11-22 13:54:01 +05:00