-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dffff9
commit 99ce5f1
Showing
14 changed files
with
471 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/Unit/YoshiKan/Domain/Model/Common/ChecksumEntityTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Yoshi-Kan software. | ||
* | ||
* (c) Koen Caerels | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use App\YoshiKan\Domain\Model\Common\ChecksumEntity; | ||
|
||
it('creates a content code', function () { | ||
|
||
$checksumEntity = new class () { | ||
use ChecksumEntity; | ||
|
||
private string $firstname = 'firstname'; | ||
private string $lastname = 'lastname'; | ||
private \DateTime $createdAt; | ||
private \DateTime $updatedAt; | ||
|
||
public function __construct() | ||
{ | ||
$this->createdAt = new \DateTime(); | ||
$this->updatedAt = new \DateTime(); | ||
} | ||
}; | ||
$contentString = hash('sha256', $_ENV['APP_SECRET']); | ||
$contentString .= 'firstname'; | ||
$contentString .= 'lastname'; | ||
$checksum = md5($contentString); | ||
$checksumEntity->setChecksum(); | ||
|
||
expect($checksumEntity->getChecksum())->toBe($checksum); | ||
|
||
})->group('unit'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Yoshi-Kan software. | ||
* | ||
* (c) Koen Caerels | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use App\YoshiKan\Domain\Model\Common\IdEntity; | ||
use Symfony\Component\Uid\Uuid; | ||
|
||
it('creates identifiers for an object', function () { | ||
|
||
$entityId = new class () { | ||
use IdEntity; | ||
}; | ||
$uuid = Uuid::v4(); | ||
$entityId->identify(1, $uuid); | ||
|
||
expect($entityId->getId())->toBe(1) | ||
->and($entityId->getUuid())->toBe($uuid); | ||
|
||
})->group('unit'); |
21 changes: 21 additions & 0 deletions
21
tests/Unit/YoshiKan/Domain/Model/Common/SequenceEntityTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Yoshi-Kan software. | ||
* | ||
* (c) Koen Caerels | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use App\YoshiKan\Domain\Model\Common\SequenceEntity; | ||
|
||
it('creates sequences for an object', function () { | ||
|
||
$sequenceEntity = new class () { | ||
use SequenceEntity; | ||
}; | ||
$sequenceEntity->setSequence(1); | ||
expect($sequenceEntity->getSequence())->toBe(1); | ||
|
||
})->group('unit'); |
41 changes: 41 additions & 0 deletions
41
tests/Unit/YoshiKan/Domain/Model/Member/FederationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,42 @@ | ||
<?php | ||
|
||
use App\YoshiKan\Domain\Model\Member\Federation; | ||
use Symfony\Component\Uid\Uuid; | ||
|
||
it('can create a federation', function () { | ||
$uuid = Uuid::v4(); | ||
$federation = Federation::make( | ||
uuid: $uuid, | ||
sequence: 1, | ||
code: 'JV', | ||
name: 'Judo Vlaanderen', | ||
yearlySubscriptionFee: 49, | ||
publicLabel: 'Competitie' | ||
); | ||
expect($federation->getCode())->toBe('JV') | ||
->and($federation->getName())->toBe('Judo Vlaanderen') | ||
->and($federation->getYearlySubscriptionFee())->toBe(49) | ||
->and($federation->getPublicLabel())->toBe('Competitie'); | ||
}); | ||
|
||
it('can change federation attributes', function () { | ||
$uuid = Uuid::v4(); | ||
$federation = Federation::make( | ||
uuid: $uuid, | ||
sequence: 1, | ||
code: 'JV', | ||
name: 'Judo Vlaanderen', | ||
yearlySubscriptionFee: 49, | ||
publicLabel: 'Competitie' | ||
); | ||
$federation->change( | ||
code: 'JJ', | ||
name: 'Judo Japan', | ||
yearlySubscriptionFee: 59, | ||
publicLabel: 'Competition' | ||
); | ||
expect($federation->getCode())->toBe('JJ') | ||
->and($federation->getName())->toBe('Judo Japan') | ||
->and($federation->getYearlySubscriptionFee())->toBe(59) | ||
->and($federation->getPublicLabel())->toBe('Competition'); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
<?php | ||
|
||
use App\Tests\Unit\YoshiKan\Domain\Model\ModelFactory; | ||
use App\YoshiKan\Domain\Model\Member\GradeLog; | ||
use Symfony\Component\Uid\Uuid; | ||
|
||
it('can create a grade log', function () { | ||
$uuid = Uuid::v4(); | ||
$member = ModelFactory::makeMember(Uuid::v4()); | ||
$fromGrade = ModelFactory::makeGrade(Uuid::v4()); | ||
$toGrade = ModelFactory::makeGrade(Uuid::v4()); | ||
$date = new \DateTimeImmutable(); | ||
$remark = 'Promoted to next grade'; | ||
$gradeLog = GradeLog::make( | ||
uuid: $uuid, | ||
date: $date, | ||
remark: $remark, | ||
member: $member, | ||
fromGrade: $fromGrade, | ||
toGrade: $toGrade | ||
); | ||
expect($gradeLog->getDate())->toBe($date) | ||
->and($gradeLog->getRemark())->toBe($remark) | ||
->and($gradeLog->getMember())->toBe($member) | ||
->and($gradeLog->getFromGrade())->toBe($fromGrade) | ||
->and($gradeLog->getToGrade())->toBe($toGrade); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
<?php | ||
|
||
use App\YoshiKan\Domain\Model\Member\Grade; | ||
use Symfony\Component\Uid\Uuid; | ||
|
||
it('can create a grade', function () { | ||
$uuid = Uuid::v4(); | ||
$grade = Grade::make( | ||
uuid: $uuid, | ||
code: '1K', | ||
name: '1e Kyu', | ||
color: 'brown' | ||
); | ||
expect($grade->getCode())->toBe('1K') | ||
->and($grade->getName())->toBe('1e Kyu') | ||
->and($grade->getColor())->toBe('brown'); | ||
}); | ||
|
||
it('can change grade attributes', function () { | ||
$uuid = Uuid::v4(); | ||
$grade = Grade::make( | ||
uuid: $uuid, | ||
code: '1K', | ||
name: '1e Kyu', | ||
color: 'brown' | ||
); | ||
$grade->change( | ||
code: '2K', | ||
name: '2e Kyu', | ||
color: 'green' | ||
); | ||
expect($grade->getCode())->toBe('2K') | ||
->and($grade->getName())->toBe('2e Kyu') | ||
->and($grade->getColor())->toBe('green'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,40 @@ | ||
<?php | ||
|
||
use App\YoshiKan\Domain\Model\Member\Group; | ||
use Symfony\Component\Uid\Uuid; | ||
|
||
it('can create a group', function () { | ||
$uuid = Uuid::v4(); | ||
$group = Group::make( | ||
uuid: $uuid, | ||
code: 'adults', | ||
name: 'Adults Group', | ||
minAge: 18, | ||
maxAge: 99 | ||
); | ||
expect($group->getCode())->toBe('adults') | ||
->and($group->getName())->toBe('Adults Group') | ||
->and($group->getMinAge())->toBe(18) | ||
->and($group->getMaxAge())->toBe(99); | ||
}); | ||
|
||
it('can change group attributes', function () { | ||
$uuid = Uuid::v4(); | ||
$group = Group::make( | ||
uuid: $uuid, | ||
code: 'adults', | ||
name: 'Adults Group', | ||
minAge: 18, | ||
maxAge: 99 | ||
); | ||
$group->change( | ||
code: 'seniors', | ||
name: 'Seniors Group', | ||
minAge: 60, | ||
maxAge: 99 | ||
); | ||
expect($group->getCode())->toBe('seniors') | ||
->and($group->getName())->toBe('Seniors Group') | ||
->and($group->getMinAge())->toBe(60) | ||
->and($group->getMaxAge())->toBe(99); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
<?php | ||
|
||
use App\YoshiKan\Domain\Model\Member\Location; | ||
use Symfony\Component\Uid\Uuid; | ||
|
||
it('can create a location', function () { | ||
$uuid = Uuid::v4(); | ||
$location = Location::make( | ||
uuid: $uuid, | ||
code: 'dojo', | ||
name: 'Dojo Location' | ||
); | ||
expect($location->getCode())->toBe('dojo') | ||
->and($location->getName())->toBe('Dojo Location'); | ||
}); | ||
|
||
it('can change location attributes', function () { | ||
$uuid = Uuid::v4(); | ||
$location = Location::make( | ||
uuid: $uuid, | ||
code: 'dojo', | ||
name: 'Dojo Location' | ||
); | ||
$location->change( | ||
code: 'gym', | ||
name: 'Gym Location' | ||
); | ||
expect($location->getCode())->toBe('gym') | ||
->and($location->getName())->toBe('Gym Location'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,109 @@ | ||
<?php | ||
|
||
use App\Tests\Unit\YoshiKan\Domain\Model\ModelFactory; | ||
use App\YoshiKan\Domain\Model\Member\Gender; | ||
use App\YoshiKan\Domain\Model\Member\Member; | ||
use App\YoshiKan\Domain\Model\Member\MemberStatus; | ||
use Symfony\Component\Uid\Uuid; | ||
|
||
it('can create a member', function () { | ||
$uuid = Uuid::v4(); | ||
$grade = ModelFactory::makeGrade(Uuid::v4()); | ||
$location = ModelFactory::makeLocation(Uuid::v4()); | ||
$federation = ModelFactory::makeFederation(Uuid::v4()); | ||
$gender = Gender::M; | ||
|
||
$member = Member::make( | ||
uuid: $uuid, | ||
firstname: 'John', | ||
lastname: 'Doe', | ||
dateOfBirth: new \DateTimeImmutable('1990-01-01'), | ||
gender: $gender, | ||
grade: $grade, | ||
location: $location, | ||
federation: $federation, | ||
email: '[email protected]', | ||
nationalRegisterNumber: '12345678901', | ||
addressStreet: 'Main Street', | ||
addressNumber: '123', | ||
addressBox: '', | ||
addressZip: '12345', | ||
addressCity: 'Anytown', | ||
numberOfTraining: 10, | ||
); | ||
expect($member->getFirstname())->toBe('John') | ||
->and($member->getLastname())->toBe('Doe') | ||
->and($member->getDateOfBirth())->toBeInstanceOf(\DateTimeImmutable::class) | ||
->and($member->getGender())->toBe(Gender::M) | ||
->and($member->getGrade())->toBe($grade) | ||
->and($member->getLocation())->toBe($location) | ||
->and($member->getFederation())->toBe($federation) | ||
->and($member->getEmail())->toBe('[email protected]') | ||
->and($member->getNationalRegisterNumber())->toBe('12345678901') | ||
->and($member->getAddressStreet())->toBe('Main Street') | ||
->and($member->getAddressNumber())->toBe('123') | ||
->and($member->getAddressZip())->toBe('12345') | ||
->and($member->getAddressCity())->toBe('Anytown') | ||
->and($member->getNumberOfTraining())->toBe(10); | ||
}); | ||
|
||
it('can change member details', function () { | ||
$uuid = Uuid::v4(); | ||
$grade = ModelFactory::makeGrade(Uuid::v4()); | ||
$location = ModelFactory::makeLocation(Uuid::v4()); | ||
$federation = ModelFactory::makeFederation(Uuid::v4()); | ||
$gender = Gender::M; | ||
$member = Member::make( | ||
uuid: $uuid, | ||
firstname: 'John', | ||
lastname: 'Doe', | ||
dateOfBirth: new \DateTimeImmutable('1990-01-01'), | ||
gender: $gender, | ||
grade: $grade, | ||
location: $location, | ||
federation: $federation, | ||
email: '[email protected]', | ||
nationalRegisterNumber: '12345678901', | ||
addressStreet: 'Main Street', | ||
addressNumber: '123', | ||
addressBox: '', | ||
addressZip: '12345', | ||
addressCity: 'Anytown', | ||
numberOfTraining: 10, | ||
); | ||
$member->changeDetails( | ||
firstname: 'Jane', | ||
lastname: 'Smith', | ||
gender: Gender::V, | ||
dateOfBirth: new \DateTimeImmutable('1995-05-05'), | ||
status: MemberStatus::ACTIVE, | ||
location: ModelFactory::makeLocation(Uuid::v4()), | ||
nationalRegisterNumber: '98765432109', | ||
email: '[email protected]', | ||
addressStreet: 'New Avenue', | ||
addressNumber: '456', | ||
addressBox: 'A', | ||
addressZip: '54321', | ||
addressCity: 'Newtown', | ||
contactFirstname: 'John', | ||
contactLastname: 'Doe', | ||
contactEmail: '[email protected]', | ||
contactPhone: '123456789', | ||
); | ||
expect($member->getFirstname())->toBe('Jane') | ||
->and($member->getLastname())->toBe('Smith') | ||
->and($member->getDateOfBirth())->toBeInstanceOf(\DateTimeImmutable::class) | ||
->and($member->getGender())->toBe(Gender::V) | ||
->and($member->getStatus())->toBe(MemberStatus::ACTIVE) | ||
->and($member->getLocation())->not()->toBe($location) | ||
->and($member->getNationalRegisterNumber())->toBe('98765432109') | ||
->and($member->getEmail())->toBe('[email protected]') | ||
->and($member->getAddressStreet())->toBe('New Avenue') | ||
->and($member->getAddressNumber())->toBe('456') | ||
->and($member->getAddressZip())->toBe('54321') | ||
->and($member->getAddressCity())->toBe('Newtown') | ||
->and($member->getContactFirstname())->toBe('John') | ||
->and($member->getContactLastname())->toBe('Doe') | ||
->and($member->getContactEmail())->toBe('[email protected]') | ||
->and($member->getContactPhone())->toBe('123456789'); | ||
}); |
Oops, something went wrong.