-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- removes the previous error handling logic in route() method (wip) - moves the locale folder from src/ to project root - adds translation strings to error messages - adds error messages for en_US locale - do not load Woops if ENV var is 'PRODUCTION' - adds tests for DIModule - improved tests for error handlers - adds a test for route parameters - updates dependencies in composer - do not try to find the Config instance path - check if .env is readable/exists for configuration - uses `CurlyFormatter` for i18n messages (updates from [kodedphp/i18n](https://github.com/kodedphp/i18n/releases/tag/0.9.2)) - fixes the default translation.dir path (updates from [kodedphp/stdlib](kodedphp/stdlib@331dabc))
- Loading branch information
Showing
20 changed files
with
222 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
return [ | ||
'language' => 'English', | ||
'messages' => [ | ||
'koded.handler.wrong.type' => '"type" must be an exception type', | ||
'koded.handler.missing' => 'Error handler must either be specified explicitly, or defined as a static method named "handle" that is a member of the given exception type', | ||
'koded.middleware.implements' => 'A middleware class {0} must implement {1}', | ||
|
||
'koded.router.noSlash' => 'URI template must begin with \'/\'', | ||
'koded.router.duplicateSlashes' => 'URI template has duplicate slashes', | ||
'koded.router.pcre.compilation' => 'PCRE compilation error. {0}', | ||
'koded.router.invalidRoute.title' => 'Invalid route. No regular expression provided', | ||
'koded.router.invalidRoute.detail' => 'Provide a proper PCRE regular expression', | ||
'koded.router.invalidParam.title' => "Invalid route parameter type '{0}'", | ||
'koded.router.invalidParam.detail' => 'Use one of the supported parameter types', | ||
'koded.router.duplicateRoute.title' => 'Duplicate route', | ||
'koded.router.duplicateRoute.detail' => 'Detected a multiple route definitions. The URI template for "%s" conflicts with an already registered route "%s".', | ||
'koded.router.multiPaths.title' => 'Invalid route. Multiple path parameters in the route template detected', | ||
'koded.router.multiPaths.detail' => 'Only one "path" type is allowed as URI parameter', | ||
] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Tests\Koded\Framework; | ||
|
||
use Koded\Framework\App; | ||
use PHPUnit\Framework\TestCase; | ||
use function date_default_timezone_get; | ||
use function date_default_timezone_set; | ||
|
||
class AppTest extends TestCase | ||
{ | ||
public function test_construct_sets_timezone_to_utc() | ||
{ | ||
date_default_timezone_set('Europe/Berlin'); | ||
|
||
new App; | ||
|
||
$this->assertEquals('UTC', date_default_timezone_get(), | ||
'App instance always sets the default timezone to UTC'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Tests\Koded\Framework; | ||
|
||
use Koded\Framework\App; | ||
use Koded\Stdlib\Config; | ||
use PHPUnit\Framework\TestCase; | ||
use function Koded\Stdlib\env; | ||
|
||
class DIModuleConfigurationTest extends TestCase | ||
{ | ||
use ObjectPropertyTrait; | ||
|
||
/** | ||
* @dataProvider configs | ||
*/ | ||
public function test_loading_configuration($config) | ||
{ | ||
$app = (new App( | ||
config: $config, | ||
)); | ||
|
||
/** @var Config $config */ | ||
$config = $this | ||
->objectProperty($app, 'container') | ||
->get(Config::class); | ||
|
||
$this->assertSame('bar', $config->get('test.foo')); | ||
$this->assertSame('BAR', env('TEST_FOO'), | ||
'ENV variables are loaded from .env in the configured root directory'); | ||
|
||
$this->assertSame([ | ||
__DIR__ . '/Fixtures/test-autoloader.php', | ||
], $config->get('autoloaders')); | ||
|
||
$this->assertTrue(class_exists(\TestAutoloadedClass::class), | ||
'Classes are loaded from "autoloaders" directive'); | ||
} | ||
|
||
public function configs() | ||
{ | ||
return [ | ||
[__DIR__ . '/Fixtures/test-conf.php'], | ||
[(new Config(__DIR__ . '/Fixtures'))->fromPhpFile(__DIR__ . '/Fixtures/test-conf.php')] | ||
]; | ||
} | ||
} |
Oops, something went wrong.