Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homepage #10

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
DATABASE_URL=sqlite:///%kernel.project_dir%/var/test.db
6 changes: 6 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,11 @@ jobs:
- name: Build webpack
run: yarn encore prod

- name: Create database
run: bin/console doctrine:database:create --env test

- name: Create database schema
run: bin/console doctrine:schema:create --env test

- name: Run test suite
run: bin/phpunit
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"symfony/yaml": "5.0.*"
},
"require-dev": {
"dama/doctrine-test-bundle": "^6.3",
"doctrine/doctrine-fixtures-bundle": "^3.3",
"easycorp/easy-log-handler": "^1.0.7",
"friendsofphp/php-cs-fixer": "^2.16",
Expand Down
74 changes: 66 additions & 8 deletions composer.lock

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

1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
DAMA\DoctrineTestBundle\DAMADoctrineTestBundle::class => ['test' => true],
];
4 changes: 4 additions & 0 deletions config/packages/test/dama_doctrine_test_bundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dama_doctrine_test:
enable_static_connection: true
enable_static_meta_data_cache: true
enable_static_query_cache: true
8 changes: 7 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ services:
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
volumes:
- dbdata:/var/lib/mysql

mailhog:
image: mailhog/mailhog
ports:
- 1025:1025
- 8025:8025
- 8025:8025

volumes:
dbdata:
driver: local
6 changes: 5 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
<server name="SYMFONY_PHPUNIT_VERSION" value="8.5" />
<server name="SYMFONY_PHPUNIT_VERSION" value="9.0" />
</php>

<testsuites>
Expand All @@ -30,6 +30,10 @@
</whitelist>
</filter>

<extensions>
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"/>
</extensions>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
Expand Down
7 changes: 5 additions & 2 deletions src/Action/HomeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Action;

use App\Repository\AppointmentRepository;
use Basster\LazyResponseBundle\Response\TemplateResponse;
use Symfony\Component\Routing\Annotation\Route;

Expand All @@ -12,8 +13,10 @@ final class HomeAction
/**
* @Route("/", name="app_home")
*/
public function __invoke(): TemplateResponse
public function __invoke(AppointmentRepository $appointmentRepository): TemplateResponse
{
return new TemplateResponse('home.html.twig');
return new TemplateResponse('home.html.twig', [
'appointments' => $appointmentRepository->findAll(),
]);
}
}
23 changes: 19 additions & 4 deletions src/DataFixtures/AppointmentFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,52 @@
namespace App\DataFixtures;

use App\Entity\Appointment;
use App\Entity\Attribute;
use DateTimeImmutable;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;

class AppointmentFixtures extends Fixture implements DependentFixtureInterface
final class AppointmentFixtures extends Fixture implements DependentFixtureInterface
{
public const PHPUGHB_3 = 'appointment:phpughb3';

public function load(ObjectManager $manager): void
{
/** @var \App\Entity\Talk $talk */
$talk = $this->getReference(TalkFixtures::TALK_SOLID);
/** @var \App\Entity\Location $teamNeusta */
$teamNeusta = $this->getReference(LocationFixtures::TEAM_NEUSTA);
$ticketsType = $this->getReference(AttributeFixtures::TYPE_TICKETS);

$ticketsAttr = new Attribute($ticketsType, 'Anmelden', 'https://www.eventbrite.de/e/php-usergroup-bremen-phpughb-iii-tickets-93670576215');

$appointment = new Appointment(
'#PHPUGHB III',
'Lorem ipsum',
DateTimeImmutable::createFromFormat('Y-m-d H:i', '2020-03-11 18:30')
);
$appointment->addTalk($talk);
$appointment->setLocation($teamNeusta);
$appointment->addAttribute($ticketsAttr);

$manager->persist($appointment);
$manager->persist($ticketsAttr);

$manager->flush();

$this->addReference('appointment:phpughb3', $appointment);
$this->addReference(self::PHPUGHB_3, $appointment);
}

/**
* {@inheritdoc}
*/
public function getDependencies(): array
{
return [TalkFixtures::class];
return [
TalkFixtures::class,
LocationFixtures::class,
AttributeFixtures::class,
];
}
}
42 changes: 42 additions & 0 deletions src/DataFixtures/AttributeFixtures.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace App\DataFixtures;

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

/**
* Class AttributeFixtures.
*/
final class AttributeFixtures extends Fixture
{
public const TYPE_TWITTER = 'attribute_type:twitter';
public const TYPE_YOUTUBE = 'attribute_type:youtube';
public const TYPE_LATLNG = 'attribute_type:latlng';
public const TYPE_TICKETS = 'attribute_type:tickets';

/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager): void
{
$twitterType = new AttributeType('twitter', 'twitter');
$youtubeType = new AttributeType('youtube', 'youtube');
$latLngType = new AttributeType('map-marker-alt', 'latlng');
$ticketsType = new AttributeType('calendar-check', 'tickets');

$manager->persist($twitterType);
$manager->persist($youtubeType);
$manager->persist($latLngType);
$manager->persist($ticketsType);
$manager->flush();

$this->addReference(self::TYPE_TWITTER, $twitterType);
$this->addReference(self::TYPE_YOUTUBE, $youtubeType);
$this->addReference(self::TYPE_LATLNG, $latLngType);
$this->addReference(self::TYPE_TICKETS, $ticketsType);
}
}
47 changes: 47 additions & 0 deletions src/DataFixtures/LocationFixtures.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace App\DataFixtures;

use App\Entity\Attribute;
use App\Entity\Location;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager;

/**
* Class LocationFixtures.
*/
final class LocationFixtures extends Fixture implements DependentFixtureInterface
{
public const TEAM_NEUSTA = 'location:team-neusta';

/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager): void
{
$latLngType = $this->getReference(AttributeFixtures::TYPE_LATLNG);

$teamNeusta = new Location('team neusta', 'Konsul-Smidt-Str.', '24', '28217', 'Bremen');
$tnLatLng = new Attribute($latLngType, '8.7742443,53.090925');
$teamNeusta->addAttribute($tnLatLng);

$manager->persist($teamNeusta);
$manager->persist($tnLatLng);
$manager->flush();

$this->setReference(self::TEAM_NEUSTA, $teamNeusta);
}

/**
* {@inheritdoc}
*/
public function getDependencies(): array
{
return [
AttributeFixtures::class,
];
}
}
Loading