52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Models;
|
|
|
|
use App\Models\Project;
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class ProjectTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp(); // TODO: Change the autogenerated stub
|
|
}
|
|
|
|
/** @test */
|
|
public function it_should_return_the_correct_attachment_path()
|
|
{
|
|
$project = Project::factory()->create(['name' => 'Test Project']);
|
|
$this->assertStringEndsWith(
|
|
'/storage/test_project/attachments',
|
|
$project->attachment_path
|
|
);
|
|
}
|
|
|
|
/** @test */
|
|
public function it_can_add_a_mailing_and_attachment()
|
|
{
|
|
$project = Project::factory()->create();
|
|
$project->mailings()->create([
|
|
'subject' => 'Test Subject',
|
|
'message' => 'Test Message',
|
|
]);
|
|
$fileFake = \Illuminate\Http\UploadedFile::fake()->create('test.pdf');
|
|
$project->mailings()->first()->addAttachment('test.pdf', $fileFake);
|
|
|
|
$this->assertCount(1, $project->mailings);
|
|
$this->assertCount(1, $project->mailings()->first()->attachments);
|
|
}
|
|
|
|
|
|
/** @test */
|
|
public function when_running_the_seeder_their_are_three_projects(): void
|
|
{
|
|
$this->seed();
|
|
$this->assertCount(3,Project::all());
|
|
}
|
|
}
|