|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Tests\Unit\Http\Controllers; |
| 4 | + |
| 5 | +use Mockery as m; |
| 6 | +use Prologue\Alerts\AlertsMessageBag; |
| 7 | +use Illuminate\Contracts\Console\Kernel; |
| 8 | +use Illuminate\Contracts\Encryption\Encrypter; |
| 9 | +use Illuminate\Contracts\Config\Repository as ConfigRepository; |
| 10 | +use Pterodactyl\Http\Controllers\Admin\Settings\MailController; |
| 11 | +use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface; |
| 12 | + |
| 13 | +class MailControllerTest extends ControllerTestCase |
| 14 | +{ |
| 15 | + /** |
| 16 | + * @var \Prologue\Alerts\AlertsMessageBag |
| 17 | + */ |
| 18 | + private $alert; |
| 19 | + |
| 20 | + /** |
| 21 | + * @var \Illuminate\Contracts\Config\Repository |
| 22 | + */ |
| 23 | + private $configRepository; |
| 24 | + |
| 25 | + /** |
| 26 | + * @var \Illuminate\Contracts\Encryption\Encrypter |
| 27 | + */ |
| 28 | + private $encrypter; |
| 29 | + |
| 30 | + /** |
| 31 | + * @var \Illuminate\Contracts\Console\Kernel |
| 32 | + */ |
| 33 | + private $kernel; |
| 34 | + |
| 35 | + /** |
| 36 | + * @var \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface |
| 37 | + */ |
| 38 | + private $settingsRepositoryInterface; |
| 39 | + |
| 40 | + /** |
| 41 | + * Setup tests. |
| 42 | + */ |
| 43 | + public function setUp() |
| 44 | + { |
| 45 | + parent::setUp(); |
| 46 | + |
| 47 | + $this->alert = m::mock(AlertsMessageBag::class); |
| 48 | + $this->configRepository = m::mock(ConfigRepository::class); |
| 49 | + $this->encrypter = m::mock(Encrypter::class); |
| 50 | + $this->kernel = m::mock(Kernel::class); |
| 51 | + $this->settingsRepositoryInterface = m::mock(SettingsRepositoryInterface::class); |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Test the mail controller for viewing mail settings page. |
| 56 | + */ |
| 57 | + public function testIndex() |
| 58 | + { |
| 59 | + $this->configRepository->shouldReceive('get'); |
| 60 | + |
| 61 | + $response = $this->getController()->index(); |
| 62 | + |
| 63 | + $this->assertIsViewResponse($response); |
| 64 | + $this->assertViewNameEquals('admin.settings.mail', $response); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Prepare a MailController using our mocks. |
| 69 | + * |
| 70 | + * @return MailController |
| 71 | + */ |
| 72 | + public function getController() |
| 73 | + { |
| 74 | + return new MailController( |
| 75 | + $this->alert, |
| 76 | + $this->configRepository, |
| 77 | + $this->encrypter, |
| 78 | + $this->kernel, |
| 79 | + $this->settingsRepositoryInterface |
| 80 | + ); |
| 81 | + } |
| 82 | +} |
0 commit comments