Hello!
I wrote a small CMS in Slim, with authentication and so on. And it works fine
But I’ haven’t done many PHPUnit tests so far. I’m a beginner in testing. My entities are tested, but it’s really simple.
My simplest action is this:
namespace App\Actions\Pages;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Slim\Views\ViewInterface;
class PagesAction
{
private ViewInterface $view;
public function __construct(ViewInterface $view)
{
$this->view = $view;
}
public function __invoke(Request $request, Response $response, array $args = []): Response
{
$page = $args['page'];
$response = $this->view->render($response, $page, []);
return $response;
}
}
How can I test the action as easy as possible for me? I would like to understand it. Where is the best place to start?
I use my own slim skeleton, here, and not the official one. Was my other fun project.
Who can help me?
Thanks in advance