From 094a57e8be69afb531ae0c19a86d72db1c257369 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 21 Oct 2024 22:09:44 +0000 Subject: [PATCH 1/4] Remove interaction test files that are not needed Signed-off-by: Kevin Ullyott --- app-modules/student-data-model/phpunit.xml | 18 ----- app-modules/student-data-model/tests/Pest.php | 79 ------------------- 2 files changed, 97 deletions(-) delete mode 100644 app-modules/student-data-model/phpunit.xml delete mode 100644 app-modules/student-data-model/tests/Pest.php diff --git a/app-modules/student-data-model/phpunit.xml b/app-modules/student-data-model/phpunit.xml deleted file mode 100644 index ada83de962..0000000000 --- a/app-modules/student-data-model/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests - - - - - ./app - ./src - - - diff --git a/app-modules/student-data-model/tests/Pest.php b/app-modules/student-data-model/tests/Pest.php deleted file mode 100644 index 5040969699..0000000000 --- a/app-modules/student-data-model/tests/Pest.php +++ /dev/null @@ -1,79 +0,0 @@ - - - Copyright © 2016-2024, Canyon GBS LLC. All rights reserved. - - Advising App™ is licensed under the Elastic License 2.0. For more details, - see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. - - Notice: - - - You may not provide the software to third parties as a hosted or managed - service, where the service provides users with access to any substantial set of - the features or functionality of the software. - - You may not move, change, disable, or circumvent the license key functionality - in the software, and you may not remove or obscure any functionality in the - software that is protected by the license key. - - You may not alter, remove, or obscure any licensing, copyright, or other notices - of the licensor in the software. Any use of the licensor’s trademarks is subject - to applicable law. - - Canyon GBS LLC respects the intellectual property rights of others and expects the - same in return. Canyon GBS™ and Advising App™ are registered trademarks of - Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks - vigorously. - - The software solution, including services, infrastructure, and code, is offered as a - Software as a Service (SaaS) by Canyon GBS LLC. - - Use of this software implies agreement to the license terms and conditions as stated - in the Elastic License 2.0. - - For more information or inquiries please visit our website at - https://www.canyongbs.com or contact us via email at legal@canyongbs.com. - - -*/ - -/* -|-------------------------------------------------------------------------- -| Test Case -|-------------------------------------------------------------------------- -| -| The closure you provide to your test functions is always bound to a specific PHPUnit test -| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may -| need to change it using the "uses()" function to bind a different classes or traits. -| -*/ - -// uses(Tests\TestCase::class)->in('Feature'); - -/* -|-------------------------------------------------------------------------- -| Expectations -|-------------------------------------------------------------------------- -| -| When you're writing tests, you often need to check that values meet certain conditions. The -| "expect()" function gives you access to a set of "expectations" methods that you can use -| to assert different things. Of course, you may extend the Expectation API at any time. -| -*/ - -// expect()->extend('toBeOne', function () { -// return $this->toBe(1); -// }); - -/* -|-------------------------------------------------------------------------- -| Functions -|-------------------------------------------------------------------------- -| -| While Pest is very powerful out-of-the-box, you may have some testing code specific to your -| project that you don't want to repeat in every file. Here you can also expose helpers as -| global functions to help you to reduce the number of lines of code in your test files. -| -*/ - -function something() -{ - // .. -} From b08b1ea6e19cf439cfc3d4686f11471c34e88212 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 21 Oct 2024 22:10:01 +0000 Subject: [PATCH 2/4] Fix scoping to only happen if the User has neither license Signed-off-by: Kevin Ullyott --- .../interaction/src/Models/Interaction.php | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/app-modules/interaction/src/Models/Interaction.php b/app-modules/interaction/src/Models/Interaction.php index b12eb932d9..ac46f5fe6a 100644 --- a/app-modules/interaction/src/Models/Interaction.php +++ b/app-modules/interaction/src/Models/Interaction.php @@ -212,20 +212,24 @@ protected static function booted(): void ->where(fn (Builder $query) => $query ->tap(new LicensedToEducatable('interactable')) ->when( - ! $user->hasLicense(Student::getLicenseType()), - fn (Builder $query) => $query->whereHasMorph( - 'interactable', - ServiceRequest::class, - fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '!=', app(Student::class)->getMorphClass()), - ), - ) - ->when( - ! $user->hasLicense(Prospect::getLicenseType()), - fn (Builder $query) => $query->whereHasMorph( - 'interactable', - ServiceRequest::class, - fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '!=', app(Prospect::class)->getMorphClass()), - ), + (! $user->hasLicense(Student::getLicenseType()) && ! $user->hasLicense(Prospect::getLicenseType())), + fn (Builder $query) => $query + ->when( + ! $user->hasLicense(Student::getLicenseType()), + fn (Builder $query) => $query->whereHasMorph( + 'interactable', + ServiceRequest::class, + fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '!=', app(Student::class)->getMorphClass()), + ), + ) + ->when( + ! $user->hasLicense(Prospect::getLicenseType()), + fn (Builder $query) => $query->whereHasMorph( + 'interactable', + ServiceRequest::class, + fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '!=', app(Prospect::class)->getMorphClass()), + ), + ) )); }); } From 1da6c740834e41539c494132b67daeed06c7cc5b Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 21 Oct 2024 22:33:44 +0000 Subject: [PATCH 3/4] Remove the query Signed-off-by: Kevin Ullyott --- .../interaction/src/Models/Interaction.php | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/app-modules/interaction/src/Models/Interaction.php b/app-modules/interaction/src/Models/Interaction.php index ac46f5fe6a..c20a64add1 100644 --- a/app-modules/interaction/src/Models/Interaction.php +++ b/app-modules/interaction/src/Models/Interaction.php @@ -210,27 +210,24 @@ protected static function booted(): void $builder ->where(fn (Builder $query) => $query - ->tap(new LicensedToEducatable('interactable')) - ->when( - (! $user->hasLicense(Student::getLicenseType()) && ! $user->hasLicense(Prospect::getLicenseType())), - fn (Builder $query) => $query - ->when( - ! $user->hasLicense(Student::getLicenseType()), - fn (Builder $query) => $query->whereHasMorph( - 'interactable', - ServiceRequest::class, - fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '!=', app(Student::class)->getMorphClass()), - ), - ) - ->when( - ! $user->hasLicense(Prospect::getLicenseType()), - fn (Builder $query) => $query->whereHasMorph( - 'interactable', - ServiceRequest::class, - fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '!=', app(Prospect::class)->getMorphClass()), - ), - ) - )); + ->tap(new LicensedToEducatable('interactable'))); + // TODO: This needs to be fixed seperatlely but is preventing users without each license from seeing interactions + // ->when( + // ! $user->hasLicense(Student::getLicenseType()), + // fn (Builder $query) => $query->whereHasMorph( + // 'interactable', + // ServiceRequest::class, + // fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '!=', app(Student::class)->getMorphClass()), + // ), + // ) + // ->when( + // ! $user->hasLicense(Prospect::getLicenseType()), + // fn (Builder $query) => $query->whereDoesntHaveMorph( + // 'interactable', + // ServiceRequest::class, + // fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '=', app(Prospect::class)->getMorphClass()), + // ), + // )); }); } } From 34073748649c92776190035fc22b151661ad2337 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 21 Oct 2024 23:08:22 +0000 Subject: [PATCH 4/4] Fix the queries Signed-off-by: Kevin Ullyott --- .../interaction/src/Models/Interaction.php | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/app-modules/interaction/src/Models/Interaction.php b/app-modules/interaction/src/Models/Interaction.php index c20a64add1..b8ff28727b 100644 --- a/app-modules/interaction/src/Models/Interaction.php +++ b/app-modules/interaction/src/Models/Interaction.php @@ -210,24 +210,31 @@ protected static function booted(): void $builder ->where(fn (Builder $query) => $query - ->tap(new LicensedToEducatable('interactable'))); - // TODO: This needs to be fixed seperatlely but is preventing users without each license from seeing interactions - // ->when( - // ! $user->hasLicense(Student::getLicenseType()), - // fn (Builder $query) => $query->whereHasMorph( - // 'interactable', - // ServiceRequest::class, - // fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '!=', app(Student::class)->getMorphClass()), - // ), - // ) - // ->when( - // ! $user->hasLicense(Prospect::getLicenseType()), - // fn (Builder $query) => $query->whereDoesntHaveMorph( - // 'interactable', - // ServiceRequest::class, - // fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '=', app(Prospect::class)->getMorphClass()), - // ), - // )); + ->tap(new LicensedToEducatable('interactable')) + ->when( + ! $user->hasLicense(Student::getLicenseType()), + fn (Builder $query) => $query->where(fn (Builder $query) => $query->whereHasMorph( + 'interactable', + ServiceRequest::class, + fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '!=', app(Student::class)->getMorphClass()), + )->orWhere( + 'interactable_type', + '!=', + app(ServiceRequest::class)->getMorphClass(), + )), + ) + ->when( + ! $user->hasLicense(Prospect::getLicenseType()), + fn (Builder $query) => $query->where(fn (Builder $query) => $query->whereHasMorph( + 'interactable', + ServiceRequest::class, + fn (Builder $query) => $query->where($serviceRequestRespondentTypeColumn, '!=', app(Prospect::class)->getMorphClass()), + )->orWhere( + 'interactable_type', + '!=', + app(ServiceRequest::class)->getMorphClass(), + )), + )); }); } }