feat: generate draft assignments from a staffing matrix
This commit is contained in:
1 parent
3116d23199
commit
2fc9806c69
41 files changed
+2618
No files matched your search
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\StaffingRule;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
|
||||
class StaffingRuleTest extends TestCase
|
||||
{
|
||||
public function testTheProductCodeIsNormalized(): void
|
||||
{
|
||||
$this->assertSame('DPWAST', (new StaffingRule())->setProductCode(' dpwast ')->getProductCode());
|
||||
$this->assertNull((new StaffingRule())->setProductCode(' ')->getProductCode());
|
||||
}
|
||||
|
||||
#[DataProvider('combinations')]
|
||||
public function testTheCombinationIsValidated(StaffingRule $rule, array $expectedPaths): void
|
||||
{
|
||||
$violations = Validation::createValidator()->validate($rule, new Callback('validateCombination'));
|
||||
|
||||
$paths = [];
|
||||
|
||||
foreach ($violations as $violation) {
|
||||
$paths[] = $violation->getPropertyPath();
|
||||
}
|
||||
|
||||
$this->assertSame($expectedPaths, $paths);
|
||||
}
|
||||
|
||||
public static function combinations(): iterable
|
||||
{
|
||||
yield 'guides only' => [self::rule(2), []];
|
||||
yield 'split with a level per guide' => [self::rule(2, beginner: true, advanced: true, split: true), []];
|
||||
yield 'split with more levels than guides' => [self::rule(1, beginner: true, advanced: true, split: true), ['split']];
|
||||
yield 'split without a level' => [self::rule(2, split: true), ['split']];
|
||||
yield 'guiding without a guide' => [self::rule(0, beginner: true, guiding: true), ['guiding']];
|
||||
yield 'bus escort without a guide' => [self::rule(0, beginner: true, busEscort: true), ['busEscort']];
|
||||
yield 'courses without guides' => [self::rule(0, beginner: true), []];
|
||||
}
|
||||
|
||||
private static function rule(
|
||||
int $guides,
|
||||
bool $beginner = false,
|
||||
bool $advanced = false,
|
||||
bool $split = false,
|
||||
bool $guiding = false,
|
||||
bool $busEscort = false,
|
||||
): StaffingRule {
|
||||
return (new StaffingRule())
|
||||
->setProductCode('DKIMP')
|
||||
->setGuides($guides)
|
||||
->setSkiBeginner($beginner)
|
||||
->setSkiAdvanced($advanced)
|
||||
->setSplit($split)
|
||||
->setGuiding($guiding)
|
||||
->setBusEscort($busEscort)
|
||||
;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user