diff --git a/app/src/Domain/Repository/UserRepositoryInterface.php b/app/src/Domain/Repository/UserRepositoryInterface.php index 81152d9..e6eb05a 100644 --- a/app/src/Domain/Repository/UserRepositoryInterface.php +++ b/app/src/Domain/Repository/UserRepositoryInterface.php @@ -2,7 +2,7 @@ namespace Slovocast\Domain\Repository; -use Slovocast\Domain\Model\User; +use Slovocast\Domain\Entity\User; interface UserRepositoryInterface { diff --git a/app/templates/user/register.twig b/app/templates/user/register.twig index fa53884..4fec4a9 100644 --- a/app/templates/user/register.twig +++ b/app/templates/user/register.twig @@ -1,6 +1,6 @@ -{% extends 'layouts/skeleton' %} +{% extends 'layouts/skeleton.twig' %} -{% block "content" %} +{% block content %}
diff --git a/app/tests/Controller/User/RegisterUserActionTest.php b/app/tests/Controller/User/RegisterUserActionTest.php index 018b40b..8a9fff2 100644 --- a/app/tests/Controller/User/RegisterUserActionTest.php +++ b/app/tests/Controller/User/RegisterUserActionTest.php @@ -3,12 +3,43 @@ namespace Slovocast\Tests\Controller\User; use Slovocast\Tests\TestCase; +use Slovocast\Domain\Repository\UserRepositoryInterface; +use Slovocast\Domain\Entity\User; class RegisterUserActionTest extends TestCase { + protected function getUser(): User + { + return User::fromArray([ + 'email' => 'dave@slovocast.com', + 'name' => 'Dave SH', + 'password' => 'hashed_password' + ]); + } + public function testSuccessfulRegistration(): void { + $user = $this->getUser(); + $prophecy = $this->getProphet() + ->prophesize(UserRepositoryInterface::class); + $prophecy->save($user)->willReturn(true); + + $app = $this->getAppInstance(); + + /** @var \DI\Container */ + $container = $app->getContainer(); + $container->set(UserRepositoryInterface::class, $prophecy->reveal()); + + $request = $this->createRequest('POST', '/users/register')->withParsedBody([ + 'email' => 'dave@slovocast.com', + 'name' => 'Dave SH', + 'password' => 'hashed_password', + 'checked_password' => 'hashed_password' + ]); + + $response = $app->handle($request); + $this->assertEquals(200, $response->getStatusCode()); } public function testFailingRegistration(): void diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php index ad80568..486bb24 100644 --- a/app/tests/TestCase.php +++ b/app/tests/TestCase.php @@ -3,7 +3,7 @@ namespace Slovocast\Tests; use PHPUnit\Framework\TestCase as PHPUnit_TestCase; -use Prophecy\PhpUnit\ProphecyTrait; +use Prophecy\Prophet; use Psr\Http\Message\ServerRequestInterface as Request; use Slim\App; use Slim\Psr7\Factory\StreamFactory; @@ -18,7 +18,6 @@ use Slovocast\Bootstrap; */ class TestCase extends PHPUnit_TestCase { - use ProphecyTrait; /** * Generate an instance of the Application */ @@ -59,4 +58,9 @@ class TestCase extends PHPUnit_TestCase $stream ); } + + public function getProphet(): Prophet + { + return new Prophet(); + } }