first commit

This commit is contained in:
2026-03-11 22:04:36 +04:00
commit bae063a4fa
69 changed files with 12411 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');
$response->assertStatus(200);
}
}
@@ -0,0 +1,66 @@
<?php
namespace Tests\Feature;
use App\Exceptions\DuplicateGameAccountException;
use App\Services\AzerothCoreAccountRegistrar;
use Mockery\MockInterface;
use Tests\TestCase;
class GameAccountRegistrationTest extends TestCase
{
public function test_registration_form_submits_successfully(): void
{
$this->mock(AzerothCoreAccountRegistrar::class, function (MockInterface $mock): void {
$mock->shouldReceive('register')
->once()
->with('playerone', 'player@example.com', 'Pass1234')
->andReturn(['id' => 77, 'username' => 'PLAYERONE']);
});
$response = $this->from(route('landing.index'))->post(route('game-account.store'), [
'username' => 'playerone',
'email' => 'player@example.com',
'password' => 'Pass1234',
'password_confirmation' => 'Pass1234',
'terms' => '1',
]);
$response->assertRedirect(route('landing.index'));
$response->assertSessionHas('registration_success');
}
public function test_registration_validation_rejects_invalid_data(): void
{
$response = $this->from(route('landing.index'))->post(route('game-account.store'), [
'username' => 'игрок!',
'email' => 'not-an-email',
'password' => '123',
'password_confirmation' => '456',
'terms' => '',
]);
$response->assertRedirect(route('landing.index'));
$response->assertSessionHasErrors(['username', 'email', 'password', 'terms']);
}
public function test_duplicate_username_is_reported_back_to_the_form(): void
{
$this->mock(AzerothCoreAccountRegistrar::class, function (MockInterface $mock): void {
$mock->shouldReceive('register')
->once()
->andThrow(DuplicateGameAccountException::forUsername());
});
$response = $this->from(route('landing.index'))->post(route('game-account.store'), [
'username' => 'playerone',
'email' => 'player@example.com',
'password' => 'Pass1234',
'password_confirmation' => 'Pass1234',
'terms' => '1',
]);
$response->assertRedirect(route('landing.index'));
$response->assertSessionHasErrors(['username']);
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
class LandingPageTest extends TestCase
{
public function test_landing_page_loads_successfully(): void
{
$response = $this->get(route('landing.index'));
$response->assertOk();
$response->assertSee('Создать игровой аккаунт');
$response->assertSee(config('moonwell.realm.server_name'));
}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
//
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}