Skip to content

Commit

Permalink
Composer update + unit tests commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
koencaerels committed Jan 30, 2024
1 parent f1cfe51 commit f4dc670
Show file tree
Hide file tree
Showing 43 changed files with 388 additions and 513 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/php_build_and_qa_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ jobs:
- name: QA PSALM
run: ./vendor/bin/psalm

## —— Backend Tests ———————————————————————————————————————————————————

- name: Execute tests (Unit & Integration Tests) via PestPHP
run: ./vendor/bin/pest

## —— Yarn ————————————————————————————————————————————————————————————

- name: Nodejs install
Expand All @@ -93,7 +98,3 @@ jobs:
cd frontends/member_module/
npm install
npm run build-only
## —— Testing ————————————————————————————————————————————————————————————
# - name: Execute tests (Unit & Feature Tests) via PestPHP
# run: ./vendor/bin/pest
668 changes: 335 additions & 333 deletions composer.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@
use App\YoshiKan\Application\Command\Member\AddFederation\AddFederation;

it('can add a federation', function () {
// Arrange
$code = 'FED123';
$name = 'Example Federation';
$yearlySubscriptionFee = 100;
$publicLabel = 'Public Federation';

// Act
$addFederation = AddFederation::hydrateFromJson((object) [
'code' => $code,
'name' => $name,
'yearlySubscriptionFee' => $yearlySubscriptionFee,
'publicLabel' => $publicLabel,
]);

// Assert
expect($addFederation->getCode())->toBe($code)
->and($addFederation->getName())->toBe($name)
->and($addFederation->getYearlySubscriptionFee())->toBe($yearlySubscriptionFee)
->and($addFederation->getPublicLabel())->toBe($publicLabel);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@
use App\YoshiKan\Application\Command\Member\AddGrade\AddGrade;

it('can add a grade', function () {
// Arrange
$code = 'GRD123';
$name = 'Example Grade';
$color = '#FF0000';

// Act
$addGrade = AddGrade::hydrateFromJson((object) [
'code' => $code,
'name' => $name,
'color' => $color,
]);

// Assert
expect($addGrade->getCode())->toBe($code)
->and($addGrade->getName())->toBe($name)
->and($addGrade->getColor())->toBe($color);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@
use App\YoshiKan\Application\Command\Member\AddGroup\AddGroup;

it('can add a group', function () {
// Arrange
$code = 'GRP123';
$name = 'Example Group';
$minAge = 10;
$maxAge = 20;

// Act
$addGroup = AddGroup::hydrateFromJson((object) [
'code' => $code,
'name' => $name,
'minAge' => $minAge,
'maxAge' => $maxAge,
]);

// Assert
expect($addGroup->getCode())->toBe($code)
->and($addGroup->getName())->toBe($name)
->and($addGroup->getMinAge())->toBe($minAge)
->and($addGroup->getMaxAge())->toBe($maxAge);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@
use App\YoshiKan\Application\Command\Member\AddLocation\AddLocation;

it('can add a location', function () {
// Arrange
$code = 'LOC123';
$name = 'Example Location';

// Act
$addLocation = AddLocation::hydrateFromJson((object) [
'code' => $code,
'name' => $name,
]);

// Assert
expect($addLocation->getCode())->toBe($code)
->and($addLocation->getName())->toBe($name);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@
use App\YoshiKan\Application\Command\Member\AddPeriod\AddPeriod;

it('can add a period', function () {
// Arrange
$code = 'PER123';
$name = 'Example Period';
$startDate = new DateTimeImmutable('2024-01-01');
$endDate = new DateTimeImmutable('2024-12-31');

// Act
$addPeriod = AddPeriod::hydrateFromJson((object) [
'code' => $code,
'name' => $name,
'startDate' => $startDate->format(DateTimeInterface::ATOM),
'endDate' => $endDate->format(DateTimeInterface::ATOM),
]);

// Assert
expect($addPeriod->getCode())->toBe($code)
->and($addPeriod->getName())->toBe($name)
->and($addPeriod->getStartDate()->format(DateTimeInterface::ATOM))->toBe($startDate->format(DateTimeInterface::ATOM))
->and($addPeriod->getEndDate()->format(DateTimeInterface::ATOM))->toBe($endDate->format(DateTimeInterface::ATOM));
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
use App\YoshiKan\Application\Command\Member\ChangeFederation\ChangeFederation;

it('can change a federation', function () {
// Arrange
$id = 1;
$code = 'FED123';
$name = 'Example Federation';
$yearlySubscriptionFee = 100;
$publicLabel = 'Public Federation';

// Act
$changeFederation = ChangeFederation::hydrateFromJson((object) [
'id' => $id,
'code' => $code,
Expand All @@ -28,10 +26,9 @@
'publicLabel' => $publicLabel,
]);

// Assert
expect($changeFederation->getId())->toBe($id)
->and($changeFederation->getCode())->toBe($code)
->and($changeFederation->getName())->toBe($name)
->and($changeFederation->getYearlySubscriptionFee())->toBe($yearlySubscriptionFee)
->and($changeFederation->getPublicLabel())->toBe($publicLabel);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@
use App\YoshiKan\Application\Command\Member\ChangeGrade\ChangeGrade;

it('can change a grade', function () {
// Arrange
$id = 1;
$code = 'GRD123';
$name = 'Example Grade';
$color = '#FF0000';

// Act
$changeGrade = ChangeGrade::hydrateFromJson((object) [
'id' => $id,
'code' => $code,
'name' => $name,
'color' => $color,
]);

// Assert
expect($changeGrade->getId())->toBe($id)
->and($changeGrade->getCode())->toBe($code)
->and($changeGrade->getName())->toBe($name)
->and($changeGrade->getColor())->toBe($color);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
use App\YoshiKan\Application\Command\Member\ChangeGroup\ChangeGroup;

it('can change a group', function () {
// Arrange
$id = 1;
$code = 'GRP123';
$name = 'Example Group';
$minAge = 10;
$maxAge = 20;

// Act
$changeGroup = ChangeGroup::hydrateFromJson((object) [
'id' => $id,
'code' => $code,
Expand All @@ -28,10 +26,9 @@
'maxAge' => $maxAge,
]);

// Assert
expect($changeGroup->getId())->toBe($id)
->and($changeGroup->getCode())->toBe($code)
->and($changeGroup->getName())->toBe($name)
->and($changeGroup->getMinAge())->toBe($minAge)
->and($changeGroup->getMaxAge())->toBe($maxAge);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@
use App\YoshiKan\Application\Command\Member\ChangeLicense\ChangeLicense;

it('can change a license', function () {
// Arrange
$memberId = 1;
$federationId = 2;
$sendMail = false;

// Act
$changeLicense = ChangeLicense::hydrateFromJson((object) [
'memberId' => $memberId,
'federationId' => $federationId,
'sendMail' => $sendMail,
]);

// Assert
expect($changeLicense->getMemberId())->toBe($memberId)
->and($changeLicense->getFederationId())->toBe($federationId)
->and($changeLicense->isSendMail())->toBe($sendMail);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@
use App\YoshiKan\Application\Command\Member\ChangeLocation\ChangeLocation;

it('can change a location', function () {
// Arrange
$id = 1;
$code = 'LOC123';
$name = 'Example Location';

// Act
$changeLocation = ChangeLocation::hydrateFromJson((object) [
'id' => $id,
'code' => $code,
'name' => $name,
]);

// Assert
expect($changeLocation->getId())->toBe($id)
->and($changeLocation->getCode())->toBe($code)
->and($changeLocation->getName())->toBe($name);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use App\YoshiKan\Application\Command\Member\ChangeMemberDetails\ChangeMemberDetails;

test('change member details', function () {
// Arrange
$id = 1;
$status = 'active';
$firstname = 'John';
Expand Down Expand Up @@ -53,8 +52,6 @@
'contactPhone' => $contactPhone,
]);

// Act
// Access getters to retrieve the values
$resultId = $changeMemberDetails->getId();
$resultStatus = $changeMemberDetails->getStatus();
$resultFirstname = $changeMemberDetails->getFirstname();
Expand All @@ -74,8 +71,6 @@
$resultContactEmail = $changeMemberDetails->getContactEmail();
$resultContactPhone = $changeMemberDetails->getContactPhone();

// Assert
// Compare each property with the expected values
expect($resultId)->toBe($id)
->and($resultStatus)->toBe($status)
->and($resultFirstname)->toBe($firstname)
Expand All @@ -94,4 +89,4 @@
->and($resultContactLastname)->toBe($contactLastname)
->and($resultContactEmail)->toBe($contactEmail)
->and($resultContactPhone)->toBe($contactPhone);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
expect($changeMemberGrade->getId())->toBe($id)
->and($changeMemberGrade->getGradeId())->toBe($gradeId)
->and($changeMemberGrade->getRemark())->toBe($remark);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

use App\YoshiKan\Application\Command\Member\ChangeMemberRemarks\ChangeMemberRemarks;

// Rewrite the test using Pest's chaining syntax
test('change member remarks', function () {
// Arrange
$id = 1;
$remarks = 'This member has been exceptionally active in the past few months.';

Expand All @@ -22,11 +20,8 @@
'remarks' => $remarks,
];

// Act
$changeMemberRemarks = ChangeMemberRemarks::hydrateFromJson($json);

// Assert
// Chained expect functions to check all properties at once
expect($changeMemberRemarks->getId())->toBe($id)
->and($changeMemberRemarks->getRemarks())->toBe($remarks);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

use App\YoshiKan\Application\Command\Member\ChangeMemberSubscription\ChangeMemberSubscription;

// Rewrite the test using Pest's chaining syntax
test('change member subscription', function () {
// Arrange
$memberId = 1;
$federationId = 2;
$membershipStart = new DateTimeImmutable('2023-01-01');
Expand All @@ -34,11 +32,8 @@
'numberOfTraining' => $numberOfTraining,
];

// Act
$changeMemberSubscription = ChangeMemberSubscription::hydrateFromJson($json);

// Assert
// Chained expect functions to check all properties at once
expect($changeMemberSubscription->getMemberId())->toBe($memberId)
->and($changeMemberSubscription->getFederationId())->toBe($federationId)
->and($changeMemberSubscription->getMembershipStart())->toEqual($membershipStart)
Expand All @@ -47,4 +42,4 @@
->and($changeMemberSubscription->getLicenseEnd())->toEqual($licenseEnd)
->and($changeMemberSubscription->isMemberShipIsHalfYear())->toBe($memberShipIsHalfYear)
->and($changeMemberSubscription->getNumberOfTraining())->toBe($numberOfTraining);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
->and($changePeriod->getStartDate())->toEqual($startDate)
->and($changePeriod->getEndDate())->toEqual($endDate)
->and($changePeriod->isActive())->toBe($isActive);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@
->and($subscription->isJudogiBelt())->toBe(true)
->and($subscription->getNewMemberFee())->toBe(25.0)
->and($subscription->isSendMail())->toBe(true);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

expect($member->getId())->toBe(123)
->and($member->getMemberEmail())->toBe('[email protected]');
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
$paymentLink = CreateMolliePaymentLink::make($subscriptionId);

expect($paymentLink->getSubscriptionId())->toBe($subscriptionId);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

expect($deleteImageCommand->getId())->toBe($imageId)
->and($deleteImageCommand->getUploadFolder())->toBe($uploadFolder);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
$json = (object) ['memberId' => $memberId];
$forgetMember = ForgetMember::hydrateFromJson($json);
expect($forgetMember->getMemberId())->toBe($memberId);
});
})->group('unit');
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
it('can mark subscription as canceled', function () {
$subscriptionId = 123;

// Test maker method
$markAsCanceled = MarkSubscriptionAsCanceled::make($subscriptionId);
expect($markAsCanceled->getId())->toBe($subscriptionId)
->and($markAsCanceled->isCancelMember())->toBe(true);

// Test hydrate from JSON method
$json = (object) ['id' => $subscriptionId];
$markAsCanceled = MarkSubscriptionAsCanceled::hydrateFromJson($json);
expect($markAsCanceled->getId())->toBe($subscriptionId)
->and($markAsCanceled->isCancelMember())->toBe(true);
});
})->group('unit');
Loading

0 comments on commit f4dc670

Please sign in to comment.