new: pkg: add test cases to back-end w/ real database connection in it #10
This commit is contained in:
145
tests/Controller/GameControllerTest.php
Normal file
145
tests/Controller/GameControllerTest.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of the SplendidBear Websites' projects.
|
||||
*
|
||||
* Copyright (c) 2026 @ www.splendidbear.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\Attributes\TestDox;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use App\Tests\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Class GameControllerTest
|
||||
*
|
||||
* @package App\Tests\Controller
|
||||
* @author Lang <https://www.splendidbear.org>
|
||||
* @category Class
|
||||
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html GNU Lesser General Public License
|
||||
* @link www.splendidbear.org
|
||||
* @since 2026. 04. 21.
|
||||
*/
|
||||
#[TestDox('Game Controller')]
|
||||
class GameControllerTest extends WebTestCase
|
||||
{
|
||||
private KernelBrowser $client;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->client = static::createClient();
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Homepage loads successfully with navigation links')]
|
||||
public function homepageLoadsSuccessfully(): void
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/');
|
||||
|
||||
self::assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
self::assertSelectorExists('h1');
|
||||
self::assertSelectorExists('a[href="/play"]');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Play page loads successfully')]
|
||||
public function playPageLoadsSuccessfully(): void
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/play');
|
||||
|
||||
self::assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
self::assertResponseHasHeader('Content-Type');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Play page with game association loads successfully')]
|
||||
public function playPageWithGameAssocLoadsSuccessfully(): void
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/play/testgame123');
|
||||
|
||||
self::assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
self::assertResponseHasHeader('Content-Type');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Privacy policy page loads successfully')]
|
||||
public function privacyPolicyPageLoadsSuccessfully(): void
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/privacy-policy');
|
||||
|
||||
self::assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
self::assertSelectorExists('h1');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Terms of service page loads successfully')]
|
||||
public function termsOfServicePageLoadsSuccessfully(): void
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/terms-of-service');
|
||||
|
||||
self::assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
self::assertSelectorExists('h1');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Contact page loads successfully with form')]
|
||||
public function contactPageLoadsSuccessfully(): void
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/contact');
|
||||
|
||||
self::assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
self::assertSelectorExists('form');
|
||||
self::assertSelectorExists('button[type="submit"]');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Landing page loads successfully with play link')]
|
||||
public function landingPageLoadsSuccessfully(): void
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/landing-page');
|
||||
|
||||
self::assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
self::assertSelectorExists('h1');
|
||||
self::assertSelectorExists('a[href="/play"]');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Rules page loads successfully')]
|
||||
public function rulesPageLoadsSuccessfully(): void
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/rules');
|
||||
|
||||
self::assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
self::assertSelectorExists('h1');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Homepage contains navigation links to play, login, and register')]
|
||||
public function homepageContainsNavigationLinks(): void
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/');
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
self::assertSelectorExists('a[href="/play"]');
|
||||
self::assertSelectorExists('a[href="/login"]');
|
||||
self::assertSelectorExists('a[href="/register"]');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestDox('Play page has correct meta tags for SEO and social sharing')]
|
||||
public function playPageHasCorrectMetaTags(): void
|
||||
{
|
||||
$this->client->request('GET', '/play');
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
self::assertSelectorExists('meta[name="description"]');
|
||||
self::assertSelectorExists('meta[property="og:title"]');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user