Skip to content

Commit

Permalink
#469 enum p3
Browse files Browse the repository at this point in the history
  • Loading branch information
eventhorizonpl committed Jan 27, 2022
1 parent 2fb3cde commit 072e5c3
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 96 deletions.
8 changes: 2 additions & 6 deletions src/Entity/AccountOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ public function getType(): ?AccountOperationTypeEnum
public static function getTypeFormChoices(): array
{
return [
AccountOperationTypeEnum::DEPOSIT => AccountOperationTypeEnum::DEPOSIT,
AccountOperationTypeEnum::WITHDRAW => AccountOperationTypeEnum::WITHDRAW,
AccountOperationTypeEnum::DEPOSIT->value => AccountOperationTypeEnum::DEPOSIT->value,
AccountOperationTypeEnum::WITHDRAW->value => AccountOperationTypeEnum::WITHDRAW->value,
];
}

Expand All @@ -149,10 +149,6 @@ public static function getTypeValidationChoices(): array

public function setType(AccountOperationTypeEnum $type): self
{
if (!(\in_array($type, self::getTypeValidationChoices(), true))) {
throw new InvalidArgumentException('Invalid type');
}

$this->type = $type;

return $this;
Expand Down
12 changes: 4 additions & 8 deletions src/Entity/Achievement.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ public function getType(): ?AchievementTypeEnum
public static function getTypeFormChoices(): array
{
return [
AchievementTypeEnum::COMPLETED_ROUTINE => AchievementTypeEnum::COMPLETED_ROUTINE,
AchievementTypeEnum::COMPLETED_GOAL => AchievementTypeEnum::COMPLETED_GOAL,
AchievementTypeEnum::COMPLETED_PROJECT => AchievementTypeEnum::COMPLETED_PROJECT,
AchievementTypeEnum::CREATED_NOTE => AchievementTypeEnum::CREATED_NOTE,
AchievementTypeEnum::COMPLETED_ROUTINE->value => AchievementTypeEnum::COMPLETED_ROUTINE->value,
AchievementTypeEnum::COMPLETED_GOAL->value => AchievementTypeEnum::COMPLETED_GOAL->value,
AchievementTypeEnum::COMPLETED_PROJECT->value => AchievementTypeEnum::COMPLETED_PROJECT->value,
AchievementTypeEnum::CREATED_NOTE->value => AchievementTypeEnum::CREATED_NOTE->value,
];
}

Expand All @@ -142,10 +142,6 @@ public static function getTypeValidationChoices(): array

public function setType(?AchievementTypeEnum $type): self
{
if (!(\in_array($type, self::getTypeValidationChoices(), true))) {
throw new InvalidArgumentException('Invalid type');
}

$this->type = $type;

return $this;
Expand Down
8 changes: 2 additions & 6 deletions src/Entity/Answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public function getType(): ?AnswerTypeEnum
public static function getTypeFormChoices(): array
{
return [
AnswerTypeEnum::DEFINED => AnswerTypeEnum::DEFINED,
AnswerTypeEnum::OWN => AnswerTypeEnum::OWN,
AnswerTypeEnum::DEFINED->value => AnswerTypeEnum::DEFINED->value,
AnswerTypeEnum::OWN->value => AnswerTypeEnum::OWN->value,
];
}

Expand All @@ -101,10 +101,6 @@ public static function getTypeValidationChoices(): array

public function setType(AnswerTypeEnum $type): self
{
if (!(\in_array($type, self::getTypeValidationChoices(), true))) {
throw new InvalidArgumentException('Invalid type');
}

$this->type = $type;

return $this;
Expand Down
24 changes: 8 additions & 16 deletions src/Entity/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ public function getStatus(): ?ContactStatusEnum
public static function getStatusFormChoices(): array
{
return [
ContactStatusEnum::CLOSED => ContactStatusEnum::CLOSED,
ContactStatusEnum::ON_HOLD => ContactStatusEnum::ON_HOLD,
ContactStatusEnum::OPEN => ContactStatusEnum::OPEN,
ContactStatusEnum::PENDING => ContactStatusEnum::PENDING,
ContactStatusEnum::SOLVED => ContactStatusEnum::SOLVED,
ContactStatusEnum::SPAM => ContactStatusEnum::SPAM,
ContactStatusEnum::CLOSED->value => ContactStatusEnum::CLOSED->value,
ContactStatusEnum::ON_HOLD->value => ContactStatusEnum::ON_HOLD->value,
ContactStatusEnum::OPEN->value => ContactStatusEnum::OPEN->value,
ContactStatusEnum::PENDING->value => ContactStatusEnum::PENDING->value,
ContactStatusEnum::SOLVED->value => ContactStatusEnum::SOLVED->value,
ContactStatusEnum::SPAM->value => ContactStatusEnum::SPAM->value,
];
}

Expand All @@ -123,10 +123,6 @@ public static function getStatusValidationChoices(): array

public function setStatus(ContactStatusEnum $status): self
{
if (!(\in_array($status, self::getStatusValidationChoices(), true))) {
throw new InvalidArgumentException('Invalid status');
}

$this->status = $status;

return $this;
Expand All @@ -152,8 +148,8 @@ public function getType(): ?ContactTypeEnum
public static function getTypeFormChoices(): array
{
return [
ContactTypeEnum::FEATURE_IDEA => ContactTypeEnum::FEATURE_IDEA,
ContactTypeEnum::QUESTION => ContactTypeEnum::QUESTION,
ContactTypeEnum::FEATURE_IDEA->value => ContactTypeEnum::FEATURE_IDEA->value,
ContactTypeEnum::QUESTION->value => ContactTypeEnum::QUESTION->value,
];
}

Expand All @@ -164,10 +160,6 @@ public static function getTypeValidationChoices(): array

public function setType(ContactTypeEnum $type): self
{
if (!(\in_array($type, self::getTypeValidationChoices(), true))) {
throw new InvalidArgumentException('Invalid type');
}

$this->type = $type;

return $this;
Expand Down
8 changes: 2 additions & 6 deletions src/Entity/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ public function getTheme(): ?ProfileThemeEnum
public static function getThemeFormChoices(): array
{
return [
ProfileThemeEnum::DARK => ProfileThemeEnum::DARK,
ProfileThemeEnum::LIGHT => ProfileThemeEnum::LIGHT,
ProfileThemeEnum::DARK->value => ProfileThemeEnum::DARK->value,
ProfileThemeEnum::LIGHT->value => ProfileThemeEnum::LIGHT->value,
];
}

Expand All @@ -311,10 +311,6 @@ public static function getThemeValidationChoices(): array

public function setTheme(?ProfileThemeEnum $theme): self
{
if (!(\in_array($theme, self::getThemeValidationChoices(), true))) {
throw new InvalidArgumentException('Invalid theme');
}

$this->theme = $theme;

return $this;
Expand Down
9 changes: 0 additions & 9 deletions tests/Entity/AccountOperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ public function testGetType(): void
$accountOperation = new AccountOperation();
$accountOperation->setType($type);
$this->assertSame($type, $accountOperation->getType());
$this->assertIsString($accountOperation->getType());
}

public function testGetTypeFormChoices(): void
Expand All @@ -273,12 +272,4 @@ public function testSetType(): void
$this->assertInstanceOf(AccountOperation::class, $accountOperation->setType($type));
$this->assertSame($type, $accountOperation->getType());
}

public function testSetTypeException(): void
{
$this->expectException(InvalidArgumentException::class);
$type = 'wrong type';
$accountOperation = new AccountOperation();
$this->assertInstanceOf(AccountOperation::class, $accountOperation->setType($type));
}
}
9 changes: 0 additions & 9 deletions tests/Entity/AchievementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ public function testGetType(): void
$achievement = new Achievement();
$achievement->setType($type);
$this->assertSame($type, $achievement->getType());
$this->assertIsString($achievement->getType());
}

public function testGetTypeFormChoices(): void
Expand All @@ -276,14 +275,6 @@ public function testSetType(): void
$this->assertSame($type, $achievement->getType());
}

public function testSetTypeException(): void
{
$this->expectException(InvalidArgumentException::class);
$type = 'wrong type';
$achievement = new Achievement();
$this->assertInstanceOf(Achievement::class, $achievement->setType($type));
}

public function testAddUser(): void
{
$achievement = new Achievement();
Expand Down
9 changes: 0 additions & 9 deletions tests/Entity/AnswerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ public function testGetType(): void
$answer = new Answer();
$answer->setType($type);
$this->assertSame($type, $answer->getType());
$this->assertIsString($answer->getType());
}

public function testGetTypeFormChoices(): void
Expand All @@ -258,14 +257,6 @@ public function testSetType(): void
$this->assertSame($type, $answer->getType());
}

public function testSetTypeException(): void
{
$this->expectException(InvalidArgumentException::class);
$type = 'wrong type';
$answer = new Answer();
$this->assertInstanceOf(Answer::class, $answer->setType($type));
}

public function testAddUserQuestionnaireAnswer(): void
{
$answer = new Answer();
Expand Down
18 changes: 0 additions & 18 deletions tests/Entity/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ public function testGetStatus(): void
$contact = new Contact();
$contact->setStatus($status);
$this->assertSame($status, $contact->getStatus());
$this->assertIsString($contact->getStatus());
}

public function testGetStatusFormChoices(): void
Expand All @@ -240,14 +239,6 @@ public function testSetStatus(): void
$this->assertSame($status, $contact->getStatus());
}

public function testSetStatusException(): void
{
$this->expectException(InvalidArgumentException::class);
$status = 'wrong status';
$contact = new Contact();
$this->assertInstanceOf(Contact::class, $contact->setStatus($status));
}

public function testGetTitle(): void
{
$title = 'test title';
Expand All @@ -272,7 +263,6 @@ public function testGetType(): void
$contact = new Contact();
$contact->setType($type);
$this->assertSame($type, $contact->getType());
$this->assertIsString($contact->getType());
}

public function testGetTypeFormChoices(): void
Expand All @@ -294,12 +284,4 @@ public function testSetType(): void
$this->assertInstanceOf(Contact::class, $contact->setType($type));
$this->assertSame($type, $contact->getType());
}

public function testSetTypeException(): void
{
$this->expectException(InvalidArgumentException::class);
$type = 'wrong type';
$contact = new Contact();
$this->assertInstanceOf(Contact::class, $contact->setType($type));
}
}
9 changes: 0 additions & 9 deletions tests/Entity/ProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ public function testGetTheme(): void
$profile = new Profile();
$profile->setTheme($theme);
$this->assertSame($theme, $profile->getTheme());
$this->assertIsString($profile->getTheme());
}

public function testGetThemeFormChoices(): void
Expand All @@ -432,14 +431,6 @@ public function testSetTheme(): void
$this->assertSame($theme, $profile->getTheme());
}

public function testSetThemeException(): void
{
$this->expectException(InvalidArgumentException::class);
$theme = 'wrong theme';
$profile = new Profile();
$this->assertInstanceOf(Profile::class, $profile->setTheme($theme));
}

public function testGetTimeZone(): void
{
$timeZone = 'test time zone';
Expand Down

0 comments on commit 072e5c3

Please sign in to comment.