diff --git a/.gitignore b/.gitignore index 7d5318d..19e9cb9 100755 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ composer.phar composer.lock .phpunit.result.cache +.phpunit.cache vendor/ coverage/ diff --git a/Makefile b/Makefile index 9959023..4d62c70 100755 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ fix-cs: docker-compose run --rm --no-deps app ./vendor/bin/phpcbf stan: - docker-compose run --rm --no-deps app ./vendor/bin/phpstan analyse --level=9 --no-progress src/ tests/ + docker-compose run --rm --no-deps app ./vendor/bin/phpstan analyse --level=9 -c phpstan.neon --no-progress src/ tests/ setup: install-php diff --git a/composer.json b/composer.json index 2bbebc2..d74dcb5 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,6 @@ "php": ">=8.1", "doctrine/orm": "~2.7", - "gedmo/doctrine-extensions": "^3.0", "psr/log": "^1.0|^2.0|^3.0", "wmde/email-address": "~1.0", @@ -15,7 +14,8 @@ "require-dev": { "phpunit/phpunit": "~10.1.1", "wmde/fundraising-phpcs": "~8.0", - "phpstan/phpstan": "~1.7" + "phpstan/phpstan": "~1.7", + "symfony/cache": "^6.1" }, "repositories": [ { diff --git a/config/DoctrineClassMapping/WMDE.Fundraising.SubscriptionContext.Domain.Model.Subscription.dcm.xml b/config/DoctrineClassMapping/WMDE.Fundraising.SubscriptionContext.Domain.Model.Subscription.dcm.xml index 28fdf87..1bc1995 100644 --- a/config/DoctrineClassMapping/WMDE.Fundraising.SubscriptionContext.Domain.Model.Subscription.dcm.xml +++ b/config/DoctrineClassMapping/WMDE.Fundraising.SubscriptionContext.Domain.Model.Subscription.dcm.xml @@ -1,7 +1,6 @@ @@ -18,8 +17,6 @@ - - - + diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..c928bb8 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,6 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#" + count: 1 + path: src/DataAccess/DoctrineSubscriptionRepository.php diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..2ee6a55 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,2 @@ +includes: + - phpstan-baseline.neon diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 05e4aae..253a2c4 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,18 +1,15 @@ - - - - src - - + + tests/Unit @@ -21,4 +18,9 @@ tests/Integration + + + src + + diff --git a/src/Domain/Model/Subscription.php b/src/Domain/Model/Subscription.php index d410c40..d2cfa26 100644 --- a/src/Domain/Model/Subscription.php +++ b/src/Domain/Model/Subscription.php @@ -35,6 +35,7 @@ class Subscription { public function __construct() { $this->setStatus( self::STATUS_NEW ); + $this->createdAt = new DateTime(); } public function setEmail( string $email ): self { diff --git a/src/SubscriptionContextFactory.php b/src/SubscriptionContextFactory.php index 808fee3..a7ea04d 100644 --- a/src/SubscriptionContextFactory.php +++ b/src/SubscriptionContextFactory.php @@ -4,10 +4,6 @@ namespace WMDE\Fundraising\SubscriptionContext; -use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\Common\EventSubscriber; -use Gedmo\Timestampable\TimestampableListener; - class SubscriptionContextFactory { private const DOCTRINE_CLASS_MAPPING_DIRECTORY = __DIR__ . '/../config/DoctrineClassMapping'; @@ -18,16 +14,4 @@ class SubscriptionContextFactory { public function getDoctrineMappingPaths(): array { return [ self::DOCTRINE_CLASS_MAPPING_DIRECTORY ]; } - - /** - * @return array - */ - public function newEventSubscribers(): array { - $timestampableListener = new TimestampableListener(); - $timestampableListener->setAnnotationReader( new AnnotationReader() ); - return [ - TimestampableListener::class => $timestampableListener - ]; - } - } diff --git a/tests/TestSubscriptionContextFactory.php b/tests/TestSubscriptionContextFactory.php index d915b2c..8f9799a 100644 --- a/tests/TestSubscriptionContextFactory.php +++ b/tests/TestSubscriptionContextFactory.php @@ -4,18 +4,14 @@ namespace WMDE\Fundraising\SubscriptionContext\Tests; -use Doctrine\Common\EventManager; -use Doctrine\Common\EventSubscriber; use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; -use WMDE\Fundraising\SubscriptionContext\SubscriptionContextFactory; class TestSubscriptionContextFactory { private Configuration $doctrineConfig; - private SubscriptionContextFactory $factory; private Connection $connection; private ?EntityManager $entityManager; @@ -26,33 +22,17 @@ public function __construct( Configuration $doctrineConfig ) { 'driver' => 'pdo_sqlite', 'memory' => true, ] ); - $this->factory = new SubscriptionContextFactory(); $this->entityManager = null; } public function getEntityManager(): EntityManager { if ( $this->entityManager === null ) { - $eventManager = $this->setupEventSubscribers( $this->factory->newEventSubscribers() ); - $this->entityManager = new EntityManager( $this->connection, - $this->doctrineConfig, - $eventManager + $this->doctrineConfig ); } return $this->entityManager; } - - /** - * @param EventSubscriber[] $eventSubscribers - * @return EventManager - */ - private function setupEventSubscribers( array $eventSubscribers ): EventManager { - $eventManager = new EventManager(); - foreach ( $eventSubscribers as $eventSubscriber ) { - $eventManager->addEventSubscriber( $eventSubscriber ); - } - return $eventManager; - } }