Skip to content

Commit

Permalink
Command Unit Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
koencaerels committed Jan 30, 2024
1 parent b56f372 commit f1cfe51
Show file tree
Hide file tree
Showing 42 changed files with 1,662 additions and 3 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
136 changes: 135 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
<?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\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);
});
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
<?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\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);
});
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
<?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\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);
});
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
<?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\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);
});
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
<?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\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));
});
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
<?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\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,
'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);
});
Loading

0 comments on commit f1cfe51

Please sign in to comment.