Commit 9890a28f authored by Jacob Priddy's avatar Jacob Priddy 👌

Fix update group tests after changing behavior

parent 1fd3a5ca
......@@ -40,7 +40,7 @@ class UpdateGroup implements UpdateGroupUseCase
$reflection = new ReflectionClass(Permissions::class);
if (in_array($group->getTitle(), $reflection->getConstants(), true)) {
$response->setError('You cannot modify the title of a default permission group');
$response->setError('You cannot modify the title of a default permission group.');
$presenter->present($response);
return;
}
......
......@@ -43,6 +43,7 @@ class UseCaseTest extends TestCase
* @param string $groupId
* @param array $attributes
* @throws EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public function handleTest(string $groupId, array $attributes): void
{
......@@ -54,6 +55,7 @@ class UseCaseTest extends TestCase
/**
* @test
* @throws EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public function presenter_was_called(): void
{
......@@ -62,12 +64,13 @@ class UseCaseTest extends TestCase
$this->handleTest('69', $this->createGroupAttributes($group));
$this->assertTrue($this->presenter->wasPresenterCalled());
self::assertTrue($this->presenter->wasPresenterCalled());
}
/**
* @test
* @throws EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public function it_updates_a_group(): void
{
......@@ -77,14 +80,15 @@ class UseCaseTest extends TestCase
$this->handleTest('69', $this->createGroupAttributes($updatedGroup));
$this->assertFalse($this->response->hasError());
$this->assertEquals('updated title', $this->groups->get('69')->getTitle());
$this->assertEquals($updatedGroup, $this->response->getGroup());
self::assertFalse($this->response->hasError());
self::assertEquals('updated title', $this->groups->get('69')->getTitle());
self::assertEquals($updatedGroup, $this->response->getGroup());
}
/**
* @test
* @throws EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public function it_cannot_update_non_existent_group(): void
{
......@@ -97,9 +101,11 @@ class UseCaseTest extends TestCase
/**
* @test
* @throws EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public function it_sets_error_on_fail(): void
public function it_fails_if_update_returns_null(): void
{
$this->expectException(EntityNotFoundException::class);
$updatedGroup = new Group(420, 'updated name', '');
$stub = new InMemoryGroupsRepositoryStub();
......@@ -107,14 +113,12 @@ class UseCaseTest extends TestCase
$this->useCase = new UpdateGroup($stub);
$this->handleTest('420', $this->createGroupAttributes($updatedGroup));
$this->assertTrue($this->response->hasError());
$this->assertEquals('Unable to update group.', $this->response->getError());
}
/**
* @test
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public function it_cannot_change_title_on_default_permission_group(): void
{
......@@ -124,7 +128,6 @@ class UseCaseTest extends TestCase
$this->handleTest('69', $this->createGroupAttributes($updatedGroup));
$this->assertEquals(Permissions::CODE_QUERY, $this->response->getGroup()->getTitle());
$this->assertEquals('asdf', $this->response->getGroup()->getDescription());
self::assertEquals('You cannot modify the title of a default permission group.', $this->response->getError());
}
}
Markdown is supported
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