mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 04:44:19 +01:00
Create Testcoverage and upgrade Symfomy and PHP
* Some tests * More tests! * Tests 3 * Move getScores from Candidate to Quiz * Add some suggestions for future refactoring * - **Add Gedmo doctrine-extensions and Stof bundle integration** - Added `stof/doctrine-extensions-bundle` and `gedmo/doctrine-extensions` dependencies. - Integrated `Timestampable` behavior for `Created` fields in entities. - Updated `bundles.php` to register StofDoctrineExtensionsBundle. - Added configuration for the Stof bundle. - Simplified `SeasonVoter` with `match` expression and added new tests. - Minor fixes and adjustments across various files. * WIP * All the tests * Base64 tests * Symfomny 7.4.0 * Update * Update recipe * PHP 8.5 * Rector changes * More 8.5 * Things
This commit is contained in:
75
src/DataFixtures/TestFixtures.php
Normal file
75
src/DataFixtures/TestFixtures.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tvdt\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Tvdt\Entity\Season;
|
||||
use Tvdt\Entity\User;
|
||||
|
||||
final class TestFixtures extends Fixture implements FixtureGroupInterface, DependentFixtureInterface
|
||||
{
|
||||
public const string PASSWORD = 'test1234';
|
||||
|
||||
public function __construct(
|
||||
private readonly UserPasswordHasherInterface $passwordHasher,
|
||||
) {}
|
||||
|
||||
public static function getGroups(): array
|
||||
{
|
||||
return ['test'];
|
||||
}
|
||||
|
||||
public function getDependencies(): array
|
||||
{
|
||||
return [KrtekFixtures::class];
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$user = new User();
|
||||
$user->email = 'test@example.org';
|
||||
$user->password = $this->passwordHasher->hashPassword($user, self::PASSWORD);
|
||||
|
||||
$manager->persist($user);
|
||||
|
||||
$user = new User();
|
||||
$user->email = 'krtek-admin@example.org';
|
||||
$user->password = $this->passwordHasher->hashPassword($user, self::PASSWORD);
|
||||
|
||||
$manager->persist($user);
|
||||
|
||||
$krtek = $this->getReference(KrtekFixtures::KRTEK_SEASON, Season::class);
|
||||
$krtek->addOwner($user);
|
||||
|
||||
$anotherSeason = new Season();
|
||||
$anotherSeason->name = 'Another Season';
|
||||
$anotherSeason->seasonCode = 'bbbbb';
|
||||
|
||||
$manager->persist($anotherSeason);
|
||||
$this->addReference('another-season', $anotherSeason);
|
||||
|
||||
$user = new User();
|
||||
$user->email = 'user1@example.org';
|
||||
$user->password = $this->passwordHasher->hashPassword($user, self::PASSWORD);
|
||||
|
||||
$manager->persist($user);
|
||||
$user->addSeason($anotherSeason);
|
||||
|
||||
$user = new User();
|
||||
$user->email = 'user2@example.org';
|
||||
$user->password = $this->passwordHasher->hashPassword($user, self::PASSWORD);
|
||||
|
||||
$manager->persist($user);
|
||||
|
||||
$krtek->addOwner($user);
|
||||
$anotherSeason->addOwner($user);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user