You've already forked Php-Template
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m40s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 2m42s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 2m53s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m55s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 2m42s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m24s
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Siteworxpro\Tests\Controllers;
|
|
|
|
use League\Tactician\CommandBus;
|
|
use Siteworxpro\App\Controllers\IndexController;
|
|
|
|
class IndexControllerTest extends AbstractController
|
|
{
|
|
/**
|
|
* @throws \JsonException|\ReflectionException
|
|
*/
|
|
public function testGet(): void
|
|
{
|
|
$this->assertTrue(true);
|
|
|
|
$this->getContainer()->bind(CommandBus::class, function () {
|
|
return \Mockery::mock(CommandBus::class)
|
|
->shouldReceive('handle')
|
|
->andReturn('Hello World')
|
|
->getMock();
|
|
});
|
|
|
|
$controller = new IndexController();
|
|
|
|
$response = $controller->get($this->getMockRequest());
|
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
|
$this->assertEquals('{"message":"Server is running. Hello World"}', (string)$response->getBody());
|
|
}
|
|
|
|
/**
|
|
* @throws \JsonException
|
|
*/
|
|
public function testPost(): void
|
|
{
|
|
$this->assertTrue(true);
|
|
|
|
$controller = new IndexController();
|
|
|
|
$response = $controller->post($this->getMockRequest());
|
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
|
$this->assertEquals('{"message":"POST request received"}', (string)$response->getBody());
|
|
}
|
|
}
|