Compare commits
4 Commits
c03d6bb549
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b259e058b | |||
| 1d0f293827 | |||
| d5cbd4d56e | |||
| 8dc93df394 |
9
Makefile
Normal file
9
Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
SHELL := /bin/bash
|
||||
|
||||
tests:
|
||||
symfony console doctrine:database:drop --force --env=test || true
|
||||
symfony console doctrine:database:create --env=test
|
||||
symfony console doctrine:migrations:migrate -n --env=test
|
||||
symfony console doctrine:fixtures:load -n --env=test
|
||||
symfony php bin/phpunit $(MAKECMDGOALS)
|
||||
.PHONY: tests
|
||||
@@ -100,6 +100,7 @@
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/doctrine-fixtures-bundle": "^3.6",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"symfony/browser-kit": "6.4.*",
|
||||
"symfony/css-selector": "6.4.*",
|
||||
|
||||
173
composer.lock
generated
173
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "8c1a998d0fd531901efdf4231f51010e",
|
||||
"content-hash": "7a088b51b25fa5dd11238a61747b340d",
|
||||
"packages": [
|
||||
{
|
||||
"name": "blackfire/php-sdk",
|
||||
@@ -8015,6 +8015,177 @@
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "doctrine/data-fixtures",
|
||||
"version": "1.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/data-fixtures.git",
|
||||
"reference": "bbcb74f2ac6dbe81a14b3c3687d7623490a0448f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/data-fixtures/zipball/bbcb74f2ac6dbe81a14b3c3687d7623490a0448f",
|
||||
"reference": "bbcb74f2ac6dbe81a14b3c3687d7623490a0448f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/deprecations": "^0.5.3 || ^1.0",
|
||||
"doctrine/persistence": "^2.0|^3.0",
|
||||
"php": "^7.4 || ^8.0"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/dbal": "<3.5 || >=5",
|
||||
"doctrine/orm": "<2.14 || >=4",
|
||||
"doctrine/phpcr-odm": "<1.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/annotations": "^1.12 || ^2",
|
||||
"doctrine/coding-standard": "^12",
|
||||
"doctrine/dbal": "^3.5 || ^4",
|
||||
"doctrine/mongodb-odm": "^1.3.0 || ^2.0.0",
|
||||
"doctrine/orm": "^2.14 || ^3",
|
||||
"ext-sqlite3": "*",
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpunit/phpunit": "^9.6.13 || ^10.4.2",
|
||||
"symfony/cache": "^5.4 || ^6.3 || ^7",
|
||||
"symfony/var-exporter": "^5.4 || ^6.3 || ^7",
|
||||
"vimeo/psalm": "^5.9"
|
||||
},
|
||||
"suggest": {
|
||||
"alcaeus/mongo-php-adapter": "For using MongoDB ODM 1.3 with PHP 7 (deprecated)",
|
||||
"doctrine/mongodb-odm": "For loading MongoDB ODM fixtures",
|
||||
"doctrine/orm": "For loading ORM fixtures",
|
||||
"doctrine/phpcr-odm": "For loading PHPCR ODM fixtures"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Common\\DataFixtures\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Data Fixtures for all Doctrine Object Managers",
|
||||
"homepage": "https://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"database"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/doctrine/data-fixtures/issues",
|
||||
"source": "https://github.com/doctrine/data-fixtures/tree/1.7.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://www.doctrine-project.org/sponsorship.html",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/phpdoctrine",
|
||||
"type": "patreon"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdata-fixtures",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-11-24T11:18:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/doctrine-fixtures-bundle",
|
||||
"version": "3.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/DoctrineFixturesBundle.git",
|
||||
"reference": "d13a08ebf244f74c8adb8ff15aa55d01c404e534"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/d13a08ebf244f74c8adb8ff15aa55d01c404e534",
|
||||
"reference": "d13a08ebf244f74c8adb8ff15aa55d01c404e534",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/data-fixtures": "^1.3",
|
||||
"doctrine/doctrine-bundle": "^2.2",
|
||||
"doctrine/orm": "^2.14.0 || ^3.0",
|
||||
"doctrine/persistence": "^2.4|^3.0",
|
||||
"php": "^7.4 || ^8.0",
|
||||
"symfony/config": "^5.4|^6.0|^7.0",
|
||||
"symfony/console": "^5.4|^6.0|^7.0",
|
||||
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
|
||||
"symfony/deprecation-contracts": "^2.1|^3",
|
||||
"symfony/doctrine-bridge": "^5.4|^6.0|^7.0",
|
||||
"symfony/http-kernel": "^5.4|^6.0|^7.0"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/dbal": "< 3"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^12",
|
||||
"phpstan/phpstan": "^1.10.39",
|
||||
"phpunit/phpunit": "^9.6.13",
|
||||
"symfony/phpunit-bridge": "^6.3.6",
|
||||
"vimeo/psalm": "^5.15"
|
||||
},
|
||||
"type": "symfony-bundle",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Bundle\\FixturesBundle\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Doctrine Project",
|
||||
"homepage": "https://www.doctrine-project.org"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony DoctrineFixturesBundle",
|
||||
"homepage": "https://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"Fixture",
|
||||
"persistence"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/doctrine/DoctrineFixturesBundle/issues",
|
||||
"source": "https://github.com/doctrine/DoctrineFixturesBundle/tree/3.6.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://www.doctrine-project.org/sponsorship.html",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/phpdoctrine",
|
||||
"type": "patreon"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdoctrine-fixtures-bundle",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-05-07T07:16:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "masterminds/html5",
|
||||
"version": "2.9.0",
|
||||
|
||||
@@ -14,4 +14,5 @@ return [
|
||||
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
||||
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
||||
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
||||
];
|
||||
|
||||
48
src/DataFixtures/AppFixtures.php
Normal file
48
src/DataFixtures/AppFixtures.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
use App\Entity\Admin;
|
||||
use App\Entity\Comment;
|
||||
use App\Entity\Conference;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface;
|
||||
|
||||
class AppFixtures extends Fixture
|
||||
{
|
||||
public function __construct(
|
||||
private PasswordHasherFactoryInterface $passwordHasherFactory,
|
||||
) {
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$amsterdam = new Conference();
|
||||
$amsterdam->setCity('Amsterdam');
|
||||
$amsterdam->setYear('2019');
|
||||
$amsterdam->setIsInternational(true);
|
||||
$manager->persist($amsterdam);
|
||||
|
||||
$slc = new Conference();
|
||||
$slc->setCity('Salt Lake City');
|
||||
$slc->setYear('2021');
|
||||
$slc->setIsInternational(false);
|
||||
$manager->persist($slc);
|
||||
|
||||
$comment1 = new Comment();
|
||||
$comment1->setConference($amsterdam);
|
||||
$comment1->setAuthor('Jake');
|
||||
$comment1->setEmail('jake@example.com');
|
||||
$comment1->setText('This was a great conference.');
|
||||
$manager->persist($comment1);
|
||||
|
||||
$admin = new Admin();
|
||||
$admin->setRoles(['ROLE_ADMIN']);
|
||||
$admin->setUsername('admin');
|
||||
$admin->setPassword($this->passwordHasherFactory->getPasswordHasher(Admin::class)->hash('admin'));
|
||||
$manager->persist($admin);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
12
symfony.lock
12
symfony.lock
@@ -25,6 +25,18 @@
|
||||
"src/Repository/.gitignore"
|
||||
]
|
||||
},
|
||||
"doctrine/doctrine-fixtures-bundle": {
|
||||
"version": "3.6",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "3.0",
|
||||
"ref": "1f5514cfa15b947298df4d771e694e578d4c204d"
|
||||
},
|
||||
"files": [
|
||||
"src/DataFixtures/AppFixtures.php"
|
||||
]
|
||||
},
|
||||
"doctrine/doctrine-migrations-bundle": {
|
||||
"version": "3.3",
|
||||
"recipe": {
|
||||
|
||||
41
tests/ConferenceSluggerTest.php
Normal file
41
tests/ConferenceSluggerTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use App\Entity\Conference;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\String\Slugger\SluggerInterface;
|
||||
|
||||
|
||||
class ConferenceSluggerTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideConferences
|
||||
*/
|
||||
public function testConferenceComputeSlug(string $expectedResult, Conference $conference): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$slugger = static::getContainer()->get(SluggerInterface::class);
|
||||
|
||||
$conference->computeSlug($slugger);
|
||||
$this->assertSame($expectedResult, $conference->getSlug());
|
||||
}
|
||||
|
||||
public static function provideConferences(): iterable
|
||||
{
|
||||
$conference = new Conference();
|
||||
$conference->setCity("Barcelona");
|
||||
$conference->setyear("2002");
|
||||
yield ["barcelona-2002", $conference];
|
||||
|
||||
$conference = new Conference();
|
||||
$conference->setCity("Tokyo");
|
||||
$conference->setyear("2020");
|
||||
yield ["tokyo-2020", $conference];
|
||||
|
||||
$conference = new Conference();
|
||||
$conference->setCity("Mexico City");
|
||||
$conference->setyear("1999");
|
||||
yield ["mexico-city-1999", $conference];
|
||||
}
|
||||
}
|
||||
47
tests/Controller/ConferenceControllerTest.php
Normal file
47
tests/Controller/ConferenceControllerTest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class ConferenceControllerTest extends WebTestCase
|
||||
{
|
||||
public function testIndex()
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/');
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertSelectorTextContains('h2', 'Give your feedback');
|
||||
}
|
||||
|
||||
public function testConferencePage()
|
||||
{
|
||||
$client = static::createClient();
|
||||
$crawler = $client->request('GET', '/');
|
||||
|
||||
$this->assertCount(2, $crawler->filter('h4'));
|
||||
|
||||
$client->clickLink('View');
|
||||
|
||||
$this->assertPageTitleContains('Amsterdam');
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertSelectorTextContains('h2', 'Amsterdam 2019');
|
||||
$this->assertSelectorExists('div:contains("There are 1 comments")');
|
||||
}
|
||||
|
||||
public function testCommentSubmission()
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', 'conference/amsterdam-2019');
|
||||
$client->submitForm('Submit', [
|
||||
'comment[author]' => 'Bob',
|
||||
'comment[text]' => 'Some feedback from an automated functional test',
|
||||
'comment[email]' => 'test@example.com',
|
||||
'comment[photo]' => dirname(__DIR__, 2) . '/public/images/under-construction.gif',
|
||||
]);
|
||||
$this->assertResponseRedirects();
|
||||
$client->followRedirect();
|
||||
$this->assertSelectorExists('div:contains("There are 2 comments")');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user