This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 5dd4a7e Author: Anna-Sokolowska <[email protected]> Date: Wed May 11 15:39:03 2022 +0200 #89 - cs-fix commit 88dc366 Merge: 56b5dfd 86a33bb Author: Anna-Sokolowska <[email protected]> Date: Wed May 11 13:33:24 2022 +0200 Merge remote-tracking branch 'origin/#89-unit-tests' into #89-unit-tests commit 56b5dfd Author: Anna-Sokolowska <[email protected]> Date: Wed May 11 13:32:32 2022 +0200 #89 - fix wrong admin invitation receiver commit d6cd834 Author: Anna-Sokolowska <[email protected]> Date: Wed May 11 13:29:20 2022 +0200 #89 - add organization profile scope bindings commit 86a33bb Author: Anna-Sokolowska <[email protected]> Date: Wed May 11 11:34:21 2022 +0200 #89 - add cache views commit d95551e Author: Anna-Sokolowska <[email protected]> Date: Wed May 11 09:21:08 2022 +0200 #89 - add .env.ci commit 202c4d7 Author: Anna-Sokolowska <[email protected]> Date: Wed May 11 06:37:01 2022 +0200 #89 - refactor tests commit a851f81 Merge: 5ae0b73 e554018 Author: Anna-Sokolowska <[email protected]> Date: Tue May 10 19:57:25 2022 +0200 Merge branch 'main' into #89-unit-tests commit 5ae0b73 Author: Anna-Sokolowska <[email protected]> Date: Tue May 10 19:53:53 2022 +0200 #89 - cs-fix commit 7d7edd2 Merge: dbcba11 9a47c51 Author: Anna-Sokolowska <[email protected]> Date: Tue May 10 09:53:13 2022 +0200 Merge branch 'main' into #89-unit-tests commit dbcba11 Author: Anna-Sokolowska <[email protected]> Date: Tue May 10 09:41:43 2022 +0200 #89 - basic features tests commit 8120c8d Merge: bd8c792 b24753d Author: Anna-Sokolowska <[email protected]> Date: Sat May 7 20:40:04 2022 +0200 Merge branch 'main' into #89-unit-tests commit bd8c792 Author: Anna-Sokolowska <[email protected]> Date: Fri May 6 13:22:59 2022 +0200 #89 - unit tests init
- Loading branch information
1 parent
ca081ae
commit 9fa1350
Showing
29 changed files
with
1,232 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
APP_NAME=Laravel | ||
APP_ENV=testing | ||
APP_KEY=base64:fDr4dLzbpxwzo9eDpy8of5b6/Dt2Pnvnd3lng8cf348= | ||
APP_DEBUG=true | ||
APP_URL=http://localhost | ||
APP_TIMEZONE='Europe/Warsaw' | ||
|
||
LOG_CHANNEL=stack | ||
LOG_LEVEL=debug | ||
|
||
BROADCAST_DRIVER=log | ||
CACHE_DRIVER=file | ||
FILESYSTEM_DRIVER=local | ||
QUEUE_CONNECTION=redis | ||
SESSION_DRIVER=file | ||
SESSION_LIFETIME=120 | ||
|
||
MEMCACHED_HOST=memcached |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
$app = new Illuminate\Foundation\Application( | ||
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) | ||
); | ||
|
||
$app->singleton( | ||
Illuminate\Contracts\Http\Kernel::class, | ||
Blumilk\Meetup\Core\Http\Kernel::class | ||
); | ||
|
||
$app->singleton( | ||
Illuminate\Contracts\Console\Kernel::class, | ||
Blumilk\Meetup\Core\Console\Kernel::class | ||
); | ||
|
||
$app->singleton( | ||
Illuminate\Contracts\Debug\ExceptionHandler::class, | ||
Blumilk\Meetup\Core\Exceptions\Handler::class | ||
); | ||
|
||
return $app; |
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,2 @@ | ||
* | ||
!.gitignore |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests; | ||
|
||
use Illuminate\Contracts\Console\Kernel; | ||
use Illuminate\Foundation\Application; | ||
|
||
trait CreatesApplication | ||
{ | ||
public function createApplication(): Application | ||
{ | ||
$app = require __DIR__ . "/../bootstrap/app.php"; | ||
|
||
$app->make(Kernel::class)->bootstrap(); | ||
|
||
return $app; | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Feature; | ||
|
||
use Blumilk\Meetup\Core\Models\Contact; | ||
use Blumilk\Meetup\Core\Notifications\ContactEmailNotification; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Support\Facades\Notification; | ||
use Tests\TestCase; | ||
|
||
class ContactTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
public function testUserCanSeeContactPage(): void | ||
{ | ||
$this->get("/contact") | ||
->assertOk(); | ||
} | ||
|
||
public function testUserCanSendContactForm(): void | ||
{ | ||
Notification::fake(); | ||
|
||
$this->post("/contact", [ | ||
"name" => "John", | ||
"email" => "[email protected]", | ||
"subject" => "Test subject", | ||
"message" => "Test message", | ||
]) | ||
->assertSessionHasNoErrors(); | ||
|
||
$this->assertDatabaseHas("contacts", [ | ||
"name" => "John", | ||
"email" => "[email protected]", | ||
"subject" => "Test subject", | ||
"message" => "Test message", | ||
]); | ||
|
||
$contact = Contact::query()->first(); | ||
|
||
Notification::assertSentTo([$contact], ContactEmailNotification::class); | ||
} | ||
|
||
public function testContactFormDataIsRequired(): void | ||
{ | ||
$this->post("/contact") | ||
->assertInvalid([ | ||
"name", | ||
"email", | ||
"subject", | ||
"message", | ||
]); | ||
} | ||
} |
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,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Feature; | ||
|
||
use Blumilk\Meetup\Core\Models\User; | ||
use Blumilk\Meetup\Core\Notifications\InvitationEmailNotification; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Support\Facades\Notification; | ||
use Spatie\Permission\Models\Role; | ||
use Tests\TestCase; | ||
|
||
class InviteAdminTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
public User $admin; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Role::create(["name" => "admin"]); | ||
$this->admin = User::factory()->create()->assignRole("admin"); | ||
} | ||
|
||
public function testAdminCanSeeSendInvitationPage(): void | ||
{ | ||
$this->actingAs($this->admin) | ||
->get("/invitation") | ||
->assertOk(); | ||
} | ||
|
||
public function testAdminCanSendInvitation(): void | ||
{ | ||
Notification::fake(); | ||
|
||
$this->actingAs($this->admin) | ||
->post("/invitation", [ | ||
"email" => "[email protected]", | ||
]) | ||
->assertSessionHasNoErrors(); | ||
|
||
Notification::assertSentOnDemand( | ||
InvitationEmailNotification::class, | ||
fn ($notification, $channels, $notifiable) => $notifiable->routes["mail"] === "[email protected]", | ||
); | ||
} | ||
|
||
public function testUserCannotSendInvitation(): void | ||
{ | ||
$user = User::factory()->create(); | ||
|
||
$this->actingAs($user) | ||
->get("/invitation") | ||
->assertLocation("/"); | ||
} | ||
} |
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,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Feature\Meetups; | ||
|
||
use Blumilk\Meetup\Core\Models\Meetup; | ||
use Blumilk\Meetup\Core\Models\User; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Spatie\Permission\Models\Role; | ||
use Tests\TestCase; | ||
|
||
class BrowseMeetupsTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
public User $admin; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Role::create(["name" => "admin"]); | ||
$this->admin = User::factory()->create()->assignRole("admin"); | ||
} | ||
|
||
public function testUserCanSeeMeetupsList(): void | ||
{ | ||
$meetups = Meetup::factory() | ||
->count(15) | ||
->for($this->admin) | ||
->create(); | ||
|
||
$this->assertDatabaseCount("meetups", 15); | ||
|
||
$response = $this->get(route("meetups")) | ||
->assertOk(); | ||
|
||
foreach ($meetups as $meetup) { | ||
$response->assertSee($meetup->logo_path) | ||
->assertSee($meetup->title) | ||
->assertSee($meetup->date->toDateString()) | ||
->assertSee($meetup->place); | ||
} | ||
} | ||
|
||
public function testMeetupsListIsPaginated(): void | ||
{ | ||
Meetup::factory() | ||
->count(30) | ||
->for($this->admin) | ||
->create(); | ||
|
||
$meetups = Meetup::query() | ||
->latest() | ||
->skip(20) | ||
->take(10); | ||
|
||
$this->assertDatabaseCount("meetups", 30); | ||
|
||
$response = $this->get(route("meetups") . "?page=2") | ||
->assertOk(); | ||
|
||
foreach ($meetups as $meetup) { | ||
$response->assertSee($meetup->logo_path) | ||
->assertSee($meetup->title) | ||
->assertSee($meetup->date->format("Y-m-d h:i")) | ||
->assertSee($meetup->place); | ||
} | ||
} | ||
} |
Oops, something went wrong.