-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests and workflow. Also, fixed some little bugs.
- Loading branch information
Showing
13 changed files
with
128 additions
and
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
php: [7.2.5, 8.0] | ||
stability: [prefer-stable] | ||
|
||
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo | ||
coverage: none | ||
|
||
- name: Setup problem matchers | ||
run: | | ||
echo "::add-matcher::${{ runner.tool_cache }}/php.json" | ||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
- name: Install dependencies | ||
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction | ||
|
||
- name: Execute tests | ||
run: composer test |
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
/index.php | ||
/.htaccess | ||
.idea | ||
.phpunit.result.cache | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
RewriteEngine On | ||
RewriteBase /tests | ||
RewriteBase /tests/Example | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteRule ^ index.php [QSA,L] |
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 Buki\Tests\Example\Controllers; | ||
|
||
use Buki\Router\Http\Controller; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class TestController extends Controller | ||
{ | ||
public function main(): string | ||
{ | ||
return 'controller route'; | ||
} | ||
|
||
public function foo(Response $response): Response | ||
{ | ||
$response->setContent('Foo in TestController!'); | ||
|
||
return $response; | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace Buki\Tests\Example\Middlewares; | ||
|
||
use Buki\Router\Http\Middleware; | ||
|
||
class TestMiddleware extends Middleware | ||
{ | ||
public function handle(): bool | ||
{ | ||
return true; | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
require __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
$params = [ | ||
'paths' => [ | ||
'controllers' => __DIR__ . '/Controllers', | ||
'middlewares' => __DIR__ . '/Middlewares', | ||
], | ||
'namespaces' => [ | ||
'controllers' => 'Buki\\Tests\\Example\\Controllers', | ||
'middlewares' => 'Buki\\Tests\\Example\\Middlewares', | ||
], | ||
'base_folder' => __DIR__, | ||
'main_method' => 'main', | ||
]; | ||
|
||
$router = new \Buki\Router\Router($params); | ||
|
||
$router->get('/', function() { | ||
return 'Hello World!'; | ||
}); | ||
|
||
$router->get('/test', 'TestController@main'); | ||
|
||
$router->controller('/controller', 'TestController'); | ||
|
||
$router->run(); |
File renamed without changes.
File renamed without changes.
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 was deleted.
Oops, something went wrong.