-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Temp consutation and webnar to mail * Add templates for events approved and reject * Add variables to register temp * Add setTimezone for datetimes * Repair tests * add assert to test * add assert to test * add assert to test * add assert to test * Add yt problem event temp * Add event yt problem Co-authored-by: Hubert Krzysztofiak <[email protected]>
- Loading branch information
Showing
8 changed files
with
152 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace EscolaLms\TemplatesEmail\Providers; | ||
|
||
use EscolaLms\TemplatesEmail\Core\EmailChannel; | ||
use EscolaLms\TemplatesEmail\Youtube\YtProblemVariables; | ||
use EscolaLms\Youtube\Events\YtProblem; | ||
use Illuminate\Support\ServiceProvider; | ||
use EscolaLms\Templates\Facades\Template; | ||
|
||
class YoutubeTemplatesServiceProvider extends ServiceProvider | ||
{ | ||
public function boot() | ||
{ | ||
Template::register(YtProblem::class, EmailChannel::class, YtProblemVariables::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace EscolaLms\TemplatesEmail\Youtube; | ||
|
||
use Carbon\Carbon; | ||
use EscolaLms\Core\Models\User; | ||
use EscolaLms\Templates\Events\EventWrapper; | ||
use EscolaLms\TemplatesEmail\Core\EmailVariables; | ||
use EscolaLms\Webinar\Models\Webinar; | ||
use EscolaLms\Youtube\Facades\Youtube; | ||
|
||
abstract class CommonYoutubeVariables extends EmailVariables | ||
{ | ||
const VAR_USER_EMAIL = '@VarUserEmail'; | ||
|
||
public static function mockedVariables(?User $user = null): array | ||
{ | ||
$faker = \Faker\Factory::create(); | ||
return array_merge(parent::mockedVariables(), [ | ||
self::VAR_USER_EMAIL => $faker->email(), | ||
]); | ||
} | ||
|
||
public static function variablesFromEvent(EventWrapper $event): array | ||
{ | ||
return array_merge(parent::variablesFromEvent($event), [ | ||
self::VAR_USER_EMAIL => $event->getUser()->email | ||
]); | ||
} | ||
|
||
public static function requiredVariables(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public static function requiredVariablesInSection(string $sectionKey): array | ||
{ | ||
return []; | ||
} | ||
|
||
public static function assignableClass(): ?string | ||
{ | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace EscolaLms\TemplatesEmail\Youtube; | ||
|
||
class YtProblemVariables extends CommonYoutubeVariables | ||
{ | ||
|
||
public static function defaultSectionsContent(): array | ||
{ | ||
return [ | ||
'title' => __('Problem with Yt integration'), | ||
'content' => self::wrapWithMjml(__('<h1>Hello!</h1><p>There was a problem with youtube integration. Please verify it.</p>')), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace EscolaLms\TemplatesEmail\Tests\Api; | ||
|
||
use EscolaLms\Core\Models\User; | ||
use EscolaLms\Core\Tests\CreatesUsers; | ||
use EscolaLms\Templates\Database\Seeders\PermissionTableSeeder; | ||
use EscolaLms\Templates\Listeners\TemplateEventListener; | ||
use EscolaLms\Templates\Models\Template; | ||
use EscolaLms\TemplatesEmail\Core\EmailChannel; | ||
use EscolaLms\TemplatesEmail\Core\EmailMailable; | ||
use EscolaLms\TemplatesEmail\Tests\TestCase; | ||
use EscolaLms\Youtube\Dto\YTBroadcastDto; | ||
use EscolaLms\Youtube\EscolaLmsYoutubeServiceProvider; | ||
use EscolaLms\Youtube\Events\YtProblem; | ||
use EscolaLms\Youtube\Services\Contracts\YoutubeServiceContract; | ||
use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
use Illuminate\Foundation\Testing\WithFaker; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Event; | ||
use Illuminate\Support\Facades\Mail; | ||
use Illuminate\Support\Facades\Notification; | ||
|
||
class YoutubeTest extends TestCase | ||
{ | ||
use DatabaseTransactions, CreatesUsers, WithFaker; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
if (!class_exists(EscolaLmsYoutubeServiceProvider::class)) { | ||
$this->markTestSkipped('Youtube package not installed'); | ||
} | ||
$this->seed(PermissionTableSeeder::class); | ||
} | ||
|
||
public function testVerifyEmailAfterWrongYt() | ||
{ | ||
Event::fake(); | ||
Mail::fake(); | ||
|
||
$email = $this->faker->email; | ||
Config::set('services.youtube.email', $email); | ||
$ytServiceContract = app(YoutubeServiceContract::class); | ||
try { | ||
$ytServiceContract->generateYTStream(new YTBroadcastDto()); | ||
} catch (\Exception $ex) { | ||
// | ||
} | ||
$user = new User([ | ||
'email' => $email | ||
]); | ||
Event::assertDispatched(YtProblem::class, function (YtProblem $event) use ($user) { | ||
return $event->getUser()->email === $user->email; | ||
}); | ||
$listener = app(TemplateEventListener::class); | ||
$listener->handle(new YtProblem($user)); | ||
|
||
Mail::assertSent(EmailMailable::class, function (EmailMailable $mailable) use ($user) { | ||
$this->assertEquals(__('Problem with Yt integration'), $mailable->subject); | ||
$this->assertTrue($mailable->hasTo($user->email)); | ||
return true; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters