@@ -13,17 +17,18 @@ {{ blog_post.title }} - - Edit - + {% if is_granted('IS_AUTHENTICATED_FULLY') %} + + Edit + + {% endif %} {% if blog_post.banner %} - - + {% endif %} @@ -67,9 +72,12 @@ {% set left = 1 %} {% endif %} - {% for i in range(left, right) %} - {{ i }} - {% endfor %} + {% if pager.hasNextPage or pager.hasPreviousPage %} + {% for i in range(left, right) %} + {{ i }} + {% endfor %} + {% endif %} + {% if pager.hasNextPage %} Next diff --git a/templates/security/login.html.twig b/templates/security/login.html.twig new file mode 100644 index 0000000..9bb43ca --- /dev/null +++ b/templates/security/login.html.twig @@ -0,0 +1,44 @@ +{% extends 'base.html.twig' %} + +{% block title %}Log in!{% endblock %} + +{% block body %} + + + Please sign in + + {% if error %} + + {{ error.messageKey|trans(error.messageData, 'security') }} + + {% endif %} + + {% if app.user %} + + You are logged in as {{ app.user.userIdentifier }}, Logout + + {% endif %} + + + Email +{# #} + + + + Password + + + + + + Remember me + + + + + + Sign in + + + +{% endblock %} diff --git a/tests/AppBrowser.php b/tests/AppBrowser.php new file mode 100644 index 0000000..5aee69f --- /dev/null +++ b/tests/AppBrowser.php @@ -0,0 +1,18 @@ +client()->waitFor('html[aria-busy="true"]'); + + return $this; + } +} diff --git a/tests/AppPantherTestCase.php b/tests/AppPantherTestCase.php new file mode 100644 index 0000000..c35f369 --- /dev/null +++ b/tests/AppPantherTestCase.php @@ -0,0 +1,18 @@ +parentPantherBrowser($options, $kernelOptions, $managerOptions); + } +} diff --git a/tests/Browser/AuthenticationExtension.php b/tests/Browser/AuthenticationExtension.php new file mode 100644 index 0000000..f847985 --- /dev/null +++ b/tests/Browser/AuthenticationExtension.php @@ -0,0 +1,41 @@ +visit('/login') + ->fillField('username', $username) + ->fillField('password', $password) + ->click('Sign in'); + } + + public function logout(): self + { + return $this->visit('/logout'); + } + + public function assertLoggedIn(): self + { + $this->assertSee('Logout'); + + return $this; + } + + public function assertLoggedInAs(string $user): self + { + $this->assertSee($user); + + return $this; + } + + public function assertNotLoggedIn(): self + { + $this->assertSee('Login'); + + return $this; + } +} diff --git a/tests/Functional/Blog/CreateBlogPostTest.php b/tests/Functional/Blog/CreateBlogPostTest.php index 59af04b..51a49c6 100644 --- a/tests/Functional/Blog/CreateBlogPostTest.php +++ b/tests/Functional/Blog/CreateBlogPostTest.php @@ -2,7 +2,31 @@ namespace Tests\Functional\Blog; -class CreateBlogPostTest +use App\Factory\UserFactory; +use Tests\AppPantherTestCase; +use Zenstruck\Foundry\Test\Factories; +use Zenstruck\Foundry\Test\ResetDatabase; + +class CreateBlogPostTest extends AppPantherTestCase { + use ResetDatabase; + use Factories; + + public function testItWorks(): void + { + UserFactory::createOne(); + + // test there are no articles + $this->browser() + ->visit('/') + ->assertSee('No Articles found 😞') + ; + // login user + $this->pantherBrowser() + ->loginAs('test@mail.com', '1234') + ->waitForPageLoad() + ->assertOn('/') + ->assertLoggedIn(); + } } diff --git a/tests/Functional/Blog/DeleteBlogPostTest.php b/tests/Functional/Blog/DeleteBlogPostTest.php deleted file mode 100644 index d12ab6f..0000000 --- a/tests/Functional/Blog/DeleteBlogPostTest.php +++ /dev/null @@ -1,8 +0,0 @@ -