diff --git a/composer.json b/composer.json index 0e45709..fb41fe8 100644 --- a/composer.json +++ b/composer.json @@ -41,17 +41,18 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.13", + "mockery/mockery": "^1.6", "pestphp/pest": "^1.23", "phpstan/phpstan": "^1.9.0", "phpstan/phpstan-doctrine": "^1.3.0", "phpstan/phpstan-symfony": "^1.2.0", "phpunit/phpunit": "^9.5", + "psalm/plugin-symfony": "^5.1", "qossmic/deptrac-shim": "^1.0", "symfony/phpunit-bridge": "^6.2", "symplify/easy-coding-standard": "^9.4", "vimeo/psalm": "^5.19", - "weirdan/doctrine-psalm-plugin": "^2.9", - "psalm/plugin-symfony": "^5.1" + "weirdan/doctrine-psalm-plugin": "^2.9" }, "config": { "optimize-autoloader": true, diff --git a/composer.lock b/composer.lock index 38bb2f5..fbf37f0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "df6d86bdf1cf2d09b2ef6a3cd2891a26", + "content-hash": "867b073dd299ff3d91eb3baac20b57a5", "packages": [ { "name": "api-platform/core", @@ -17074,6 +17074,140 @@ ], "time": "2024-01-19T21:44:39+00:00" }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0|^8.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + }, + "time": "2020-07-09T08:09:16+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.6.7", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "0cc058854b3195ba21dc6b1f7b1f60f4ef3a9c06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/0cc058854b3195ba21dc6b1f7b1f60f4ef3a9c06", + "reference": "0cc058854b3195ba21dc6b1f7b1f60f4ef3a9c06", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0.1", + "lib-pcre": ">=7.0", + "php": ">=7.3" + }, + "conflict": { + "phpunit/phpunit": "<8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5 || ^9.6.10", + "symplify/easy-coding-standard": "^12.0.8" + }, + "type": "library", + "autoload": { + "files": [ + "library/helpers.php", + "library/Mockery.php" + ], + "psr-4": { + "Mockery\\": "library/Mockery" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "https://github.com/padraic", + "role": "Author" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "https://davedevelopment.co.uk", + "role": "Developer" + }, + { + "name": "Nathanael Esayeas", + "email": "nathanael.esayeas@protonmail.com", + "homepage": "https://github.com/ghostwriter", + "role": "Lead Developer" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "support": { + "docs": "https://docs.mockery.io/", + "issues": "https://github.com/mockery/mockery/issues", + "rss": "https://github.com/mockery/mockery/releases.atom", + "security": "https://github.com/mockery/mockery/security/advisories", + "source": "https://github.com/mockery/mockery" + }, + "time": "2023-12-10T02:24:34+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.11.1", diff --git a/tests/Unit/YoshiKan/Application/Command/Member/AddFederation/AddFederationTest.php b/tests/Unit/YoshiKan/Application/Command/Member/AddFederation/AddFederationTest.php index b3d9bbc..13b474d 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/AddFederation/AddFederationTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/AddFederation/AddFederationTest.php @@ -1 +1,34 @@ $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); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/AddGrade/AddGradeTest.php b/tests/Unit/YoshiKan/Application/Command/Member/AddGrade/AddGradeTest.php index b3d9bbc..143bf57 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/AddGrade/AddGradeTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/AddGrade/AddGradeTest.php @@ -1 +1,31 @@ $code, + 'name' => $name, + 'color' => $color, + ]); + + // Assert + expect($addGrade->getCode())->toBe($code) + ->and($addGrade->getName())->toBe($name) + ->and($addGrade->getColor())->toBe($color); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/AddGroup/AddGroupTest.php b/tests/Unit/YoshiKan/Application/Command/Member/AddGroup/AddGroupTest.php index b3d9bbc..709cfaf 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/AddGroup/AddGroupTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/AddGroup/AddGroupTest.php @@ -1 +1,34 @@ $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); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/AddLocation/AddLocationTest.php b/tests/Unit/YoshiKan/Application/Command/Member/AddLocation/AddLocationTest.php index b3d9bbc..9f3b6aa 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/AddLocation/AddLocationTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/AddLocation/AddLocationTest.php @@ -1 +1,28 @@ $code, + 'name' => $name, + ]); + + // Assert + expect($addLocation->getCode())->toBe($code) + ->and($addLocation->getName())->toBe($name); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/AddPeriod/AddPeriodTest.php b/tests/Unit/YoshiKan/Application/Command/Member/AddPeriod/AddPeriodTest.php index b3d9bbc..74a6859 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/AddPeriod/AddPeriodTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/AddPeriod/AddPeriodTest.php @@ -1 +1,34 @@ $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)); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ChangeFederation/ChangeFederationTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ChangeFederation/ChangeFederationTest.php index b3d9bbc..6e1e21c 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ChangeFederation/ChangeFederationTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ChangeFederation/ChangeFederationTest.php @@ -1 +1,37 @@ $id, + 'code' => $code, + 'name' => $name, + 'yearlySubscriptionFee' => $yearlySubscriptionFee, + '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); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ChangeGrade/ChangeGradeTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ChangeGrade/ChangeGradeTest.php index b3d9bbc..77e23c2 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ChangeGrade/ChangeGradeTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ChangeGrade/ChangeGradeTest.php @@ -1 +1,34 @@ $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); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ChangeGroup/ChangeGroupTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ChangeGroup/ChangeGroupTest.php index b3d9bbc..9fb9558 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ChangeGroup/ChangeGroupTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ChangeGroup/ChangeGroupTest.php @@ -1 +1,37 @@ $id, + 'code' => $code, + 'name' => $name, + 'minAge' => $minAge, + '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); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ChangeLicense/ChangeLicenseTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ChangeLicense/ChangeLicenseTest.php new file mode 100644 index 0000000..5005098 --- /dev/null +++ b/tests/Unit/YoshiKan/Application/Command/Member/ChangeLicense/ChangeLicenseTest.php @@ -0,0 +1,31 @@ + $memberId, + 'federationId' => $federationId, + 'sendMail' => $sendMail, + ]); + + // Assert + expect($changeLicense->getMemberId())->toBe($memberId) + ->and($changeLicense->getFederationId())->toBe($federationId) + ->and($changeLicense->isSendMail())->toBe($sendMail); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ChangeLocation/ChangeLocationTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ChangeLocation/ChangeLocationTest.php index b3d9bbc..557fce1 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ChangeLocation/ChangeLocationTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ChangeLocation/ChangeLocationTest.php @@ -1 +1,31 @@ $id, + 'code' => $code, + 'name' => $name, + ]); + + // Assert + expect($changeLocation->getId())->toBe($id) + ->and($changeLocation->getCode())->toBe($code) + ->and($changeLocation->getName())->toBe($name); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberDetails/ChangeMemberDetailsTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberDetails/ChangeMemberDetailsTest.php index b3d9bbc..2d3eb0b 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberDetails/ChangeMemberDetailsTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberDetails/ChangeMemberDetailsTest.php @@ -1 +1,97 @@ $id, + 'status' => $status, + 'firstname' => $firstname, + 'lastname' => $lastname, + 'dateOfBirth' => $dateOfBirth->format('Y-m-d'), // Format the date as string + 'gender' => $gender, + 'locationId' => $locationId, + 'nationalRegisterNumber' => $nationalRegisterNumber, + 'addressStreet' => $addressStreet, + 'addressNumber' => $addressNumber, + 'addressBox' => $addressBox, + 'addressZip' => $addressZip, + 'addressCity' => $addressCity, + 'email' => $email, + 'contactFirstname' => $contactFirstname, + 'contactLastname' => $contactLastname, + 'contactEmail' => $contactEmail, + 'contactPhone' => $contactPhone, + ]); + + // Act + // Access getters to retrieve the values + $resultId = $changeMemberDetails->getId(); + $resultStatus = $changeMemberDetails->getStatus(); + $resultFirstname = $changeMemberDetails->getFirstname(); + $resultLastname = $changeMemberDetails->getLastname(); + $resultDateOfBirth = $changeMemberDetails->getDateOfBirth(); + $resultGender = $changeMemberDetails->getGender(); + $resultLocationId = $changeMemberDetails->getLocationId(); + $resultNationalRegisterNumber = $changeMemberDetails->getNationalRegisterNumber(); + $resultAddressStreet = $changeMemberDetails->getAddressStreet(); + $resultAddressNumber = $changeMemberDetails->getAddressNumber(); + $resultAddressBox = $changeMemberDetails->getAddressBox(); + $resultAddressZip = $changeMemberDetails->getAddressZip(); + $resultAddressCity = $changeMemberDetails->getAddressCity(); + $resultEmail = $changeMemberDetails->getEmail(); + $resultContactFirstname = $changeMemberDetails->getContactFirstname(); + $resultContactLastname = $changeMemberDetails->getContactLastname(); + $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) + ->and($resultLastname)->toBe($lastname) + ->and($resultDateOfBirth)->toEqual($dateOfBirth) + ->and($resultGender)->toBe($gender) + ->and($resultLocationId)->toBe($locationId) + ->and($resultNationalRegisterNumber)->toBe($nationalRegisterNumber) + ->and($resultAddressStreet)->toBe($addressStreet) + ->and($resultAddressNumber)->toBe($addressNumber) + ->and($resultAddressBox)->toBe($addressBox) + ->and($resultAddressZip)->toBe($addressZip) + ->and($resultAddressCity)->toBe($addressCity) + ->and($resultEmail)->toBe($email) + ->and($resultContactFirstname)->toBe($contactFirstname) + ->and($resultContactLastname)->toBe($contactLastname) + ->and($resultContactEmail)->toBe($contactEmail) + ->and($resultContactPhone)->toBe($contactPhone); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberGrade/ChangeMemberGradeTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberGrade/ChangeMemberGradeTest.php index b3d9bbc..a22caa1 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberGrade/ChangeMemberGradeTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberGrade/ChangeMemberGradeTest.php @@ -1 +1,30 @@ $id, + 'grade' => (object) ['id' => $gradeId], + 'remark' => $remark, + ]; + + $changeMemberGrade = ChangeMemberGrade::hydrateFromJson($json); + + expect($changeMemberGrade->getId())->toBe($id) + ->and($changeMemberGrade->getGradeId())->toBe($gradeId) + ->and($changeMemberGrade->getRemark())->toBe($remark); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberRemarks/ChangeMemberRemarksTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberRemarks/ChangeMemberRemarksTest.php index b3d9bbc..a92942d 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberRemarks/ChangeMemberRemarksTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberRemarks/ChangeMemberRemarksTest.php @@ -1 +1,32 @@ $id, + '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); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberSubscription/ChangeMemberSubscriptionTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberSubscription/ChangeMemberSubscriptionTest.php index b3d9bbc..8769cc8 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberSubscription/ChangeMemberSubscriptionTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ChangeMemberSubscription/ChangeMemberSubscriptionTest.php @@ -1 +1,50 @@ $memberId, + 'federationId' => $federationId, + 'membershipStart' => $membershipStart->format('Y-m-d'), + 'membershipEnd' => $membershipEnd->format('Y-m-d'), + 'licenseStart' => $licenseStart->format('Y-m-d'), + 'licenseEnd' => $licenseEnd->format('Y-m-d'), + 'memberShipIsHalfYear' => $memberShipIsHalfYear, + '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) + ->and($changeMemberSubscription->getMembershipEnd())->toEqual($membershipEnd) + ->and($changeMemberSubscription->getLicenseStart())->toEqual($licenseStart) + ->and($changeMemberSubscription->getLicenseEnd())->toEqual($licenseEnd) + ->and($changeMemberSubscription->isMemberShipIsHalfYear())->toBe($memberShipIsHalfYear) + ->and($changeMemberSubscription->getNumberOfTraining())->toBe($numberOfTraining); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ChangePeriod/ChangePeriodTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ChangePeriod/ChangePeriodTest.php index b3d9bbc..709a6d2 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ChangePeriod/ChangePeriodTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ChangePeriod/ChangePeriodTest.php @@ -1 +1,39 @@ $id, + 'code' => $code, + 'name' => $name, + 'startDate' => $startDate->format('Y-m-d'), + 'endDate' => $endDate->format('Y-m-d'), + 'isActive' => $isActive, + ]; + + $changePeriod = ChangePeriod::hydrateFromJson($json); + + expect($changePeriod->getId())->toBe($id) + ->and($changePeriod->getCode())->toBe($code) + ->and($changePeriod->getName())->toBe($name) + ->and($changePeriod->getStartDate())->toEqual($startDate) + ->and($changePeriod->getEndDate())->toEqual($endDate) + ->and($changePeriod->isActive())->toBe($isActive); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ConfirmMemberWebSubscription/ConfirmMemberWebSubscriptionTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ConfirmMemberWebSubscription/ConfirmMemberWebSubscriptionTest.php index b3d9bbc..ff0626f 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ConfirmMemberWebSubscription/ConfirmMemberWebSubscriptionTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ConfirmMemberWebSubscription/ConfirmMemberWebSubscriptionTest.php @@ -1 +1,111 @@ 123, + 'memberId' => 456, + 'type' => 'Type', + 'federationId' => 789, + 'locationId' => 101, + 'contactFirstname' => 'John', + 'contactLastname' => 'Doe', + 'contactEmail' => 'john@example.com', + 'contactPhone' => '123456789', + 'addressStreet' => '123 Main St', + 'addressNumber' => 'Apt 101', + 'addressBox' => 'Box 123', + 'addressZip' => '12345', + 'addressCity' => 'City', + 'firstname' => 'Jane', + 'lastname' => 'Doe', + 'email' => 'jane@example.com', + 'nationalRegisterNumber' => '123456789', + 'dateOfBirth' => '1990-01-01', + 'gender' => 'male', + 'memberSubscriptionStart' => '2024-01-01', + 'memberSubscriptionStartMM' => '01', + 'memberSubscriptionStartYY' => '24', + 'memberSubscriptionEnd' => '2024-12-31', + 'memberSubscriptionTotal' => 100.0, + 'memberSubscriptionIsPartSubscription' => true, + 'memberSubscriptionIsHalfYear' => false, + 'memberSubscriptionIsPayed' => true, + 'licenseStart' => '2024-01-01', + 'licenseStartMM' => '01', + 'licenseStartYY' => '24', + 'licenseEnd' => '2024-12-31', + 'licenseTotal' => 50.0, + 'licenseIsPartSubscription' => false, + 'licenseIsPayed' => true, + 'numberOfTraining' => 10, + 'isExtraTraining' => true, + 'isReductionFamily' => false, + 'total' => 150.0, + 'remarks' => 'Remarks', + 'isJudogiBelt' => true, + 'newMemberFee' => 25.0, + 'sendMail' => true, + ]; + + $subscription = ConfirmMemberWebSubscription::hydrateFromJson($json); + + expect($subscription->getSubscriptionId())->toBe(123) + ->and($subscription->getMemberId())->toBe(456) + ->and($subscription->getType())->toBe('Type') + ->and($subscription->getFederationId())->toBe(789) + ->and($subscription->getLocationId())->toBe(101) + ->and($subscription->getContactFirstname())->toBe('John') + ->and($subscription->getContactLastname())->toBe('Doe') + ->and($subscription->getContactEmail())->toBe('john@example.com') + ->and($subscription->getContactPhone())->toBe('123456789') + ->and($subscription->getAddressStreet())->toBe('123 Main St') + ->and($subscription->getAddressNumber())->toBe('Apt 101') + ->and($subscription->getAddressBox())->toBe('Box 123') + ->and($subscription->getAddressZip())->toBe('12345') + ->and($subscription->getAddressCity())->toBe('City') + ->and($subscription->getFirstname())->toBe('Jane') + ->and($subscription->getLastname())->toBe('Doe') + ->and($subscription->getEmail())->toBe('jane@example.com') + ->and($subscription->getNationalRegisterNumber())->toBe('123456789') + ->and($subscription->getDateOfBirth())->toBeInstanceOf(DateTimeImmutable::class) + ->and($subscription->getDateOfBirth()->format('Y-m-d'))->toBe('1990-01-01') + ->and($subscription->getGender())->toBe('male') + ->and($subscription->getMemberSubscriptionStart())->toBeInstanceOf(DateTimeImmutable::class) + ->and($subscription->getMemberSubscriptionStart()->format('Y-m-d'))->toBe('2024-01-01') + ->and($subscription->getMemberSubscriptionStartMM())->toBe('01') + ->and($subscription->getMemberSubscriptionStartYY())->toBe('24') + ->and($subscription->getMemberSubscriptionEnd())->toBeInstanceOf(DateTimeImmutable::class) + ->and($subscription->getMemberSubscriptionEnd()->format('Y-m-d'))->toBe('2024-12-31') + ->and($subscription->getMemberSubscriptionTotal())->toBe(100.0) + ->and($subscription->isMemberSubscriptionIsPartSubscription())->toBe(true) + ->and($subscription->isMemberSubscriptionIsHalfYear())->toBe(false) + ->and($subscription->isMemberSubscriptionIsPayed())->toBe(true) + ->and($subscription->getLicenseStart())->toBeInstanceOf(DateTimeImmutable::class) + ->and($subscription->getLicenseStart()->format('Y-m-d'))->toBe('2024-01-01') + ->and($subscription->getLicenseStartMM())->toBe('01') + ->and($subscription->getLicenseStartYY())->toBe('24') + ->and($subscription->getLicenseEnd())->toBeInstanceOf(DateTimeImmutable::class) + ->and($subscription->getLicenseEnd()->format('Y-m-d'))->toBe('2024-12-31') + ->and($subscription->getLicenseTotal())->toBe(50.0) + ->and($subscription->isLicenseIsPartSubscription())->toBe(false) + ->and($subscription->isLicenseIsPayed())->toBe(true) + ->and($subscription->getNumberOfTraining())->toBe(10) + ->and($subscription->isExtraTraining())->toBe(true) + ->and($subscription->isReductionFamily())->toBe(false) + ->and($subscription->getTotal())->toBe(150.0) + ->and($subscription->getRemarks())->toBe('Remarks') + ->and($subscription->isJudogiBelt())->toBe(true) + ->and($subscription->getNewMemberFee())->toBe(25.0) + ->and($subscription->isSendMail())->toBe(true); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/CreateMemberFromSubscription/CreateMemberFromSubscriptionTest.php b/tests/Unit/YoshiKan/Application/Command/Member/CreateMemberFromSubscription/CreateMemberFromSubscriptionTest.php index b3d9bbc..8d0447a 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/CreateMemberFromSubscription/CreateMemberFromSubscriptionTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/CreateMemberFromSubscription/CreateMemberFromSubscriptionTest.php @@ -1 +1,19 @@ getId())->toBe(123) + ->and($member->getMemberEmail())->toBe('test@example.com'); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/CreateMolliePaymentLink/CreateMolliePaymentLinkTest.php b/tests/Unit/YoshiKan/Application/Command/Member/CreateMolliePaymentLink/CreateMolliePaymentLinkTest.php index b3d9bbc..16fc5a9 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/CreateMolliePaymentLink/CreateMolliePaymentLinkTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/CreateMolliePaymentLink/CreateMolliePaymentLinkTest.php @@ -1 +1,19 @@ getSubscriptionId())->toBe($subscriptionId); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/DeleteMemberImage/DeleteMemberImageTest.php b/tests/Unit/YoshiKan/Application/Command/Member/DeleteMemberImage/DeleteMemberImageTest.php index b3d9bbc..3d38bb9 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/DeleteMemberImage/DeleteMemberImageTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/DeleteMemberImage/DeleteMemberImageTest.php @@ -1 +1,21 @@ getId())->toBe($imageId) + ->and($deleteImageCommand->getUploadFolder())->toBe($uploadFolder); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/ForgetMember/ForgetMemberTest.php b/tests/Unit/YoshiKan/Application/Command/Member/ForgetMember/ForgetMemberTest.php index b3d9bbc..9d87f46 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/ForgetMember/ForgetMemberTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/ForgetMember/ForgetMemberTest.php @@ -1 +1,23 @@ getMemberId())->toBe($memberId); + + $json = (object) ['memberId' => $memberId]; + $forgetMember = ForgetMember::hydrateFromJson($json); + expect($forgetMember->getMemberId())->toBe($memberId); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsCanceled/MarkSubscriptionAsCanceledTest.php b/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsCanceled/MarkSubscriptionAsCanceledTest.php index b3d9bbc..7ea99b1 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsCanceled/MarkSubscriptionAsCanceledTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsCanceled/MarkSubscriptionAsCanceledTest.php @@ -1 +1,27 @@ 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); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsFinished/MarkSubscriptionAsFinishedTest.php b/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsFinished/MarkSubscriptionAsFinishedTest.php index b3d9bbc..6801fb5 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsFinished/MarkSubscriptionAsFinishedTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsFinished/MarkSubscriptionAsFinishedTest.php @@ -1 +1,25 @@ getId())->toBe($subscriptionId); + + // Test hydrate from JSON method + $json = (object) ['id' => $subscriptionId]; + $markAsFinished = MarkSubscriptionAsFinished::hydrateFromJson($json); + expect($markAsFinished->getId())->toBe($subscriptionId); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsPayed/MarkSubscriptionAsPayedTest.php b/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsPayed/MarkSubscriptionAsPayedTest.php index b3d9bbc..3b05ad2 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsPayed/MarkSubscriptionAsPayedTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsPayed/MarkSubscriptionAsPayedTest.php @@ -1 +1,25 @@ getId())->toBe($subscriptionId); + + // Test hydrate from JSON method + $json = (object) ['id' => $subscriptionId]; + $markAsPayed = MarkSubscriptionAsPayed::hydrateFromJson($json); + expect($markAsPayed->getId())->toBe($subscriptionId); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsPayedFromMollie/MarkSubscriptionAsPayedFromMollieTest.php b/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsPayedFromMollie/MarkSubscriptionAsPayedFromMollieTest.php index b3d9bbc..769bd53 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsPayedFromMollie/MarkSubscriptionAsPayedFromMollieTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/MarkSubscriptionAsPayedFromMollie/MarkSubscriptionAsPayedFromMollieTest.php @@ -1 +1,25 @@ getPaymentId())->toBe($paymentId); + + // Test hydrate from JSON method + $json = (object) ['paymentId' => $paymentId]; + $markAsPayed = MarkSubscriptionAsPayedFromMollie::hydrateFromJson($json); + expect($markAsPayed->getPaymentId())->toBe($paymentId); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/MemberExtendSubscription/MemberExtendSubscriptionTest.php b/tests/Unit/YoshiKan/Application/Command/Member/MemberExtendSubscription/MemberExtendSubscriptionTest.php index b3d9bbc..192b55f 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/MemberExtendSubscription/MemberExtendSubscriptionTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/MemberExtendSubscription/MemberExtendSubscriptionTest.php @@ -1 +1,87 @@ 123, + 'federationId' => 456, + 'locationId' => 789, + 'contactFirstname' => 'John', + 'contactLastname' => 'Doe', + 'contactEmail' => 'john@example.com', + 'contactPhone' => '123456789', + 'firstname' => 'Jane', + 'lastname' => 'Doe', + 'dateOfBirth' => '1990-01-01', + 'gender' => 'female', + 'type' => 'regular', + 'memberSubscriptionStart' => '2024-01-01', + 'memberSubscriptionEnd' => '2024-12-31', + 'memberSubscriptionTotal' => 100.0, + 'memberSubscriptionIsPartSubscription' => false, + 'memberSubscriptionIsHalfYear' => false, + 'memberSubscriptionIsPayed' => true, + 'licenseStart' => '2024-01-01', + 'licenseEnd' => '2024-12-31', + 'licenseTotal' => 50.0, + 'licenseIsPartSubscription' => false, + 'licenseIsPayed' => true, + 'numberOfTraining' => 10, + 'isExtraTraining' => true, + 'isNewMember' => false, + 'isReductionFamily' => false, + 'isJudogiBelt' => true, + 'remarks' => 'No remarks', + 'total' => 150.0, + 'sendMail' => true, + ]; + + // Test hydrate from JSON method + $memberExtendSubscription = MemberExtendSubscription::hydrateFromJson($json); + expect($memberExtendSubscription->getMemberId())->toBe(123) + ->and($memberExtendSubscription->getFederationId())->toBe(456) + ->and($memberExtendSubscription->getLocationId())->toBe(789) + ->and($memberExtendSubscription->getContactFirstname())->toBe('John') + ->and($memberExtendSubscription->getContactLastname())->toBe('Doe') + ->and($memberExtendSubscription->getContactEmail())->toBe('john@example.com') + ->and($memberExtendSubscription->getContactPhone())->toBe('123456789') + ->and($memberExtendSubscription->getFirstname())->toBe('Jane') + ->and($memberExtendSubscription->getLastname())->toBe('Doe') + ->and($memberExtendSubscription->getDateOfBirth())->toBeInstanceOf(DateTimeImmutable::class) + ->and($memberExtendSubscription->getDateOfBirth()->format('Y-m-d'))->toBe('1990-01-01') + ->and($memberExtendSubscription->getGender())->toBe('female') + ->and($memberExtendSubscription->getType())->toBe('regular') + ->and($memberExtendSubscription->getMemberSubscriptionStart())->toBeInstanceOf(DateTimeImmutable::class) + ->and($memberExtendSubscription->getMemberSubscriptionStart()->format('Y-m-d'))->toBe('2024-01-01') + ->and($memberExtendSubscription->getMemberSubscriptionEnd())->toBeInstanceOf(DateTimeImmutable::class) + ->and($memberExtendSubscription->getMemberSubscriptionEnd()->format('Y-m-d'))->toBe('2024-12-31') + ->and($memberExtendSubscription->getMemberSubscriptionTotal())->toBe(100.0) + ->and($memberExtendSubscription->isMemberSubscriptionIsPartSubscription())->toBeFalse() + ->and($memberExtendSubscription->isMemberSubscriptionIsHalfYear())->toBeFalse() + ->and($memberExtendSubscription->isMemberSubscriptionIsPayed())->toBeTrue() + ->and($memberExtendSubscription->getLicenseStart())->toBeInstanceOf(DateTimeImmutable::class) + ->and($memberExtendSubscription->getLicenseEnd())->format('Y-m-d')->toBe('2024-12-31') + ->and($memberExtendSubscription->getLicenseEnd())->toBeInstanceOf(DateTimeImmutable::class) + ->and($memberExtendSubscription->getLicenseEnd()->format('Y-m-d'))->toBe('2024-12-31') + ->and($memberExtendSubscription->getLicenseTotal())->toBe(50.0) + ->and($memberExtendSubscription->isLicenseIsPartSubscription())->toBeFalse() + ->and($memberExtendSubscription->isLicenseIsPayed())->toBeTrue() + ->and($memberExtendSubscription->getNumberOfTraining())->toBe(10) + ->and($memberExtendSubscription->isExtraTraining())->toBeTrue() + ->and($memberExtendSubscription->isNewMember())->toBeFalse() + ->and($memberExtendSubscription->isReductionFamily())->toBeFalse() + ->and($memberExtendSubscription->isJudogiBelt())->toBeTrue() + ->and($memberExtendSubscription->getRemarks())->toBe('No remarks') + ->and($memberExtendSubscription->getTotal())->toBe(150.0) + ->and($memberExtendSubscription->isSendMail())->toBeTrue(); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/MemberExtendSubscriptionMail/MemberExtendSubscriptionMailTest.php b/tests/Unit/YoshiKan/Application/Command/Member/MemberExtendSubscriptionMail/MemberExtendSubscriptionMailTest.php index b3d9bbc..6c49e3d 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/MemberExtendSubscriptionMail/MemberExtendSubscriptionMailTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/MemberExtendSubscriptionMail/MemberExtendSubscriptionMailTest.php @@ -1 +1,24 @@ getSubscriptionId())->toBe($subscriptionId) + ->and($memberExtendSubscriptionMail->getFromName())->toBe($fromName) + ->and($memberExtendSubscriptionMail->getFromEmail())->toBe($fromEmail); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/NewMemberSubscription/NewMemberSubscriptionTest.php b/tests/Unit/YoshiKan/Application/Command/Member/NewMemberSubscription/NewMemberSubscriptionTest.php index b3d9bbc..892b9ed 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/NewMemberSubscription/NewMemberSubscriptionTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/NewMemberSubscription/NewMemberSubscriptionTest.php @@ -1 +1,107 @@ getType())->toBe($jsonObject->type) + ->and($newMemberSubscription->getFederationId())->toBe($jsonObject->federationId) + ->and($newMemberSubscription->getLocationId())->toBe($jsonObject->locationId) + ->and($newMemberSubscription->getContactFirstname())->toBe($jsonObject->contactFirstname) + ->and($newMemberSubscription->getContactLastname())->toBe($jsonObject->contactLastname) + ->and($newMemberSubscription->getContactEmail())->toBe($jsonObject->contactEmail) + ->and($newMemberSubscription->getContactPhone())->toBe($jsonObject->contactPhone) + ->and($newMemberSubscription->getAddressStreet())->toBe($jsonObject->addressStreet) + ->and($newMemberSubscription->getAddressNumber())->toBe($jsonObject->addressNumber) + ->and($newMemberSubscription->getAddressBox())->toBe($jsonObject->addressBox) + ->and($newMemberSubscription->getAddressZip())->toBe($jsonObject->addressZip) + ->and($newMemberSubscription->getAddressCity())->toBe($jsonObject->addressCity) + ->and($newMemberSubscription->getFirstname())->toBe($jsonObject->firstname) + ->and($newMemberSubscription->getLastname())->toBe($jsonObject->lastname) + ->and($newMemberSubscription->getEmail())->toBe($jsonObject->email) + ->and($newMemberSubscription->getNationalRegisterNumber())->toBe($jsonObject->nationalRegisterNumber) + ->and($newMemberSubscription->getDateOfBirth()->format('Y-m-d'))->toBe('1990-01-01') + ->and($newMemberSubscription->getGender())->toBe($jsonObject->gender) + ->and($newMemberSubscription->getMemberSubscriptionStart()->format('Y-m-d'))->toBe('2024-01-01') + ->and($newMemberSubscription->getMemberSubscriptionStartMM())->toBe($jsonObject->memberSubscriptionStartMM) + ->and($newMemberSubscription->getMemberSubscriptionStartYY())->toBe($jsonObject->memberSubscriptionStartYY) + ->and($newMemberSubscription->getMemberSubscriptionEnd()->format('Y-m-d'))->toBe('2025-01-01') + ->and($newMemberSubscription->getMemberSubscriptionTotal())->toBe($jsonObject->memberSubscriptionTotal) + ->and($newMemberSubscription->isMemberSubscriptionIsPartSubscription())->toBe($jsonObject->memberSubscriptionIsPartSubscription) + ->and($newMemberSubscription->isMemberSubscriptionIsHalfYear())->toBe($jsonObject->memberSubscriptionIsHalfYear) + ->and($newMemberSubscription->isMemberSubscriptionIsPayed())->toBe($jsonObject->memberSubscriptionIsPayed) + ->and($newMemberSubscription->getLicenseStart()->format('Y-m-d'))->toBe('2024-01-01') + ->and($newMemberSubscription->getLicenseStartMM())->toBe($jsonObject->licenseStartMM) + ->and($newMemberSubscription->getLicenseStartYY())->toBe($jsonObject->licenseStartYY) + ->and($newMemberSubscription->getLicenseEnd()->format('Y-m-d'))->toBe('2025-01-01') + ->and($newMemberSubscription->getLicenseTotal())->toBe($jsonObject->licenseTotal) + ->and($newMemberSubscription->isLicenseIsPartSubscription())->toBe($jsonObject->licenseIsPartSubscription) + ->and($newMemberSubscription->isLicenseIsPayed())->toBe($jsonObject->licenseIsPayed) + ->and($newMemberSubscription->getNumberOfTraining())->toBe($jsonObject->numberOfTraining) + ->and($newMemberSubscription->isExtraTraining())->toBe($jsonObject->isExtraTraining) + ->and($newMemberSubscription->isNewMember())->toBe($jsonObject->isNewMember) + ->and($newMemberSubscription->isReductionFamily())->toBe($jsonObject->isReductionFamily) + ->and($newMemberSubscription->getTotal())->toBe($jsonObject->total) + ->and($newMemberSubscription->getRemarks())->toBe($jsonObject->remarks) + ->and($newMemberSubscription->isJudogiBelt())->toBe($jsonObject->isJudogiBelt) + ->and($newMemberSubscription->getNewMemberFee())->toBe($jsonObject->newMemberFee) + ->and($newMemberSubscription->isSendMail())->toBe($jsonObject->sendMail); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/NewMemberSubscriptionMail/NewMemberSubscriptionMailTest.php b/tests/Unit/YoshiKan/Application/Command/Member/NewMemberSubscriptionMail/NewMemberSubscriptionMailTest.php index b3d9bbc..8e27e96 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/NewMemberSubscriptionMail/NewMemberSubscriptionMailTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/NewMemberSubscriptionMail/NewMemberSubscriptionMailTest.php @@ -1 +1,41 @@ getSubscriptionId())->toBe($subscriptionId) + ->and($newMemberSubscriptionMail->getFromName())->toBe($fromName) + ->and($newMemberSubscriptionMail->getFromEmail())->toBe($fromEmail) + ->and($newMemberSubscriptionMail->isChange())->toBeFalse(); +}); + +it('can create NewMemberSubscriptionMail instance with change flag', function () { + // Sample data + $subscriptionId = 123; + $fromName = 'John Doe'; + $fromEmail = 'john@example.com'; + + // Create NewMemberSubscriptionMail instance with change flag + $newMemberSubscriptionMail = new NewMemberSubscriptionMail($subscriptionId, $fromName, $fromEmail, true); + + // Assertions + expect($newMemberSubscriptionMail->isChange())->toBeTrue(); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/NewMemberWebSubscription/NewMemberWebSubscriptionTest.php b/tests/Unit/YoshiKan/Application/Command/Member/NewMemberWebSubscription/NewMemberWebSubscriptionTest.php index b3d9bbc..aea9ce0 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/NewMemberWebSubscription/NewMemberWebSubscriptionTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/NewMemberWebSubscription/NewMemberWebSubscriptionTest.php @@ -1 +1,75 @@ getType())->toBe($jsonObject->type) + ->and($newMemberWebSubscription->getFederationId())->toBe($jsonObject->federationId) + ->and($newMemberWebSubscription->getLocationId())->toBe($jsonObject->locationId) + ->and($newMemberWebSubscription->getContactFirstname())->toBe($jsonObject->contactFirstname) + ->and($newMemberWebSubscription->getContactLastname())->toBe($jsonObject->contactLastname) + ->and($newMemberWebSubscription->getContactEmail())->toBe($jsonObject->contactEmail) + ->and($newMemberWebSubscription->getContactPhone())->toBe($jsonObject->contactPhone) + ->and($newMemberWebSubscription->getAddressStreet())->toBe($jsonObject->addressStreet) + ->and($newMemberWebSubscription->getAddressNumber())->toBe($jsonObject->addressNumber) + ->and($newMemberWebSubscription->getAddressBox())->toBe($jsonObject->addressBox) + ->and($newMemberWebSubscription->getAddressZip())->toBe($jsonObject->addressZip) + ->and($newMemberWebSubscription->getAddressCity())->toBe($jsonObject->addressCity) + ->and($newMemberWebSubscription->getFirstname())->toBe($jsonObject->firstname) + ->and($newMemberWebSubscription->getLastname())->toBe($jsonObject->lastname) + ->and($newMemberWebSubscription->getNationalRegisterNumber())->toBe($jsonObject->nationalRegisterNumber) + ->and($newMemberWebSubscription->getDateOfBirth()->format('Y-m-d'))->toBe('1990-01-01') + ->and($newMemberWebSubscription->getGender())->toBe($jsonObject->gender) + ->and($newMemberWebSubscription->isMemberSubscriptionIsHalfYear())->toBe($jsonObject->memberSubscriptionIsHalfYear) + ->and($newMemberWebSubscription->getNumberOfTraining())->toBe($jsonObject->numberOfTraining) + ->and($newMemberWebSubscription->isExtraTraining())->toBe($jsonObject->isExtraTraining) + ->and($newMemberWebSubscription->isNewMember())->toBe($jsonObject->isNewMember) + ->and($newMemberWebSubscription->isReductionFamily())->toBe($jsonObject->isReductionFamily) + ->and($newMemberWebSubscription->getTotal())->toBe($jsonObject->total) + ->and($newMemberWebSubscription->getRemarks())->toBe($jsonObject->remarks) + ->and($newMemberWebSubscription->isJudogiBelt())->toBe($jsonObject->isJudogiBelt) + ->and($newMemberWebSubscription->getHoneyPot())->toBe($jsonObject->honeyPot); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/NewMemberWebSubscriptionMail/NewMemberWebSubscriptionMailTest.php b/tests/Unit/YoshiKan/Application/Command/Member/NewMemberWebSubscriptionMail/NewMemberWebSubscriptionMailTest.php index b3d9bbc..cff5820 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/NewMemberWebSubscriptionMail/NewMemberWebSubscriptionMailTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/NewMemberWebSubscriptionMail/NewMemberWebSubscriptionMailTest.php @@ -1 +1,29 @@ getSubscriptionId())->toBe($subscriptionId) + ->and($newMemberWebSubscriptionMail->getFromName())->toBe($fromName) + ->and($newMemberWebSubscriptionMail->getFromEmail())->toBe($fromEmail) + ->and($newMemberWebSubscriptionMail->getContactEmail())->toBe($contactEmail); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/OrderFederation/OrderFederationTest.php b/tests/Unit/YoshiKan/Application/Command/Member/OrderFederation/OrderFederationTest.php index b3d9bbc..4cdd0fa 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/OrderFederation/OrderFederationTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/OrderFederation/OrderFederationTest.php @@ -1 +1,29 @@ getSequence())->toBe($sequence); +}); + +it('can hydrate OrderFederation instance from JSON', function () { + $jsonData = (object) ['sequence' => [4, 5, 6]]; + $orderFederation = OrderFederation::hydrateFromJson($jsonData); + expect($orderFederation->getSequence())->toBe($jsonData->sequence); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/OrderGrade/OrderGradeTest.php b/tests/Unit/YoshiKan/Application/Command/Member/OrderGrade/OrderGradeTest.php index b3d9bbc..bbc8f1b 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/OrderGrade/OrderGradeTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/OrderGrade/OrderGradeTest.php @@ -1 +1,34 @@ getSequence())->toBe($sequence); +}); + +it('can hydrate OrderGrade instance from JSON', function () { + // Sample JSON data + $jsonData = (object) ['sequence' => [4, 5, 6]]; + + // Hydrate OrderGrade instance from JSON + $orderGrade = OrderGrade::hydrateFromJson($jsonData); + + // Assertions + expect($orderGrade->getSequence())->toBe($jsonData->sequence); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/OrderGroup/OrderGroupTest.php b/tests/Unit/YoshiKan/Application/Command/Member/OrderGroup/OrderGroupTest.php index b3d9bbc..54ddc91 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/OrderGroup/OrderGroupTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/OrderGroup/OrderGroupTest.php @@ -1 +1,34 @@ getSequence())->toBe($sequence); +}); + +it('can hydrate OrderGroup instance from JSON', function () { + // Sample JSON data + $jsonData = (object) ['sequence' => [4, 5, 6]]; + + // Hydrate OrderGroup instance from JSON + $orderGroup = OrderGroup::hydrateFromJson($jsonData); + + // Assertions + expect($orderGroup->getSequence())->toBe($jsonData->sequence); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/OrderLocation/OrderLocationTest.php b/tests/Unit/YoshiKan/Application/Command/Member/OrderLocation/OrderLocationTest.php index b3d9bbc..deec6aa 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/OrderLocation/OrderLocationTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/OrderLocation/OrderLocationTest.php @@ -1 +1,34 @@ getSequence())->toBe($sequence); +}); + +it('can hydrate OrderLocation instance from JSON', function () { + // Sample JSON data + $jsonData = (object) ['sequence' => [4, 5, 6]]; + + // Hydrate OrderLocation instance from JSON + $orderLocation = OrderLocation::hydrateFromJson($jsonData); + + // Assertions + expect($orderLocation->getSequence())->toBe($jsonData->sequence); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/OrderPeriod/OrderPeriodTest.php b/tests/Unit/YoshiKan/Application/Command/Member/OrderPeriod/OrderPeriodTest.php index b3d9bbc..2a817f3 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/OrderPeriod/OrderPeriodTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/OrderPeriod/OrderPeriodTest.php @@ -1 +1,34 @@ getSequence())->toBe($sequence); +}); + +it('can hydrate OrderPeriod instance from JSON', function () { + // Sample JSON data + $jsonData = (object) ['sequence' => [4, 5, 6]]; + + // Hydrate OrderPeriod instance from JSON + $orderPeriod = OrderPeriod::hydrateFromJson($jsonData); + + // Assertions + expect($orderPeriod->getSequence())->toBe($jsonData->sequence); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/SaveSettings/SaveSettingsTest.php b/tests/Unit/YoshiKan/Application/Command/Member/SaveSettings/SaveSettingsTest.php index b3d9bbc..95e36bb 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/SaveSettings/SaveSettingsTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/SaveSettings/SaveSettingsTest.php @@ -1 +1,41 @@ 'DEF456', + 'yearlyFee2Training' => 120.00, + 'yearlyFee1Training' => 90.00, + 'halfYearlyFee2Training' => 70.00, + 'halfYearlyFee1Training' => 50.00, + 'extraTrainingFee' => 30.00, + 'newMemberSubscriptionFee' => 220.00, + 'newMemberSubscriptionFeeWithoutGuide' => 200.00, + 'familyDiscount' => 15, + ]; + + // Hydrate SaveSettings instance from JSON + $settings = SaveSettings::hydrateFromJson($jsonData); + + // Assertions + expect($settings->getCode())->toBe($jsonData->code) + ->and($settings->getYearlyFee2Training())->toBe($jsonData->yearlyFee2Training) + ->and($settings->getYearlyFee1Training())->toBe($jsonData->yearlyFee1Training) + ->and($settings->getHalfYearlyFee2Training())->toBe($jsonData->halfYearlyFee2Training) + ->and($settings->getHalfYearlyFee1Training())->toBe($jsonData->halfYearlyFee1Training) + ->and($settings->getExtraTrainingFee())->toBe($jsonData->extraTrainingFee) + ->and($settings->getNewMemberSubscriptionFee())->toBe($jsonData->newMemberSubscriptionFee) + ->and($settings->getNewMemberSubscriptionFeeWithoutGuide())->toBe($jsonData->newMemberSubscriptionFeeWithoutGuide) + ->and($settings->getFamilyDiscount())->toBe($jsonData->familyDiscount); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/SendPaymentReceivedConfirmationMail/SendPaymentReceivedConfirmationMailTest.php b/tests/Unit/YoshiKan/Application/Command/Member/SendPaymentReceivedConfirmationMail/SendPaymentReceivedConfirmationMailTest.php index b3d9bbc..ccab16e 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/SendPaymentReceivedConfirmationMail/SendPaymentReceivedConfirmationMailTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/SendPaymentReceivedConfirmationMail/SendPaymentReceivedConfirmationMailTest.php @@ -1 +1,31 @@ getSubscriptionId())->toBe($subscriptionId) + ->and($mail->getFromName())->toBe($fromName) + ->and($mail->getFromEmail())->toBe($fromEmail); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/SetupConfiguration/SetupConfigurationTest.php b/tests/Unit/YoshiKan/Application/Command/Member/SetupConfiguration/SetupConfigurationTest.php index b3d9bbc..7632a4b 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/SetupConfiguration/SetupConfigurationTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/SetupConfiguration/SetupConfigurationTest.php @@ -1 +1,23 @@ getCode())->toBe($code); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/UploadMemberImage/UploadMemberImageTest.php b/tests/Unit/YoshiKan/Application/Command/Member/UploadMemberImage/UploadMemberImageTest.php index b3d9bbc..aab664e 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/UploadMemberImage/UploadMemberImageTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/UploadMemberImage/UploadMemberImageTest.php @@ -1 +1,33 @@ shouldReceive('getClientOriginalName')->andReturn('file.jpg'); + $file->shouldReceive('getMimeType')->andReturn('image/jpeg'); + $file->shouldReceive('isValid')->andReturn(true); + $uploadsFolder = '/uploads'; + $id = 1; + + $upload = new UploadMemberImage($id, $file, $uploadsFolder); + + expect($upload->getId())->toBe($id) + ->and($upload->getFile())->toBe($file) + ->and($upload->getUploadsFolder())->toBe($uploadsFolder); +}); + +afterEach(function () { + m::close(); +}); diff --git a/tests/Unit/YoshiKan/Application/Command/Member/UploadProfileImage/UploadProfileImageTest.php b/tests/Unit/YoshiKan/Application/Command/Member/UploadProfileImage/UploadProfileImageTest.php index b3d9bbc..5a24a44 100644 --- a/tests/Unit/YoshiKan/Application/Command/Member/UploadProfileImage/UploadProfileImageTest.php +++ b/tests/Unit/YoshiKan/Application/Command/Member/UploadProfileImage/UploadProfileImageTest.php @@ -1 +1,33 @@ shouldReceive('getClientOriginalName')->andReturn('profile.jpg'); + $file->shouldReceive('getMimeType')->andReturn('image/jpeg'); + $file->shouldReceive('isValid')->andReturn(true); + $uploadsFolder = '/uploads'; + $id = 1; + + $upload = new UploadProfileImage($id, $file, $uploadsFolder); + + expect($upload->getId())->toBe($id) + ->and($upload->getImageBlob())->toBe($file) + ->and($upload->getUploadsFolder())->toBe($uploadsFolder); +}); + +afterEach(function () { + m::close(); +});