Rewrite the test, which works, yet doesn't work when running the actual site?
This commit is contained in:
parent
d782bd9081
commit
b9b62c2d5c
@ -114,7 +114,7 @@ class Bootstrap
|
|||||||
*/
|
*/
|
||||||
LoggerInterface::class => function() {
|
LoggerInterface::class => function() {
|
||||||
$logger = new Logger("default");
|
$logger = new Logger("default");
|
||||||
$logger->pushHandler(new StreamHandler('php://stdout', Level::Warning));
|
$logger->pushHandler(new StreamHandler('php://stdout', Level::Info));
|
||||||
return $logger;
|
return $logger;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -132,7 +132,11 @@ class Bootstrap
|
|||||||
return $container->get(SessionInterface::class)->getFlash();
|
return $container->get(SessionInterface::class)->getFlash();
|
||||||
},
|
},
|
||||||
SessionMiddleware::class => function (ContainerInterface $container) {
|
SessionMiddleware::class => function (ContainerInterface $container) {
|
||||||
return new SessionMiddleware($container->get(SessionInterface::class));
|
return new SessionMiddleware(
|
||||||
|
$container->get(SessionManagerInterface::class),
|
||||||
|
$container->get(SessionInterface::class),
|
||||||
|
$container->get(LoggerInterface::class)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
namespace Slovocast\Middleware;
|
namespace Slovocast\Middleware;
|
||||||
|
|
||||||
use Odan\Session\SessionManagerInterface;
|
use Odan\Session\SessionManagerInterface;
|
||||||
|
use Odan\Session\SessionInterface;
|
||||||
use Psr\Http\Server\MiddlewareInterface;
|
use Psr\Http\Server\MiddlewareInterface;
|
||||||
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
|
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
use Psr\Http\Message\ResponseInterface as Response;
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a session on every single request, regardless. There may be a reason
|
* Start a session on every single request, regardless. There may be a reason
|
||||||
@ -15,7 +17,9 @@ use Psr\Http\Message\ResponseInterface as Response;
|
|||||||
class SessionMiddleware implements MiddlewareInterface
|
class SessionMiddleware implements MiddlewareInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private SessionManagerInterface $sessionManager
|
private SessionManagerInterface $sessionManager,
|
||||||
|
private SessionInterface $session,
|
||||||
|
private LoggerInterface $logger
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
public function process(Request $request, RequestHandler $handler): Response
|
public function process(Request $request, RequestHandler $handler): Response
|
||||||
@ -23,7 +27,7 @@ class SessionMiddleware implements MiddlewareInterface
|
|||||||
if (!$this->sessionManager->isStarted()) {
|
if (!$this->sessionManager->isStarted()) {
|
||||||
$this->sessionManager->start();
|
$this->sessionManager->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $handler->handle($request);
|
return $handler->handle($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,7 @@ class Middlewares
|
|||||||
/** @var ContainerInterface $container */
|
/** @var ContainerInterface $container */
|
||||||
$container = $app->getContainer();
|
$container = $app->getContainer();
|
||||||
|
|
||||||
/**
|
/** @var Configuration $config */
|
||||||
* @var Configuration $config
|
|
||||||
*/
|
|
||||||
$config = $container->get('config');
|
$config = $container->get('config');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,7 +128,8 @@ class ControllerTest extends TestCase
|
|||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
$body->read($body->getSize());
|
$body->read($body->getSize());
|
||||||
// the flash class is in the body for this test case
|
// the flash class is in the body for this test case
|
||||||
$this->assertTrue((bool) preg_match('/class\=\"flash/', $body));
|
$this->assertTrue(str_contains($body, "flash"));
|
||||||
|
$this->assertTrue(str_contains($body, "Error message"));
|
||||||
|
|
||||||
//$errorMessages = $flash->get('error');
|
//$errorMessages = $flash->get('error');
|
||||||
//$this->assertNotEmpty($errorMessages);
|
//$this->assertNotEmpty($errorMessages);
|
||||||
|
@ -114,7 +114,7 @@ class RegisterUserActionTest extends TestCase
|
|||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
$app = $this->getAppInstance();
|
$app = $this->getAppInstance();
|
||||||
|
|
||||||
/** @var $container \DI\Cotnainer */
|
/** @var $container \DI\Container */
|
||||||
$container = $app->getContainer();
|
$container = $app->getContainer();
|
||||||
|
|
||||||
$userRepository = $this->prophesize(UserRepositoryInterface::class);
|
$userRepository = $this->prophesize(UserRepositoryInterface::class);
|
||||||
|
Loading…
Reference in New Issue
Block a user