diff --git a/Tests/Application.php b/Tests/Application.php new file mode 100644 index 0000000..c688c8e --- /dev/null +++ b/Tests/Application.php @@ -0,0 +1,12 @@ + __DIR__ . '/../../app', + 'params' => [ + 'foo' => 'bar' + ], + ]; + $app = new Application($config); + + // Unique id test + $this->assertNotNull($app->getId()); + + // Base paths test + $this->assertEquals(realpath(__DIR__ . '/../../app'), $app->getBasePath()); + $this->assertEquals(realpath(__DIR__ . '/../../app/Modules'), $app->getModulePath()); + $this->assertEquals(realpath(__DIR__ . '/../../app/runtime'), $app->getRuntimePath()); + + // Params test + $this->assertEquals(['foo' => 'bar'], $app->getParams()->all()); + + // Timezones test + $this->assertEquals(date_default_timezone_get(), $app->getTimeZone()); + $app->setTimeZone('UTC'); + $this->assertEquals('UTC', $app->getTimeZone()); + + // Test Translate component + $this->assertInstanceOf('\Mindy\Locale\Translate', $app->getTranslate()); + } +} diff --git a/Tests/TestCase.php b/Tests/TestCase.php new file mode 100644 index 0000000..1ac51ae --- /dev/null +++ b/Tests/TestCase.php @@ -0,0 +1,11 @@ + + + + + + + + + + + + + ./Tests/Cases/Application/ + + + + + + benchmark + + + + + + src/ + + + + + + + + diff --git a/src/Mindy/Application/Application.php b/src/Mindy/Application/Application.php index 337cd0c..7399b6e 100644 --- a/src/Mindy/Application/Application.php +++ b/src/Mindy/Application/Application.php @@ -85,13 +85,6 @@ public function parseRoute() return $this->getUrlManager()->parseUrl($this->getRequest()); } - public function setComponents($components, $merge = true) - { - foreach ($components as $name => $component) { - $this->locator->set($name, $component); - } - } - /** * @throws \Mindy\Exception\Exception * @return \Modules\User\Models\User instance the user session information @@ -105,11 +98,6 @@ public function getUser() return $auth->getModel(); } - public function getComponent($id, $createIfNull = true) - { - return $this->locator->get($id, false); - } - /** * Creates the controller and performs the specified action. * @param string $route the route of the current request. See {@link createController} for more details. diff --git a/src/Mindy/Application/BaseApplication.php b/src/Mindy/Application/BaseApplication.php index 387e3d8..6cb7263 100644 --- a/src/Mindy/Application/BaseApplication.php +++ b/src/Mindy/Application/BaseApplication.php @@ -1067,4 +1067,11 @@ protected function registerCoreComponents() $this->locator = new ServiceLocator(); $this->setComponents($components); } + + public function setComponents($components, $merge = true) + { + foreach ($components as $name => $component) { + $this->locator->set($name, $component); + } + } }