You've already forked Php-Template
chore/dev-env (#6)
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 1m55s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 1m56s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m10s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 1m56s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m45s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 53s
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 1m55s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 1m56s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m10s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 1m56s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m45s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 53s
Reviewed-on: #6 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
This commit was merged in pull request #6.
This commit is contained in:
16
tests/Controllers/AbstractController.php
Normal file
16
tests/Controllers/AbstractController.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\Tests\Controllers;
|
||||
|
||||
use Nyholm\Psr7\ServerRequest;
|
||||
use Siteworxpro\Tests\Unit;
|
||||
|
||||
abstract class AbstractController extends Unit
|
||||
{
|
||||
protected function getMockRequest(string $method = 'GET', string $uri = '/'): ServerRequest
|
||||
{
|
||||
return new ServerRequest($method, $uri);
|
||||
}
|
||||
}
|
||||
54
tests/Controllers/ControllerTest.php
Normal file
54
tests/Controllers/ControllerTest.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\Tests\Controllers;
|
||||
|
||||
use Siteworxpro\App\Controllers\Controller;
|
||||
|
||||
class ControllerTest extends AbstractController
|
||||
{
|
||||
public function testNotFoundExceptions()
|
||||
{
|
||||
$testClass = new TestClass();
|
||||
|
||||
$this->expectException(\League\Route\Http\Exception\NotFoundException::class);
|
||||
$testClass->get($this->getMockRequest());
|
||||
}
|
||||
|
||||
public function testNotFoundExceptionPost()
|
||||
{
|
||||
$testClass = new TestClass();
|
||||
|
||||
$this->expectException(\League\Route\Http\Exception\NotFoundException::class);
|
||||
$testClass->post($this->getMockRequest());
|
||||
}
|
||||
|
||||
public function testNotFoundExceptionPut()
|
||||
{
|
||||
$testClass = new TestClass();
|
||||
|
||||
$this->expectException(\League\Route\Http\Exception\NotFoundException::class);
|
||||
$testClass->put($this->getMockRequest());
|
||||
}
|
||||
|
||||
public function testNotFoundExceptionDelete()
|
||||
{
|
||||
$testClass = new TestClass();
|
||||
|
||||
$this->expectException(\League\Route\Http\Exception\NotFoundException::class);
|
||||
$testClass->delete($this->getMockRequest());
|
||||
}
|
||||
|
||||
public function testNotFoundExceptionPatch()
|
||||
{
|
||||
$testClass = new TestClass();
|
||||
|
||||
$this->expectException(\League\Route\Http\Exception\NotFoundException::class);
|
||||
$testClass->patch($this->getMockRequest());
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass extends Controller // phpcs:ignore
|
||||
{
|
||||
}
|
||||
25
tests/Controllers/IndexControllerTest.php
Normal file
25
tests/Controllers/IndexControllerTest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\Tests\Controllers;
|
||||
|
||||
use Siteworxpro\App\Controllers\IndexController;
|
||||
|
||||
class IndexControllerTest extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function testGet(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
|
||||
$controller = new IndexController();
|
||||
|
||||
$response = $controller->get($this->getMockRequest());
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEquals('{"status_code":200,"message":"Server is running"}', (string)$response->getBody());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user