test element parent scope
This commit is contained in:
parent
fcc6ade8f3
commit
eccfed2350
1 changed files with 26 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ use App\Set\SetRepository;
|
||||||
use App\Shared\ValueObject\EmailAddress;
|
use App\Shared\ValueObject\EmailAddress;
|
||||||
use App\User\CreateUserDto;
|
use App\User\CreateUserDto;
|
||||||
use App\User\UserRepository;
|
use App\User\UserRepository;
|
||||||
|
use DomainException;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
|
@ -71,6 +72,31 @@ class EloquentElementRepositoryTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItRejectsAParentFromAnotherSet(): void
|
||||||
|
{
|
||||||
|
$bible = $this->createSet('Bible');
|
||||||
|
$course = $this->createSet('Course');
|
||||||
|
$repository = app(ElementRepository::class);
|
||||||
|
$book = $repository->create(new CreateElementDto(
|
||||||
|
set: $bible,
|
||||||
|
name: 'Genesis',
|
||||||
|
kind: 'book',
|
||||||
|
parentElement: null,
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->expectException(DomainException::class);
|
||||||
|
$this->expectExceptionMessage(
|
||||||
|
'parent element must belong to the same set',
|
||||||
|
);
|
||||||
|
|
||||||
|
$repository->create(new CreateElementDto(
|
||||||
|
set: $course,
|
||||||
|
name: 'Invalid lesson',
|
||||||
|
kind: 'lesson',
|
||||||
|
parentElement: $book,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
private function createSet(string $name): Set
|
private function createSet(string $name): Set
|
||||||
{
|
{
|
||||||
$creator = app(UserRepository::class)->create(new CreateUserDto(
|
$creator = app(UserRepository::class)->create(new CreateUserDto(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue