2
0

AppTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace Test\Michel\Framework\Core;
  3. use InvalidArgumentException;
  4. use Michel\Framework\Core\App;
  5. use Michel\UniTester\TestCase;
  6. use Psr\Container\ContainerInterface;
  7. use Psr\Http\Message\ResponseFactoryInterface;
  8. use Psr\Http\Message\ServerRequestInterface;
  9. class AppTest extends TestCase
  10. {
  11. protected function setUp(): void
  12. {
  13. }
  14. protected function tearDown(): void
  15. {
  16. // TODO: Implement tearDown() method.
  17. }
  18. protected function execute(): void
  19. {
  20. $this->testInitWithInValidPath();
  21. App::initWithPath(__DIR__ . '/config/framework.php');
  22. $this->testCreateServerRequest();
  23. $this->testGetResponseFactory();
  24. $this->testCreateContainer();
  25. $this->testGetCustomEnvironments();
  26. }
  27. public function testInitWithInValidPath()
  28. {
  29. $path = 'path/to/your/options.php';
  30. $this->expectException(InvalidArgumentException::class, function () use($path) {
  31. App::initWithPath($path);
  32. });
  33. }
  34. public function testCreateServerRequest()
  35. {
  36. $request = App::createServerRequest();
  37. $this->assertInstanceOf(ServerRequestInterface::class, $request);
  38. }
  39. public function testGetResponseFactory()
  40. {
  41. $responseFactory = App::getResponseFactory();
  42. $this->assertInstanceOf(ResponseFactoryInterface::class, $responseFactory);
  43. }
  44. public function testCreateContainer()
  45. {
  46. $definitions = []; // Your container definitions
  47. $options = []; // Your container options
  48. $container = App::createContainer($definitions, $options);
  49. $this->assertInstanceOf(ContainerInterface::class, $container);
  50. $container = App::getContainer();
  51. $this->assertInstanceOf(ContainerInterface::class, $container);
  52. }
  53. public function testGetCustomEnvironments()
  54. {
  55. $environments = App::getCustomEnvironments();
  56. foreach ($environments as $environment) {
  57. $this->assertTrue(is_string($environment));
  58. }
  59. }
  60. }