ShuntRequestControllerTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Tools\Test\TestCase\Controller;
  3. use Cake\Core\Configure;
  4. use Cake\TestSuite\IntegrationTestTrait;
  5. use RuntimeException;
  6. use Shim\TestSuite\TestCase;
  7. use Tools\Controller\ShuntRequestController;
  8. #[\PHPUnit\Framework\Attributes\UsesClass(ShuntRequestController::class)]
  9. class ShuntRequestControllerTest extends TestCase {
  10. use IntegrationTestTrait;
  11. /**
  12. * @var array
  13. */
  14. protected array $fixtures = [
  15. 'plugin.Tools.Sessions',
  16. ];
  17. /**
  18. * @return void
  19. */
  20. public function setUp(): void {
  21. parent::setUp();
  22. $this->loadPlugins(['Tools']);
  23. Configure::write('Config.allowedLanguages', []);
  24. Configure::write('Config.defaultLanguage', null);
  25. }
  26. /**
  27. * @return void
  28. */
  29. public function testLanguage() {
  30. $this->disableErrorHandlerMiddleware();
  31. Configure::write('Config.defaultLanguage', 'de');
  32. Configure::write('Config.allowedLanguages', [
  33. 'de' => [
  34. 'locale' => 'de_DE',
  35. 'name' => 'Deutsch',
  36. ],
  37. ]);
  38. $this->post(['plugin' => 'Tools', 'controller' => 'ShuntRequest', 'action' => 'language']);
  39. $this->assertRedirect();
  40. }
  41. /**
  42. * @return void
  43. */
  44. public function testLanguageError() {
  45. $this->disableErrorHandlerMiddleware();
  46. $this->expectException(RuntimeException::class);
  47. $this->post(['plugin' => 'Tools', 'controller' => 'ShuntRequest', 'action' => 'language']);
  48. }
  49. }