Skip to content

Commit

Permalink
EV-318: Updated fixtures with images
Browse files Browse the repository at this point in the history
  • Loading branch information
cableman committed Nov 27, 2023
1 parent 07a1c76 commit 2b8e2da
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/DataFixtures/EventFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function load(ObjectManager $manager): void
->setLocation($this->getReference(LocationFixture::ITKDEV))
->addTag($this->getReference(TagsFixtures::AROS))
->addTag($this->getReference(TagsFixtures::RACE))
->addTag($this->getReference(TagsFixtures::ITKDEV))

Check failure on line 33 in src/DataFixtures/EventFixture.php

View workflow job for this annotation

GitHub Actions / Psalm static analysis (8.2)

ArgumentTypeCoercion

src/DataFixtures/EventFixture.php:33:22: ArgumentTypeCoercion: Argument 1 of App\Entity\Event::addTag expects App\Entity\Tag, but parent type object provided (see https://psalm.dev/193)
->setImage($this->getReference(ImagesFixtures::ITK))

Check failure on line 34 in src/DataFixtures/EventFixture.php

View workflow job for this annotation

GitHub Actions / Psalm static analysis (8.2)

ArgumentTypeCoercion

src/DataFixtures/EventFixture.php:34:24: ArgumentTypeCoercion: Argument 1 of App\Entity\Event::setImage expects App\Entity\Image|null, but parent type object provided (see https://psalm.dev/193)
->setEditable(true)
->setHash('4936efebda146f6775fb7e429d884fef');
$manager->persist($event);
Expand All @@ -47,6 +49,7 @@ public function load(ObjectManager $manager): void
->addTag($this->getReference(TagsFixtures::CONCERT))
->addTag($this->getReference(TagsFixtures::AROS))
->setEditable(true)
->setImage($this->getReference(ImagesFixtures::AAK))

Check failure on line 52 in src/DataFixtures/EventFixture.php

View workflow job for this annotation

GitHub Actions / Psalm static analysis (8.2)

ArgumentTypeCoercion

src/DataFixtures/EventFixture.php:52:24: ArgumentTypeCoercion: Argument 1 of App\Entity\Event::setImage expects App\Entity\Image|null, but parent type object provided (see https://psalm.dev/193)
->setHash('16d48c26d38f6d59b3d081e596b4d0e8');
$manager->persist($event);
$this->addReference(self::EVENT1, $event);
Expand Down
35 changes: 35 additions & 0 deletions src/DataFixtures/ImagesFixtures.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\DataFixtures;

use App\Entity\Image;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;

final class ImagesFixtures extends Fixture
{
public const AAK = 'image_aak';
public const ITK = 'image_itk';

public function load(ObjectManager $manager): void
{
$image = new Image();
$image->setEditable(true)
->setTitle('ITK Test image')
->setSource('https://itk.aarhus.dk/media/79711/itk-4f-10.png');
$manager->persist($image);
$this->addReference(self::ITK, $image);

$image = new Image();
$image->setEditable(false)
->setTitle('AAK Test image')
->setSource('https://placehold.co/600x400/0FF0FF/FF0000.png?text=ITK');
$manager->persist($image);
$this->addReference(self::AAK, $image);

// @TODO: Trigger image download to local storage.

// Make it stick.
$manager->flush();
}
}
1 change: 0 additions & 1 deletion src/DataFixtures/TagsFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function load(ObjectManager $manager): void
$manager->persist($tag);
$this->addReference(self::ITKDEV, $tag);


// Make it stick.
$manager->flush();
}
Expand Down

0 comments on commit 2b8e2da

Please sign in to comment.