You've already forked php-auth
generated from siteworxpro/Php-Template
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());
|
|
}
|
|
}
|