diff --git a/tests/Checks/EnvTypeCheckTest.php b/tests/Checks/EnvTypeCheckTest.php new file mode 100644 index 0000000..4af1e39 --- /dev/null +++ b/tests/Checks/EnvTypeCheckTest.php @@ -0,0 +1,73 @@ +get(Kernel::class); + $kernel->setEnvironment('live'); + + $this->assertTrue(Director::isLive()); + + $checker = Injector::inst()->get(EnvSettingCheck::class); + $result = $checker->check(); + + $this->assertSame($result[0], EnvironmentCheck::OK); + } + + /** + * Check is ERROR when in test mode + * + * @return void + */ + public function testEnvSettingTest() + { + /** @var Kernel $kernel */ + $kernel = Injector::inst()->get(Kernel::class); + $kernel->setEnvironment('test'); + + $this->assertTrue(Director::isTest()); + + $checker = Injector::inst()->get(EnvSettingCheck::class); + $result = $checker->check(); + + $this->assertSame($result[0], EnvironmentCheck::ERROR); + } + + /** + * Check is ERROR when in dev mode + * + * @return void + */ + public function testEnvSettingDev() + { + /** @var Kernel $kernel */ + $kernel = Injector::inst()->get(Kernel::class); + $kernel->setEnvironment('dev'); + + $this->assertTrue(Director::isDev()); + + $checker = Injector::inst()->get(EnvSettingCheck::class); + $result = $checker->check(); + + $this->assertSame($result[0], EnvironmentCheck::ERROR); + } +}