From 43fb174deee98bef0af66972e134a72a293fcc80 Mon Sep 17 00:00:00 2001 From: Tatevik Date: Tue, 10 Dec 2024 20:51:28 +0400 Subject: [PATCH] ISSUE-337: fix phpcs --- composer.json | 6 ++- src/Domain/Model/Identity/Administrator.php | 20 +++---- .../Model/Identity/AdministratorToken.php | 18 +++---- src/Domain/Model/Messaging/SubscriberList.php | 42 +++++++-------- src/Domain/Model/Subscription/Subscriber.php | 54 +++++++++---------- .../Model/Subscription/Subscription.php | 32 +++++------ src/Domain/Model/Traits/IdentityTrait.php | 4 +- .../Messaging/SubscriberListRepository.php | 3 +- .../Traits/DatabaseTestTrait.php | 8 ++- src/TestingSupport/Traits/ModelTestTrait.php | 4 +- .../Fixtures/AdministratorFixture.php | 12 +++-- ...nistratorTokenWithAdministratorFixture.php | 15 +++--- .../DetachedAdministratorTokenFixture.php | 12 +++-- .../Repository/Fixtures/SubscriberFixture.php | 14 +++-- .../Fixtures/SubscriberListFixture.php | 17 +++--- .../Fixtures/SubscriptionFixture.php | 12 +++-- .../Identity/AdministratorRepositoryTest.php | 11 ++-- .../AdministratorTokenRepositoryTest.php | 3 +- tests/Unit/Composer/ScriptHandlerTest.php | 16 +++++- .../Model/Identity/AdministratorTest.php | 2 +- 20 files changed, 178 insertions(+), 127 deletions(-) diff --git a/composer.json b/composer.json index fd17d6e..ea89ef1 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,11 @@ "symfony/test-pack": "^1.1", "symfony/process": "^6.4", "composer/composer": "^2.7", - "symfony/symfony": "^6.4" + "symfony/framework-bundle": "^6.4", + "symfony/http-kernel": "^6.4", + "symfony/http-foundation": "^6.4", + "symfony/routing": "^6.4", + "symfony/console": "^6.4" }, "suggest": { "phplist/web-frontend": "5.0.x-dev", diff --git a/src/Domain/Model/Identity/Administrator.php b/src/Domain/Model/Identity/Administrator.php index 065c19a..eef4c5f 100644 --- a/src/Domain/Model/Identity/Administrator.php +++ b/src/Domain/Model/Identity/Administrator.php @@ -20,8 +20,8 @@ * * @author Oliver Klee */ -#[ORM\Entity(repositoryClass: "PhpList\Core\Domain\Repository\Identity\AdministratorRepository")] -#[ORM\Table(name: "phplist_admin")] +#[ORM\Entity(repositoryClass: 'PhpList\Core\Domain\Repository\Identity\AdministratorRepository')] +#[ORM\Table(name: 'phplist_admin')] #[ORM\HasLifecycleCallbacks] class Administrator implements DomainModel, Identity, CreationDate, ModificationDate { @@ -29,28 +29,28 @@ class Administrator implements DomainModel, Identity, CreationDate, Modification use CreationDateTrait; use ModificationDateTrait; - #[ORM\Column(name: "loginname")] + #[ORM\Column(name: 'loginname')] private string $loginName; - #[ORM\Column(name: "email")] + #[ORM\Column(name: 'email')] private string $emailAddress; - #[ORM\Column(name: "created", type: "datetime")] + #[ORM\Column(name: 'created', type: 'datetime')] protected ?DateTime $creationDate = null; - #[ORM\Column(name: "modified", type: "datetime")] + #[ORM\Column(name: 'modified', type: 'datetime')] protected ?DateTime $modificationDate; - #[ORM\Column(name: "password")] + #[ORM\Column(name: 'password')] private string $passwordHash; - #[ORM\Column(name: "passwordchanged", type: "date", nullable: true)] + #[ORM\Column(name: 'passwordchanged', type: 'date', nullable: true)] private ?DateTime $passwordChangeDate; - #[ORM\Column(type: "boolean")] + #[ORM\Column(type: 'boolean')] private bool $disabled; - #[ORM\Column(name: "superuser", type: "boolean")] + #[ORM\Column(name: 'superuser', type: 'boolean')] private bool $superUser; public function __construct() diff --git a/src/Domain/Model/Identity/AdministratorToken.php b/src/Domain/Model/Identity/AdministratorToken.php index f4041c8..7f4b165 100644 --- a/src/Domain/Model/Identity/AdministratorToken.php +++ b/src/Domain/Model/Identity/AdministratorToken.php @@ -19,8 +19,8 @@ * This class represents an API authentication token for an administrator. * @author Oliver Klee */ -#[ORM\Entity(repositoryClass: "PhpList\Core\Domain\Repository\Identity\AdministratorTokenRepository")] -#[ORM\Table(name: "phplist_admintoken")] +#[ORM\Entity(repositoryClass: 'PhpList\Core\Domain\Repository\Identity\AdministratorTokenRepository')] +#[ORM\Table(name: 'phplist_admintoken')] #[ORM\HasLifecycleCallbacks] class AdministratorToken implements DomainModel, Identity, CreationDate { @@ -28,20 +28,20 @@ class AdministratorToken implements DomainModel, Identity, CreationDate public const DEFAULT_EXPIRY = '+1 hour'; - #[ORM\Column(name: "entered", type: "integer")] + #[ORM\Column(name: 'entered', type: 'integer')] #[Ignore] protected int $creationDate = 0; - #[ORM\Column(name: "expires", type: "datetime")] - #[SerializedName("expiry_date")] + #[ORM\Column(name: 'expires', type: 'datetime')] + #[SerializedName('expiry_date')] private ?DateTime $expiry = null; - #[ORM\Column(name: "value")] - #[SerializedName("key")] + #[ORM\Column(name: 'value')] + #[SerializedName('key')] private string $key = ''; - #[ORM\ManyToOne(targetEntity: "PhpList\Core\Domain\Model\Identity\Administrator")] - #[ORM\JoinColumn(name: "adminid")] + #[ORM\ManyToOne(targetEntity: 'PhpList\Core\Domain\Model\Identity\Administrator')] + #[ORM\JoinColumn(name: 'adminid')] #[Ignore] private ?Administrator $administrator = null; diff --git a/src/Domain/Model/Messaging/SubscriberList.php b/src/Domain/Model/Messaging/SubscriberList.php index 1adf0a7..e8cf788 100644 --- a/src/Domain/Model/Messaging/SubscriberList.php +++ b/src/Domain/Model/Messaging/SubscriberList.php @@ -27,10 +27,10 @@ * selected lists (as the owner), send campaigns to these lists and edit subscribers. * @author Oliver Klee */ -#[ORM\Entity(repositoryClass: "PhpList\Core\Domain\Repository\Messaging\SubscriberListRepository")] -#[ORM\Table(name: "phplist_list")] -#[ORM\Index(name: "nameidx", columns: ["name"])] -#[ORM\Index(name: "listorderidx", columns: ["listorder"])] +#[ORM\Entity(repositoryClass: 'PhpList\Core\Domain\Repository\Messaging\SubscriberListRepository')] +#[ORM\Table(name: 'phplist_list')] +#[ORM\Index(name: 'nameidx', columns: ['name'])] +#[ORM\Index(name: 'listorderidx', columns: ['listorder'])] #[ORM\HasLifecycleCallbacks] class SubscriberList implements DomainModel, Identity, CreationDate, ModificationDate { @@ -39,53 +39,53 @@ class SubscriberList implements DomainModel, Identity, CreationDate, Modificatio use ModificationDateTrait; #[ORM\Column] - #[SerializedName("name")] + #[SerializedName('name')] #[Groups(['SubscriberList'])] private string $name = ''; #[ORM\Column] - #[SerializedName("description")] + #[SerializedName('description')] #[Groups(['SubscriberList'])] private string $description = ''; - #[ORM\Column(name: "entered", type: "datetime", nullable: true)] - #[SerializedName("creation_date")] + #[ORM\Column(name: 'entered', type: 'datetime', nullable: true)] + #[SerializedName('creation_date')] #[Groups(['SubscriberList'])] protected ?DateTime $creationDate = null; - #[ORM\Column(name: "modified", type: "datetime")] + #[ORM\Column(name: 'modified', type: 'datetime')] #[Ignore] protected ?DateTime $modificationDate = null; - #[ORM\Column(name: "listorder", type: "integer")] - #[SerializedName("list_position")] + #[ORM\Column(name: 'listorder', type: 'integer')] + #[SerializedName('list_position')] #[Groups(['SubscriberList'])] private ?int $listPosition; - #[ORM\Column(name: "prefix")] - #[SerializedName("subject_prefix")] + #[ORM\Column(name: 'prefix')] + #[SerializedName('subject_prefix')] #[Groups(['SubscriberList'])] private ?string $subjectPrefix; - #[ORM\Column(name: "active", type: "boolean")] - #[SerializedName("public")] + #[ORM\Column(name: 'active', type: 'boolean')] + #[SerializedName('public')] #[Groups(['SubscriberList'])] private bool $public; #[ORM\Column] - #[SerializedName("category")] + #[SerializedName('category')] #[Groups(['SubscriberList'])] private string $category; - #[ORM\ManyToOne(targetEntity: "PhpList\Core\Domain\Model\Identity\Administrator")] - #[ORM\JoinColumn(name: "owner")] + #[ORM\ManyToOne(targetEntity: 'PhpList\Core\Domain\Model\Identity\Administrator')] + #[ORM\JoinColumn(name: 'owner')] #[Ignore] private ?Administrator $owner = null; #[ORM\OneToMany( - targetEntity: "PhpList\Core\Domain\Model\Subscription\Subscription", - mappedBy: "subscriberList", - cascade: ["remove"], + targetEntity: 'PhpList\Core\Domain\Model\Subscription\Subscription', + mappedBy: 'subscriberList', + cascade: ['remove'], orphanRemoval: true, )] #[MaxDepth(1)] diff --git a/src/Domain/Model/Subscription/Subscriber.php b/src/Domain/Model/Subscription/Subscriber.php index fd84076..9473a02 100644 --- a/src/Domain/Model/Subscription/Subscriber.php +++ b/src/Domain/Model/Subscription/Subscriber.php @@ -24,12 +24,12 @@ * campaigns for those subscriber lists. * @author Oliver Klee */ -#[ORM\Entity(repositoryClass: "PhpList\Core\Domain\Repository\Subscription\SubscriberRepository")] -#[ORM\Table(name: "phplist_user_user")] -#[ORM\Index(name: "idxuniqid", columns: ["uniqid"])] -#[ORM\Index(name: "enteredindex", columns: ["entered"])] -#[ORM\Index(name: "confidx", columns: ["confirmed"])] -#[ORM\Index(name: "blidx", columns: ["blacklisted"])] +#[ORM\Entity(repositoryClass: 'PhpList\Core\Domain\Repository\Subscription\SubscriberRepository')] +#[ORM\Table(name: 'phplist_user_user')] +#[ORM\Index(name: 'idxuniqid', columns: ['uniqid'])] +#[ORM\Index(name: 'enteredindex', columns: ['entered'])] +#[ORM\Index(name: 'confidx', columns: ['confirmed'])] +#[ORM\Index(name: 'blidx', columns: ['blacklisted'])] #[ORM\HasLifecycleCallbacks] class Subscriber implements DomainModel, Identity, CreationDate, ModificationDate { @@ -37,58 +37,58 @@ class Subscriber implements DomainModel, Identity, CreationDate, ModificationDat use CreationDateTrait; use ModificationDateTrait; - #[ORM\Column(name: "entered", type: "datetime", nullable: true)] - #[SerializedName("creation_date")] + #[ORM\Column(name: 'entered', type: 'datetime', nullable: true)] + #[SerializedName('creation_date')] #[Groups(['SubscriberListMembers'])] protected ?DateTime $creationDate = null; - #[ORM\Column(name: "modified", type: "datetime")] + #[ORM\Column(name: 'modified', type: 'datetime')] #[Ignore] protected ?DateTime $modificationDate = null; #[ORM\Column(unique: true)] - #[SerializedName("email")] + #[SerializedName('email')] #[Groups(['SubscriberListMembers'])] private string $email = ''; - #[ORM\Column(type: "boolean")] - #[SerializedName("confirmed")] + #[ORM\Column(type: 'boolean')] + #[SerializedName('confirmed')] #[Groups(['SubscriberListMembers'])] private bool $confirmed = false; - #[ORM\Column(type: "boolean")] - #[SerializedName("blacklisted")] + #[ORM\Column(type: 'boolean')] + #[SerializedName('blacklisted')] #[Groups(['SubscriberListMembers'])] private bool $blacklisted = false; - #[ORM\Column(name: "bouncecount", type: "integer")] - #[SerializedName("bounce_count")] + #[ORM\Column(name: 'bouncecount', type: 'integer')] + #[SerializedName('bounce_count')] #[Groups(['SubscriberListMembers'])] private int $bounceCount = 0; - #[ORM\Column(name: "uniqid", unique: true)] - #[SerializedName("unique_id")] + #[ORM\Column(name: 'uniqid', unique: true)] + #[SerializedName('unique_id')] #[Groups(['SubscriberListMembers'])] private string $uniqueId = ''; - #[ORM\Column(name: "htmlemail", type: "boolean")] - #[SerializedName("html_email")] + #[ORM\Column(name: 'htmlemail', type: 'boolean')] + #[SerializedName('html_email')] #[Groups(['SubscriberListMembers'])] private bool $htmlEmail = false; - #[ORM\Column(type: "boolean")] - #[SerializedName("disabled")] + #[ORM\Column(type: 'boolean')] + #[SerializedName('disabled')] #[Groups(['SubscriberListMembers'])] private bool $disabled = false; - #[ORM\Column(name: "extradata", type: "text")] - #[SerializedName("extra_data")] + #[ORM\Column(name: 'extradata', type: 'text')] + #[SerializedName('extra_data')] private ?string $extraData; #[ORM\OneToMany( - targetEntity: "PhpList\Core\Domain\Model\Subscription\Subscription", - mappedBy: "subscriber", - cascade: ["remove"], + targetEntity: 'PhpList\Core\Domain\Model\Subscription\Subscription', + mappedBy: 'subscriber', + cascade: ['remove'], orphanRemoval: true, )] private Collection $subscriptions; diff --git a/src/Domain/Model/Subscription/Subscription.php b/src/Domain/Model/Subscription/Subscription.php index 99e711b..a7fb89c 100644 --- a/src/Domain/Model/Subscription/Subscription.php +++ b/src/Domain/Model/Subscription/Subscription.php @@ -21,41 +21,41 @@ * campaigns for those subscriber lists. * @author Oliver Klee */ -#[ORM\Entity(repositoryClass: "PhpList\Core\Domain\Repository\Subscription\SubscriptionRepository")] -#[ORM\Table(name: "phplist_listuser")] -#[ORM\Index(name: "userenteredidx", columns: ["userid", "entered"])] -#[ORM\Index(name: "userlistenteredidx", columns: ["userid", "entered", "listid"])] -#[ORM\Index(name: "useridx", columns: ["userid"])] -#[ORM\Index(name: "listidx", columns: ["listid"])] +#[ORM\Entity(repositoryClass: 'PhpList\Core\Domain\Repository\Subscription\SubscriptionRepository')] +#[ORM\Table(name: 'phplist_listuser')] +#[ORM\Index(name: 'userenteredidx', columns: ['userid', 'entered'])] +#[ORM\Index(name: 'userlistenteredidx', columns: ['userid', 'entered', 'listid'])] +#[ORM\Index(name: 'useridx', columns: ['userid'])] +#[ORM\Index(name: 'listidx', columns: ['listid'])] #[ORM\HasLifecycleCallbacks] class Subscription implements DomainModel, CreationDate, ModificationDate { use CreationDateTrait; use ModificationDateTrait; - #[ORM\Column(name: "entered", type: "datetime", nullable: true)] - #[SerializedName("creation_date")] + #[ORM\Column(name: 'entered', type: 'datetime', nullable: true)] + #[SerializedName('creation_date')] protected ?DateTime $creationDate = null; - #[ORM\Column(name: "modified", type: "datetime")] + #[ORM\Column(name: 'modified', type: 'datetime')] #[Ignore] protected ?DateTime $modificationDate = null; #[ORM\Id] #[ORM\ManyToOne( - targetEntity: "PhpList\Core\Domain\Model\Subscription\Subscriber", - inversedBy: "subscriptions" + targetEntity: 'PhpList\Core\Domain\Model\Subscription\Subscriber', + inversedBy: 'subscriptions' )] - #[ORM\JoinColumn(name: "userid")] - #[SerializedName("subscriber")] + #[ORM\JoinColumn(name: 'userid')] + #[SerializedName('subscriber')] private ?Subscriber $subscriber = null; #[ORM\Id] #[ORM\ManyToOne( - targetEntity: "PhpList\Core\Domain\Model\Messaging\SubscriberList", - inversedBy: "subscriptions" + targetEntity: 'PhpList\Core\Domain\Model\Messaging\SubscriberList', + inversedBy: 'subscriptions' )] - #[ORM\JoinColumn(name: "listid", onDelete: "CASCADE")] + #[ORM\JoinColumn(name: 'listid', onDelete: 'CASCADE')] #[Ignore] private ?SubscriberList $subscriberList = null; diff --git a/src/Domain/Model/Traits/IdentityTrait.php b/src/Domain/Model/Traits/IdentityTrait.php index 98b3862..4445ea2 100644 --- a/src/Domain/Model/Traits/IdentityTrait.php +++ b/src/Domain/Model/Traits/IdentityTrait.php @@ -18,9 +18,9 @@ trait IdentityTrait { #[ORM\Id] - #[ORM\Column(type: "integer")] + #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue] - #[SerializedName("id")] + #[SerializedName('id')] #[Groups(['SubscriberList', 'SubscriberListMembers'])] private int $id; diff --git a/src/Domain/Repository/Messaging/SubscriberListRepository.php b/src/Domain/Repository/Messaging/SubscriberListRepository.php index 92ce1bc..04d45b5 100644 --- a/src/Domain/Repository/Messaging/SubscriberListRepository.php +++ b/src/Domain/Repository/Messaging/SubscriberListRepository.php @@ -25,7 +25,6 @@ public function findWithSubscription($id) ->where('sl.id = :id') ->setParameter('id', $id) ->getQuery() - ->getOneOrNullResult() - ; + ->getOneOrNullResult(); } } diff --git a/src/TestingSupport/Traits/DatabaseTestTrait.php b/src/TestingSupport/Traits/DatabaseTestTrait.php index 6385a93..8ed4258 100644 --- a/src/TestingSupport/Traits/DatabaseTestTrait.php +++ b/src/TestingSupport/Traits/DatabaseTestTrait.php @@ -42,6 +42,8 @@ protected function tearDownDatabaseTest(): void /** * Initializes the Bootstrap and Doctrine EntityManager. + * + * @throws RuntimeException */ private function initializeBootstrap(): void { @@ -60,6 +62,7 @@ private function initializeBootstrap(): void * Loads data fixtures into the database. * * @param array $fixtures List of fixture classes to load + * @throws InvalidArgumentException */ protected function loadFixtures(array $fixtures): void { @@ -89,7 +92,10 @@ protected function loadSchema(): void if (!$schemaManager->tablesExist([$tableName])) { try { $schemaTool->createSchema([$classMetadata]); - } catch (ToolsException $e){} + } catch (ToolsException $e) { + // nothing to do + echo $e->getMessage(); + } } } } diff --git a/src/TestingSupport/Traits/ModelTestTrait.php b/src/TestingSupport/Traits/ModelTestTrait.php index 490c5f7..5dcfc5d 100644 --- a/src/TestingSupport/Traits/ModelTestTrait.php +++ b/src/TestingSupport/Traits/ModelTestTrait.php @@ -22,9 +22,9 @@ trait ModelTestTrait * * @return void */ - private function setSubjectId(DomainModel $model,int $id): void + private function setSubjectId(DomainModel $model, int $id): void { - $this->setSubjectProperty($model,'id', $id); + $this->setSubjectProperty($model, 'id', $id); } /** diff --git a/tests/Integration/Domain/Repository/Fixtures/AdministratorFixture.php b/tests/Integration/Domain/Repository/Fixtures/AdministratorFixture.php index f9631f8..30905f2 100644 --- a/tests/Integration/Domain/Repository/Fixtures/AdministratorFixture.php +++ b/tests/Integration/Domain/Repository/Fixtures/AdministratorFixture.php @@ -29,7 +29,11 @@ public function load(ObjectManager $manager): void $headers = fgetcsv($handle); - while (($data = fgetcsv($handle)) !== false) { + do { + $data = fgetcsv($handle); + if ($data === false) { + break; + } $row = array_combine($headers, $data); $admin = new Administrator(); @@ -41,9 +45,9 @@ public function load(ObjectManager $manager): void $admin->setSuperUser((bool) $row['superuser']); $manager->persist($admin); - $this->setSubjectProperty($admin,'creationDate', new DateTime($row['created'])); - $this->setSubjectProperty($admin,'passwordChangeDate', new DateTime($row['passwordchanged'])); - } + $this->setSubjectProperty($admin, 'creationDate', new DateTime($row['created'])); + $this->setSubjectProperty($admin, 'passwordChangeDate', new DateTime($row['passwordchanged'])); + } while (true); fclose($handle); } diff --git a/tests/Integration/Domain/Repository/Fixtures/AdministratorTokenWithAdministratorFixture.php b/tests/Integration/Domain/Repository/Fixtures/AdministratorTokenWithAdministratorFixture.php index 7058499..1d1ac74 100644 --- a/tests/Integration/Domain/Repository/Fixtures/AdministratorTokenWithAdministratorFixture.php +++ b/tests/Integration/Domain/Repository/Fixtures/AdministratorTokenWithAdministratorFixture.php @@ -12,7 +12,6 @@ use PhpList\Core\TestingSupport\Traits\ModelTestTrait; use RuntimeException; - class AdministratorTokenWithAdministratorFixture extends Fixture { use ModelTestTrait; @@ -32,24 +31,28 @@ public function load(ObjectManager $manager): void $headers = fgetcsv($handle); $adminRepository = $manager->getRepository(Administrator::class); - while (($data = fgetcsv($handle)) !== false) { + do { + $data = fgetcsv($handle); + if ($data === false) { + break; + } $row = array_combine($headers, $data); $admin = $adminRepository->find($row['adminid']); if ($admin === null) { $admin = new Administrator(); - $this->setSubjectId($admin,(int)$row['adminid']); + $this->setSubjectId($admin, (int)$row['adminid']); $manager->persist($admin); } $adminToken = new AdministratorToken(); - $this->setSubjectId($adminToken,(int)$row['id']); + $this->setSubjectId($adminToken, (int)$row['id']); $adminToken->setKey($row['value']); - $this->setSubjectProperty($adminToken,'expiry', new DateTime($row['expires'])); + $this->setSubjectProperty($adminToken, 'expiry', new DateTime($row['expires'])); $this->setSubjectProperty($adminToken, 'creationDate', (bool) $row['entered']); $adminToken->setAdministrator($admin); $manager->persist($adminToken); - } + } while (true); fclose($handle); } diff --git a/tests/Integration/Domain/Repository/Fixtures/DetachedAdministratorTokenFixture.php b/tests/Integration/Domain/Repository/Fixtures/DetachedAdministratorTokenFixture.php index c9e6e45..cf465df 100644 --- a/tests/Integration/Domain/Repository/Fixtures/DetachedAdministratorTokenFixture.php +++ b/tests/Integration/Domain/Repository/Fixtures/DetachedAdministratorTokenFixture.php @@ -29,16 +29,20 @@ public function load(ObjectManager $manager): void $headers = fgetcsv($handle); - while (($data = fgetcsv($handle)) !== false) { + do { + $data = fgetcsv($handle); + if ($data === false) { + break; + } $row = array_combine($headers, $data); $adminToken = new AdministratorToken(); - $this->setSubjectId($adminToken,(int)$row['id']); + $this->setSubjectId($adminToken, (int)$row['id']); $adminToken->setKey($row['value']); - $this->setSubjectProperty($adminToken,'expiry', new DateTime($row['expires'])); + $this->setSubjectProperty($adminToken, 'expiry', new DateTime($row['expires'])); $this->setSubjectProperty($adminToken, 'creationDate', (bool) $row['entered']); $manager->persist($adminToken); - } + } while (true); fclose($handle); } diff --git a/tests/Integration/Domain/Repository/Fixtures/SubscriberFixture.php b/tests/Integration/Domain/Repository/Fixtures/SubscriberFixture.php index 42623f6..9a4ce78 100644 --- a/tests/Integration/Domain/Repository/Fixtures/SubscriberFixture.php +++ b/tests/Integration/Domain/Repository/Fixtures/SubscriberFixture.php @@ -30,11 +30,15 @@ public function load(ObjectManager $manager): void $headers = fgetcsv($handle); - while (($data = fgetcsv($handle)) !== false) { + do { + $data = fgetcsv($handle); + if ($data === false) { + break; + } $row = array_combine($headers, $data); $subscriber = new Subscriber(); - $this->setSubjectId($subscriber,(int)$row['id']); + $this->setSubjectId($subscriber, (int)$row['id']); $subscriber->setEmail($row['email']); $subscriber->setConfirmed((bool) $row['confirmed']); @@ -47,9 +51,9 @@ public function load(ObjectManager $manager): void $manager->persist($subscriber); // avoid pre-persist $subscriber->setUniqueId($row['uniqueid']); - $this->setSubjectProperty($subscriber,'creationDate', new DateTime($row['entered'])); - $this->setSubjectProperty($subscriber,'modificationDate', new DateTime($row['modified'])); - } + $this->setSubjectProperty($subscriber, 'creationDate', new DateTime($row['entered'])); + $this->setSubjectProperty($subscriber, 'modificationDate', new DateTime($row['modified'])); + } while (true); fclose($handle); } diff --git a/tests/Integration/Domain/Repository/Fixtures/SubscriberListFixture.php b/tests/Integration/Domain/Repository/Fixtures/SubscriberListFixture.php index a41734f..0b8aff8 100644 --- a/tests/Integration/Domain/Repository/Fixtures/SubscriberListFixture.php +++ b/tests/Integration/Domain/Repository/Fixtures/SubscriberListFixture.php @@ -32,21 +32,26 @@ public function load(ObjectManager $manager): void $adminRepository = $manager->getRepository(Administrator::class); - while (($data = fgetcsv($handle)) !== false) { + do { + $data = fgetcsv($handle); + if ($data === false) { + break; + } $row = array_combine($headers, $data); + $admin = $adminRepository->find($row['owner']); if ($admin === null) { $admin = new Administrator(); - $this->setSubjectId($admin,(int)$row['owner']); + $this->setSubjectId($admin, (int)$row['owner']); $manager->persist($admin); } $subscriberList = new SubscriberList(); - $this->setSubjectId($subscriberList,(int)$row['id']); + $this->setSubjectId($subscriberList, (int)$row['id']); $subscriberList->setName($row['name']); $subscriberList->setDescription($row['description']); - $this->setSubjectProperty($subscriberList,'creationDate', new DateTime($row['entered'])); - $this->setSubjectProperty($subscriberList,'modificationDate', new DateTime($row['modified'])); + $this->setSubjectProperty($subscriberList, 'creationDate', new DateTime($row['entered'])); + $this->setSubjectProperty($subscriberList, 'modificationDate', new DateTime($row['modified'])); $subscriberList->setListPosition((int)$row['listorder']); $subscriberList->setSubjectPrefix($row['prefix']); $subscriberList->setPublic((bool) $row['active']); @@ -54,7 +59,7 @@ public function load(ObjectManager $manager): void $subscriberList->setOwner($admin); $manager->persist($subscriberList); - } + } while (true); fclose($handle); } diff --git a/tests/Integration/Domain/Repository/Fixtures/SubscriptionFixture.php b/tests/Integration/Domain/Repository/Fixtures/SubscriptionFixture.php index 12779d4..35cd792 100644 --- a/tests/Integration/Domain/Repository/Fixtures/SubscriptionFixture.php +++ b/tests/Integration/Domain/Repository/Fixtures/SubscriptionFixture.php @@ -35,7 +35,11 @@ public function load(ObjectManager $manager): void $headers = fgetcsv($handle); - while (($data = fgetcsv($handle)) !== false) { + do { + $data = fgetcsv($handle); + if ($data === false) { + break; + } $row = array_combine($headers, $data); $subscriber = $subscriberRepository->find((int)$row['userid']); @@ -47,9 +51,9 @@ public function load(ObjectManager $manager): void $manager->persist($subscription); - $this->setSubjectProperty($subscription,'creationDate', new DateTime($row['entered'])); - $this->setSubjectProperty($subscription,'modificationDate', new DateTime($row['modified'])); - } + $this->setSubjectProperty($subscription, 'creationDate', new DateTime($row['entered'])); + $this->setSubjectProperty($subscription, 'modificationDate', new DateTime($row['modified'])); + } while (true); fclose($handle); } diff --git a/tests/Integration/Domain/Repository/Identity/AdministratorRepositoryTest.php b/tests/Integration/Domain/Repository/Identity/AdministratorRepositoryTest.php index ae5001e..2f74bcf 100644 --- a/tests/Integration/Domain/Repository/Identity/AdministratorRepositoryTest.php +++ b/tests/Integration/Domain/Repository/Identity/AdministratorRepositoryTest.php @@ -55,7 +55,10 @@ public function testFindReadsModelFromDatabase(): void 1 ); $this->assertSame('john@example.com', $actual->getEmailAddress()); - $this->assertSame('1491a3c7e7b23b9a6393323babbb095dee0d7d81b2199617b487bd0fb5236f3c', $actual->getPasswordHash()); + $this->assertSame( + '1491a3c7e7b23b9a6393323babbb095dee0d7d81b2199617b487bd0fb5236f3c', + $actual->getPasswordHash() + ); $this->assertEquals(new DateTime('2017-06-22 15:01:17'), $actual->getCreationDate()); $this->assertEquals(new DateTime('2017-06-28'), $actual->getPasswordChangeDate()); } @@ -113,8 +116,10 @@ public function testModificationDateOfNewModelIsSetToNowOnPersist() * * @dataProvider incorrectLoginCredentialsDataProvider */ - public function testFindOneByLoginCredentialsForNonMatchingCredentialsReturnsNull(string $loginName, string $password): void - { + public function testFindOneByLoginCredentialsForNonMatchingCredentialsReturnsNull( + string $loginName, + string $password + ): void { $result = $this->repository->findOneByLoginCredentials($loginName, $password); $this->assertNull($result); diff --git a/tests/Integration/Domain/Repository/Identity/AdministratorTokenRepositoryTest.php b/tests/Integration/Domain/Repository/Identity/AdministratorTokenRepositoryTest.php index 1531c1e..af8c2e0 100644 --- a/tests/Integration/Domain/Repository/Identity/AdministratorTokenRepositoryTest.php +++ b/tests/Integration/Domain/Repository/Identity/AdministratorTokenRepositoryTest.php @@ -47,7 +47,8 @@ public function testFindReadsModelFromDatabase() $this->loadFixtures([DetachedAdministratorTokenFixture::class]); $id = 1; - $creationDate = new DateTime(); // prePersist + // prePersist + $creationDate = new DateTime(); $expiry = new DateTime('2017-06-22 16:43:29'); $key = 'cfdf64eecbbf336628b0f3071adba762'; diff --git a/tests/Unit/Composer/ScriptHandlerTest.php b/tests/Unit/Composer/ScriptHandlerTest.php index 26d9b5a..c85ecb3 100644 --- a/tests/Unit/Composer/ScriptHandlerTest.php +++ b/tests/Unit/Composer/ScriptHandlerTest.php @@ -58,7 +58,13 @@ public function testListModulesForPhpListModuleRootPackageListsIt(): void ScriptHandler::listModules($event); - $this->expectOutputRegex('/' . preg_quote($rootPackageName, '/') . '\s+' . preg_quote($rootPackageVersion, '/') . '/'); + $this->expectOutputRegex( + '/' + . preg_quote($rootPackageName, '/') + . '\s+' + . preg_quote($rootPackageVersion, '/') + . '/' + ); } public function testListModulesForNonPhpListModuleRootPackageExcludesIt(): void @@ -98,7 +104,13 @@ public function testListModulesForPhpListModuleDependencyListsIt(): void ScriptHandler::listModules($event); - $this->expectOutputRegex('/' . preg_quote($dependencyPackageName, '/') . '\s+' . preg_quote($dependencyPackageVersion, '/') . '/'); + $this->expectOutputRegex( + '/' + . preg_quote($dependencyPackageName, '/') + . '\s+' + . preg_quote($dependencyPackageVersion, '/') + . '/' + ); } public function testListModulesForNonPhpListModuleDependencyExcludesIt(): void diff --git a/tests/Unit/Domain/Model/Identity/AdministratorTest.php b/tests/Unit/Domain/Model/Identity/AdministratorTest.php index a9ed8d6..4bdca7d 100644 --- a/tests/Unit/Domain/Model/Identity/AdministratorTest.php +++ b/tests/Unit/Domain/Model/Identity/AdministratorTest.php @@ -35,7 +35,7 @@ public function testIsDomainModel(): void public function testGetIdReturnsId(): void { $id = 123456; - $this->setSubjectId($this->subject,$id); + $this->setSubjectId($this->subject, $id); self::assertSame($id, $this->subject->getId()); }