Skip to content

Commit

Permalink
Enhancement: Show and validate Doctrine mapping information
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Mar 13, 2020
1 parent fb65c38 commit 0110d59
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.dependabot/ export-ignore
/.github/ export-ignore
/config/ export-ignore
/test/ export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ jobs:
if: "matrix.dependencies == 'highest'"
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Show Doctrine mapping information"
run: "vendor/bin/doctrine orm:info"

- name: "Validate Doctrine mapping"
run: "vendor/bin/doctrine orm:validate-schema --skip-sync"

- name: "Run auto-review tests with phpunit/phpunit"
run: "vendor/bin/phpunit --configuration=test/AutoReview/phpunit.xml"

Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ MIN_COVERED_MSI:=84
MIN_MSI:=53

.PHONY: it
it: coding-standards dependency-analysis static-code-analysis tests ## Runs the coding-standards, dependency-analysis, static-code-analysis, and tests targets
it: coding-standards dependency-analysis static-code-analysis doctrine tests ## Runs the coding-standards, dependency-analysis, static-code-analysis, doctrine, and tests targets

.PHONY: code-coverage
code-coverage: vendor ## Collects coverage from running unit tests with phpunit/phpunit
Expand All @@ -18,6 +18,11 @@ coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fix
dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker
docker run --interactive --rm --tty --volume ${PWD}:/app webfactory/composer-require-checker:2.1.0 check --config-file=composer-require-checker.json

.PHONY: doctrine
doctrine: vendor ## Shows and validates Docrine mapping information
vendor/bin/doctrine orm:info
vendor/bin/doctrine orm:validate-schema --skip-sync

.PHONY: help
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down
21 changes: 21 additions & 0 deletions config/cli-config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2020 Andreas M枚ller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/factory-bot
*/

use Doctrine\ORM;
use Ergebnis\FactoryBot\Test\Util;

require_once __DIR__ . '/../vendor/autoload.php';

$entityManager = Util\Doctrine\ORM\EntityManagerFactory::create();

return ORM\Tools\Console\ConsoleRunner::createHelperSet($entityManager);
16 changes: 2 additions & 14 deletions test/Integration/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Ergebnis\FactoryBot\Test\Integration;

use Doctrine\ORM;
use Ergebnis\FactoryBot\Test\Util;
use PHPUnit\Framework;

/**
Expand All @@ -23,20 +24,7 @@ abstract class AbstractTestCase extends Framework\TestCase
{
final protected static function createEntityManager(): ORM\EntityManagerInterface
{
$configuration = ORM\Tools\Setup::createAnnotationMetadataConfiguration(
[
__DIR__ . '/../Fixture/Entity',
],
true
);

$entityManager = ORM\EntityManager::create(
[
'driver' => 'pdo_sqlite',
'path' => ':memory:',
],
$configuration
);
$entityManager = Util\Doctrine\ORM\EntityManagerFactory::create();

$schemaTool = new ORM\Tools\SchemaTool($entityManager);

Expand Down
16 changes: 2 additions & 14 deletions test/Unit/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Ergebnis\FactoryBot\Test\Unit;

use Doctrine\ORM;
use Ergebnis\FactoryBot\Test\Util;
use PHPUnit\Framework;

/**
Expand All @@ -23,19 +24,6 @@ abstract class AbstractTestCase extends Framework\TestCase
{
final protected static function createEntityManager(): ORM\EntityManagerInterface
{
$configuration = ORM\Tools\Setup::createAnnotationMetadataConfiguration(
[
__DIR__ . '/../Fixture/Entity',
],
true
);

return ORM\EntityManager::create(
[
'driver' => 'pdo_sqlite',
'path' => ':memory:',
],
$configuration
);
return Util\Doctrine\ORM\EntityManagerFactory::create();
}
}
37 changes: 37 additions & 0 deletions test/Util/Doctrine/ORM/EntityManagerFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2020 Andreas M枚ller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/factory-bot
*/

namespace Ergebnis\FactoryBot\Test\Util\Doctrine\ORM;

use Doctrine\ORM;

final class EntityManagerFactory
{
public static function create(): ORM\EntityManagerInterface
{
$configuration = ORM\Tools\Setup::createAnnotationMetadataConfiguration(
[
__DIR__ . '/../../../Fixture/Entity',
],
true
);

return ORM\EntityManager::create(
[
'driver' => 'pdo_sqlite',
'path' => ':memory:',
],
$configuration
);
}
}

0 comments on commit 0110d59

Please sign in to comment.