Commit 1eac0e78 authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

add some tests for some things that were not tested

parent 7d84b3ba
Pipeline #2671 passed with stages
in 1 minute and 52 seconds
......@@ -6,6 +6,7 @@ namespace Tests\Unit\Source\UseCases\Groups\CreateGroup;
use Source\Entities\Group;
use PHPUnit\Framework\TestCase;
use Source\Exceptions\EntityExistsException;
use Tests\Doubles\InMemoryGroupsRepositoryStub;
use Source\UseCases\Groups\CreateGroup\CreateGroup;
use Source\Gateways\Groups\InMemoryGroupsRepository;
use Source\UseCases\Groups\CreateGroup\ResponseModel;
......@@ -79,4 +80,19 @@ class UseCaseTest extends TestCase
$this->assertEquals($group->getDescription(), $this->response->getGroup()->getDescription());
$this->assertCount(1, $this->groupsRepository->all());
}
/**
* @test
* @throws \Source\Exceptions\EntityExistsException
*/
public function it_cannot_create_group_that_already_exists(): void
{
$group = new Group(1, 'title', 'desc');
$this->useCase = new CreateGroup(new InMemoryGroupsRepositoryStub());
$this->expectException(EntityExistsException::class);
$this->handleTest($this->createGroupAttributes($group));
}
}
......@@ -6,6 +6,7 @@ namespace Tests\Unit\Source\UseCases\Users\CreateUser;
use Source\Entities\User;
use PHPUnit\Framework\TestCase;
use Source\Exceptions\EntityExistsException;
use Tests\Doubles\InMemoryUsersRepositoryStub;
use Source\UseCases\Users\CreateUser\CreateUser;
use Source\Gateways\Users\InMemoryUsersRepository;
use Source\UseCases\Users\CreateUser\ResponseModel;
......@@ -85,4 +86,19 @@ class UseCaseTest extends TestCase
$this->assertEquals($user->getFirstName(), $this->response->getUser()->getFirstName());
$this->assertCount(1, $this->usersRepository->all());
}
/**
* @test
* @throws \Source\Exceptions\EntityExistsException
*/
public function it_cannot_create_group_that_already_exists(): void
{
$user = new User(1, '', '', '', '', '', '', '');
$this->useCase = new CreateUser(new InMemoryUsersRepositoryStub());
$this->expectException(EntityExistsException::class);
$this->handleTest($this->createUserAttributes($user));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment