diff --git a/.env.example b/.env.example index 9fb0255..f6d3727 100644 --- a/.env.example +++ b/.env.example @@ -55,4 +55,6 @@ GOOGLE_CLIENT_ID= GOOGLE_CLIENT_SECRET= GOOGLE_REDIRECT= +GOOGLE_CALENDAR_ID= + LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE= diff --git a/app/Domain/Listeners/HandleApprovedVacationRequest.php b/app/Domain/Listeners/HandleApprovedVacationRequest.php index 948f7f8..c556ee8 100644 --- a/app/Domain/Listeners/HandleApprovedVacationRequest.php +++ b/app/Domain/Listeners/HandleApprovedVacationRequest.php @@ -4,9 +4,9 @@ declare(strict_types=1); namespace Toby\Domain\Listeners; -use Illuminate\Support\Facades\Log; use Toby\Domain\Events\VacationRequestApproved; use Toby\Domain\VacationTypeConfigRetriever; +use Toby\Infrastructure\Jobs\SendVacationRequestDaysToGoogleCalendar; class HandleApprovedVacationRequest { @@ -17,8 +17,6 @@ class HandleApprovedVacationRequest public function handle(VacationRequestApproved $event): void { - $vacationRequest = $event->vacationRequest; - - Log::info("approved! {$vacationRequest->id}"); + SendVacationRequestDaysToGoogleCalendar::dispatch($event->vacationRequest); } } diff --git a/app/Eloquent/Models/Vacation.php b/app/Eloquent/Models/Vacation.php index c22cf76..232fcfe 100644 --- a/app/Eloquent/Models/Vacation.php +++ b/app/Eloquent/Models/Vacation.php @@ -12,6 +12,7 @@ use Illuminate\Support\Carbon; /** * @property int $id * @property Carbon $date + * @property string $event_id * @property User $user * @property VacationRequest $vacationRequest * @property YearPeriod $yearPeriod diff --git a/app/Infrastructure/Jobs/SendVacationRequestDaysToGoogleCalendar.php b/app/Infrastructure/Jobs/SendVacationRequestDaysToGoogleCalendar.php new file mode 100644 index 0000000..6791d70 --- /dev/null +++ b/app/Infrastructure/Jobs/SendVacationRequestDaysToGoogleCalendar.php @@ -0,0 +1,43 @@ +vacationRequest->vacations() + ->whereNull("event_id") + ->get(); + + /** @var Vacation $vacation */ + foreach ($vacations as $vacation) { + $event = Event::create([ + "name" => "{$this->vacationRequest->type->label()} - {$this->vacationRequest->user->fullName}", + "startDate" => $vacation->date, + "endDate" => $vacation->date, + ]); + + $vacation->update([ + "event_id" => $event->id, + ]); + } + } +} diff --git a/composer.json b/composer.json index ebd3f96..3296b26 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "laravel/socialite": "^5.2", "laravel/telescope": "^4.6", "laravel/tinker": "^2.5", - "lasserafn/php-initial-avatar-generator": "^4.2" + "lasserafn/php-initial-avatar-generator": "^4.2", + "spatie/laravel-google-calendar": "^3.5" }, "require-dev": { "blumilksoftware/codestyle": "^0.9.0", diff --git a/composer.lock b/composer.lock index a7e5000..1d9d951 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c2f475e65f84bdff45169e4443d9ef4f", + "content-hash": "9f6a05e262278b2e7bc50b7264c02fc9", "packages": [ { "name": "asm89/stack-cors", @@ -709,6 +709,63 @@ ], "time": "2020-12-29T14:50:06+00:00" }, + { + "name": "firebase/php-jwt", + "version": "v5.5.1", + "source": { + "type": "git", + "url": "https://github.com/firebase/php-jwt.git", + "reference": "83b609028194aa042ea33b5af2d41a7427de80e6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/83b609028194aa042ea33b5af2d41a7427de80e6", + "reference": "83b609028194aa042ea33b5af2d41a7427de80e6", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4.8 <=9" + }, + "suggest": { + "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present" + }, + "type": "library", + "autoload": { + "psr-4": { + "Firebase\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Neuman Vong", + "email": "neuman+pear@twilio.com", + "role": "Developer" + }, + { + "name": "Anant Narayanan", + "email": "anant@php.net", + "role": "Developer" + } + ], + "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", + "homepage": "https://github.com/firebase/php-jwt", + "keywords": [ + "jwt", + "php" + ], + "support": { + "issues": "https://github.com/firebase/php-jwt/issues", + "source": "https://github.com/firebase/php-jwt/tree/v5.5.1" + }, + "time": "2021-11-08T20:18:51+00:00" + }, { "name": "fruitcake/laravel-cors", "version": "v2.0.5", @@ -790,6 +847,177 @@ ], "time": "2022-01-03T14:53:04+00:00" }, + { + "name": "google/apiclient", + "version": "v2.12.1", + "source": { + "type": "git", + "url": "https://github.com/googleapis/google-api-php-client.git", + "reference": "1530583a711f4414407112c4068464bcbace1c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/1530583a711f4414407112c4068464bcbace1c71", + "reference": "1530583a711f4414407112c4068464bcbace1c71", + "shasum": "" + }, + "require": { + "firebase/php-jwt": "~2.0||~3.0||~4.0||~5.0", + "google/apiclient-services": "~0.200", + "google/auth": "^1.10", + "guzzlehttp/guzzle": "~5.3.3||~6.0||~7.0", + "guzzlehttp/psr7": "^1.7||^2.0.0", + "monolog/monolog": "^1.17||^2.0", + "php": "^5.6|^7.0|^8.0", + "phpseclib/phpseclib": "~2.0||^3.0.2" + }, + "require-dev": { + "cache/filesystem-adapter": "^0.3.2|^1.1", + "composer/composer": "^1.10.22", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "phpcompatibility/php-compatibility": "^9.2", + "phpspec/prophecy-phpunit": "^1.1||^2.0", + "phpunit/phpunit": "^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0", + "squizlabs/php_codesniffer": "~2.3", + "symfony/css-selector": "~2.1", + "symfony/dom-crawler": "~2.1", + "yoast/phpunit-polyfills": "^1.0" + }, + "suggest": { + "cache/filesystem-adapter": "For caching certs and tokens (using Google\\Client::setCache)" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "autoload": { + "files": [ + "src/aliases.php" + ], + "psr-4": { + "Google\\": "src/" + }, + "classmap": [ + "src/aliases.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Client library for Google APIs", + "homepage": "http://developers.google.com/api-client-library/php", + "keywords": [ + "google" + ], + "support": { + "issues": "https://github.com/googleapis/google-api-php-client/issues", + "source": "https://github.com/googleapis/google-api-php-client/tree/v2.12.1" + }, + "time": "2021-12-02T03:34:25+00:00" + }, + { + "name": "google/apiclient-services", + "version": "v0.235.0", + "source": { + "type": "git", + "url": "https://github.com/googleapis/google-api-php-client-services.git", + "reference": "3aefd2914d9025a881ee93145de16f9e0f82443e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/3aefd2914d9025a881ee93145de16f9e0f82443e", + "reference": "3aefd2914d9025a881ee93145de16f9e0f82443e", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "phpunit/phpunit": "^5.7||^8.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "autoload.php" + ], + "psr-4": { + "Google\\Service\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Client library for Google APIs", + "homepage": "http://developers.google.com/api-client-library/php", + "keywords": [ + "google" + ], + "support": { + "issues": "https://github.com/googleapis/google-api-php-client-services/issues", + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.235.0" + }, + "time": "2022-02-07T14:04:26+00:00" + }, + { + "name": "google/auth", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/googleapis/google-auth-library-php.git", + "reference": "21dd478e77b0634ed9e3a68613f74ed250ca9347" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/21dd478e77b0634ed9e3a68613f74ed250ca9347", + "reference": "21dd478e77b0634ed9e3a68613f74ed250ca9347", + "shasum": "" + }, + "require": { + "firebase/php-jwt": "~2.0|~3.0|~4.0|~5.0", + "guzzlehttp/guzzle": "^5.3.1|^6.2.1|^7.0", + "guzzlehttp/psr7": "^1.7|^2.0", + "php": ">=5.4", + "psr/cache": "^1.0|^2.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "guzzlehttp/promises": "0.1.1|^1.3", + "kelvinmo/simplejwt": "^0.2.5|^0.5.1", + "phpseclib/phpseclib": "^2.0.31", + "phpunit/phpunit": "^4.8.36|^5.7", + "sebastian/comparator": ">=1.2.3" + }, + "suggest": { + "phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2." + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\Auth\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Google Auth Library for PHP", + "homepage": "http://github.com/google/google-auth-library-php", + "keywords": [ + "Authentication", + "google", + "oauth2" + ], + "support": { + "docs": "https://googleapis.github.io/google-auth-library-php/master/", + "issues": "https://github.com/googleapis/google-auth-library-php/issues", + "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.18.0" + }, + "time": "2021-08-24T18:03:18+00:00" + }, { "name": "graham-campbell/result-type", "version": "v1.0.4", @@ -2989,6 +3217,123 @@ ], "time": "2021-07-19T03:43:32+00:00" }, + { + "name": "paragonie/constant_time_encoding", + "version": "v2.5.0", + "source": { + "type": "git", + "url": "https://github.com/paragonie/constant_time_encoding.git", + "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/9229e15f2e6ba772f0c55dd6986c563b937170a8", + "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8", + "shasum": "" + }, + "require": { + "php": "^7|^8" + }, + "require-dev": { + "phpunit/phpunit": "^6|^7|^8|^9", + "vimeo/psalm": "^1|^2|^3|^4" + }, + "type": "library", + "autoload": { + "psr-4": { + "ParagonIE\\ConstantTime\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com", + "role": "Maintainer" + }, + { + "name": "Steve 'Sc00bz' Thomas", + "email": "steve@tobtu.com", + "homepage": "https://www.tobtu.com", + "role": "Original Developer" + } + ], + "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", + "keywords": [ + "base16", + "base32", + "base32_decode", + "base32_encode", + "base64", + "base64_decode", + "base64_encode", + "bin2hex", + "encoding", + "hex", + "hex2bin", + "rfc4648" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/constant_time_encoding/issues", + "source": "https://github.com/paragonie/constant_time_encoding" + }, + "time": "2022-01-17T05:32:27+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.100", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", + "shasum": "" + }, + "require": { + "php": ">= 7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, { "name": "phenx/php-font-lib", "version": "0.5.4", @@ -3149,6 +3494,166 @@ ], "time": "2021-12-04T23:24:31+00:00" }, + { + "name": "phpseclib/phpseclib", + "version": "3.0.13", + "source": { + "type": "git", + "url": "https://github.com/phpseclib/phpseclib.git", + "reference": "1443ab79364eea48665fa8c09ac67f37d1025f7e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/1443ab79364eea48665fa8c09ac67f37d1025f7e", + "reference": "1443ab79364eea48665fa8c09ac67f37d1025f7e", + "shasum": "" + }, + "require": { + "paragonie/constant_time_encoding": "^1|^2", + "paragonie/random_compat": "^1.4|^2.0|^9.99.99", + "php": ">=5.6.1" + }, + "require-dev": { + "phing/phing": "~2.7", + "phpunit/phpunit": "^5.7|^6.0|^9.4", + "squizlabs/php_codesniffer": "~2.0" + }, + "suggest": { + "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", + "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", + "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", + "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." + }, + "type": "library", + "autoload": { + "files": [ + "phpseclib/bootstrap.php" + ], + "psr-4": { + "phpseclib3\\": "phpseclib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Wigginton", + "email": "terrafrost@php.net", + "role": "Lead Developer" + }, + { + "name": "Patrick Monnerat", + "email": "pm@datasphere.ch", + "role": "Developer" + }, + { + "name": "Andreas Fischer", + "email": "bantu@phpbb.com", + "role": "Developer" + }, + { + "name": "Hans-Jürgen Petrich", + "email": "petrich@tronic-media.com", + "role": "Developer" + }, + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "role": "Developer" + } + ], + "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", + "homepage": "http://phpseclib.sourceforge.net", + "keywords": [ + "BigInteger", + "aes", + "asn.1", + "asn1", + "blowfish", + "crypto", + "cryptography", + "encryption", + "rsa", + "security", + "sftp", + "signature", + "signing", + "ssh", + "twofish", + "x.509", + "x509" + ], + "support": { + "issues": "https://github.com/phpseclib/phpseclib/issues", + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.13" + }, + "funding": [ + { + "url": "https://github.com/terrafrost", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpseclib", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib", + "type": "tidelift" + } + ], + "time": "2022-01-30T08:50:05+00:00" + }, + { + "name": "psr/cache", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "213f9dbc5b9bfbc4f8db86d2838dc968752ce13b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/213f9dbc5b9bfbc4f8db86d2838dc968752ce13b", + "reference": "213f9dbc5b9bfbc4f8db86d2838dc968752ce13b", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/2.0.0" + }, + "time": "2021-02-03T23:23:37+00:00" + }, { "name": "psr/container", "version": "1.1.2", @@ -3857,6 +4362,81 @@ }, "time": "2021-12-11T13:40:54+00:00" }, + { + "name": "spatie/laravel-google-calendar", + "version": "3.5.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-google-calendar.git", + "reference": "b5e9e497c1fc6be5a4a2bb18ddf53b6c711648f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-google-calendar/zipball/b5e9e497c1fc6be5a4a2bb18ddf53b6c711648f7", + "reference": "b5e9e497c1fc6be5a4a2bb18ddf53b6c711648f7", + "shasum": "" + }, + "require": { + "google/apiclient": "^2.2", + "illuminate/support": "^6.0|^7.0|^8.0|^9.0", + "nesbot/carbon": "^2.0", + "php": "^7.2|^8.0" + }, + "require-dev": { + "mockery/mockery": "^1.3.3|^1.4", + "orchestra/testbench": "^4.0|^5.0|^6.0|^7.0", + "phpunit/phpunit": "^8.4|^9.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\GoogleCalendar\\GoogleCalendarServiceProvider" + ], + "aliases": { + "GoogleCalendar": "Spatie\\GoogleCalendar\\GoogleCalendarFacade" + } + } + }, + "autoload": { + "psr-4": { + "Spatie\\GoogleCalendar\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Manage events on a Google Calendar", + "homepage": "https://github.com/spatie/laravel-google-calendar", + "keywords": [ + "calendar", + "event", + "google", + "laravel-google-calendar", + "schedule", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-google-calendar/issues", + "source": "https://github.com/spatie/laravel-google-calendar/tree/3.5.0" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + } + ], + "time": "2022-01-13T09:43:27+00:00" + }, { "name": "swiftmailer/swiftmailer", "version": "v6.3.0", @@ -10312,5 +10892,5 @@ "ext-pdo": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.1.0" } diff --git a/config/google-calendar.php b/config/google-calendar.php new file mode 100644 index 0000000..e50a33b --- /dev/null +++ b/config/google-calendar.php @@ -0,0 +1,19 @@ + env("GOOGLE_CALENDAR_AUTH_PROFILE", "service_account"), + "auth_profiles" => [ + "service_account" => [ + "credentials_json" => storage_path("app/google-calendar/service-account-credentials.json"), + ], + "oauth" => [ + "credentials_json" => storage_path("app/google-calendar/oauth-credentials.json"), + "token_json" => storage_path("app/google-calendar/oauth-token.json"), + ], + ], + + "calendar_id" => env("GOOGLE_CALENDAR_ID"), + "user_to_impersonate" => env("GOOGLE_CALENDAR_IMPERSONATE"), +]; diff --git a/database/migrations/2022_02_07_133018_create_vacations_table.php b/database/migrations/2022_02_07_133018_create_vacations_table.php index 648be3c..7d09b8e 100644 --- a/database/migrations/2022_02_07_133018_create_vacations_table.php +++ b/database/migrations/2022_02_07_133018_create_vacations_table.php @@ -17,6 +17,7 @@ return new class() extends Migration { $table->foreignIdFor(User::class)->constrained()->cascadeOnDelete(); $table->foreignIdFor(VacationRequest::class)->constrained()->cascadeOnDelete(); $table->foreignIdFor(YearPeriod::class)->constrained()->cascadeOnDelete(); + $table->string("event_id")->nullable(); $table->date("date"); }); } diff --git a/readme.md b/readme.md index a30e446..f1e4372 100644 --- a/readme.md +++ b/readme.md @@ -49,6 +49,8 @@ Directory structure little differs from a standard Laravel tree. We decided to r dcr node npm run dev +- place google credentials here: `/storage/app/google-calendar/service-account-credentials.json` ([how to obtain the credentials](https://github.com/spatie/laravel-google-calendar#how-to-obtain-the-credentials-to-communicate-with-google-calendar)) + ### Available containers (local) - **web** - nginx HTTP server diff --git a/tests/Feature/VacationRequestTest.php b/tests/Feature/VacationRequestTest.php index 98e95e0..0841d1e 100644 --- a/tests/Feature/VacationRequestTest.php +++ b/tests/Feature/VacationRequestTest.php @@ -6,6 +6,7 @@ namespace Tests\Feature; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Bus; use Inertia\Testing\AssertableInertia as Assert; use Tests\FeatureTestCase; use Toby\Domain\Enums\VacationRequestState; @@ -15,6 +16,7 @@ use Toby\Eloquent\Models\User; use Toby\Eloquent\Models\VacationLimit; use Toby\Eloquent\Models\VacationRequest; use Toby\Eloquent\Models\YearPeriod; +use Toby\Infrastructure\Jobs\SendVacationRequestDaysToGoogleCalendar; class VacationRequestTest extends FeatureTestCase { @@ -26,6 +28,8 @@ class VacationRequestTest extends FeatureTestCase { parent::setUp(); + Bus::fake(); + $this->polishHolidaysRetriever = $this->app->make(PolishHolidaysRetriever::class); } @@ -128,6 +132,8 @@ class VacationRequestTest extends FeatureTestCase $this->assertDatabaseHas("vacation_requests", [ "state" => VacationRequestState::Approved, ]); + + Bus::assertDispatched(SendVacationRequestDaysToGoogleCalendar::class); } public function testTechnicalApproverCanRejectVacationRequest(): void