-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved Integration test to their own directory
Renamed the Abstract Integration class Refactored existing test currently one test is failing for LogoutHandlerTest Signed-off-by: Joey Smith <[email protected]> Signed-off-by: Joey Smith <[email protected]>
- Loading branch information
Showing
8 changed files
with
101 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 3 additions & 8 deletions
11
...st/Storage/SavePageCommandHandlerTest.php → ...ntegration/SavePageCommandHandlerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Integration; | ||
|
||
use Mezzio\Application; | ||
use Mezzio\MiddlewareFactory; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Container\ContainerInterface; | ||
|
||
abstract class AbstractTestCase extends TestCase | ||
{ | ||
/** @var Application $app */ | ||
protected $app; | ||
/** @var ContainerInterface */ | ||
protected $container; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->initContainer(); | ||
// $this->initApp(); | ||
// $this->initPipeline(); | ||
} | ||
|
||
protected function initContainer(): void | ||
{ | ||
$this->container = require __DIR__ . '/../../../config/container.php'; | ||
} | ||
|
||
protected function initApp(): void | ||
{ | ||
/** @var Application */ | ||
$this->app = $this->container->get(Application::class); | ||
} | ||
|
||
protected function initPipeline(): void | ||
{ | ||
/** @var MiddlewareFactory */ | ||
$factory = $this->container->get(MiddlewareFactory::class); | ||
(require __DIR__ . '/../../../config/pipeline.php')($this->app, $factory, $this->container); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace UserManagerTest\Integration; | ||
|
||
use Laminas\Diactoros\Response; | ||
use Laminas\Diactoros\ServerRequest; | ||
use Laminas\Diactoros\Uri; | ||
use Mezzio\Authentication\UserInterface; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use Test\Integration\AbstractTestCase; | ||
|
||
/** | ||
* | ||
* @runTestsInSeparateProcesses | ||
* @preserveGlobalState disabled | ||
*/ | ||
final class LogoutHandlerTest extends AbstractTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->initApp(); | ||
$this->initPipeline(); | ||
} | ||
|
||
public function testUserIsLoggedOut(): void | ||
{ | ||
$sessionData = [ | ||
'username' => 'jsmith', | ||
'roles' => [ | ||
'Administrator', | ||
], | ||
]; | ||
$_SESSION[UserInterface::class] = $sessionData; | ||
$uri = new Uri('/logout'); | ||
$request = new ServerRequest([], [], $uri); | ||
$request->withAttribute(UserInterface::class, $sessionData); | ||
/** @var Response */ | ||
$response = $this->app->handle($request); | ||
$this->assertEquals(302, $response->getStatusCode()); | ||
$this->assertEquals('/user/login', $response->getHeaderLine('Location')); | ||
} | ||
} |