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

Remove some of the deprecations #274

Merged
merged 1 commit into from
Aug 15, 2023
Merged
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
7 changes: 4 additions & 3 deletions src/EventSubscriber/Doctrine/EntityBlamableSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use App\Entity\AbstractBlamableEntity;
use App\Entity\User\User;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PrePersistEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Events;
use Symfony\Component\Security\Core\Security;

Expand All @@ -26,7 +27,7 @@ public function getSubscribedEvents(): array
];
}

public function prePersist(LifecycleEventArgs $args): void
public function prePersist(PrePersistEventArgs $args): void
{
$currentUser = $this->security->getUser();
$entity = $args->getObject();
Expand All @@ -36,7 +37,7 @@ public function prePersist(LifecycleEventArgs $args): void
}
}

public function preUpdate(LifecycleEventArgs $args): void
public function preUpdate(PreUpdateEventArgs $args): void
{
$currentUser = $this->security->getUser();
$entity = $args->getObject();
Expand Down
8 changes: 4 additions & 4 deletions src/EventSubscriber/Doctrine/ModGroupUpdatedSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use App\Entity\User\User;
use App\Repository\ModList\ModListRepository;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PostFlushEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Events;
use Symfony\Component\Security\Core\Security;

Expand All @@ -31,9 +31,9 @@ public function getSubscribedEvents(): array
];
}

public function preUpdate(LifecycleEventArgs $args): void
public function preUpdate(PreUpdateEventArgs $args): void
{
$entityManager = $args->getEntityManager();
$entityManager = $args->getObjectManager();
$modGroup = $args->getObject();

// Do nothing if updated entity is not a Mod Group or no changes were made to the entity
Expand All @@ -52,7 +52,7 @@ public function postFlush(PostFlushEventArgs $args): void
return;
}

$entityManager = $args->getEntityManager();
$entityManager = $args->getObjectManager();

/** @var ModListRepository $modListRepository */
$modListRepository = $entityManager->getRepository(ModList::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Traits/UserInterfaceTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait UserInterfaceTrait
{
public function getUserIdentifier(): string
{
return $this->getUsername();
return $this->username;
}

public function getPassword(): ?string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use App\Entity\AbstractBlamableEntity;
use App\Entity\User\User;
use App\EventSubscriber\Doctrine\EntityBlamableSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\PrePersistEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Events;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Security;
Expand Down Expand Up @@ -41,19 +43,18 @@ public function getSubscribedEvents(): void
public function prePersist_validEventArgs_entityUpdated(): void
{
$user = $this->createMock(User::class);
$security = $this->createMock(Security::class);
$security->method('getUser')->willReturn($user);

$entityManager = $this->createMock(EntityManagerInterface::class);
$entity = $this->createMock(AbstractBlamableEntity::class);
$entity
->expects(static::once())
->method('created')
->with(static::isInstanceOf(User::class))
;

$security = $this->createMock(Security::class);
$security->method('getUser')->willReturn($user);

$lifecycleEventArgs = $this->createMock(LifecycleEventArgs::class);
$lifecycleEventArgs->method('getObject')->willReturn($entity);
$lifecycleEventArgs = new PrePersistEventArgs($entity, $entityManager);

$entityBlamableSubscriberTest = new EntityBlamableSubscriber($security);
$entityBlamableSubscriberTest->prePersist($lifecycleEventArgs);
Expand All @@ -68,8 +69,8 @@ public function prePersist_invalidEventArgs_entityNotUpdated(mixed $user, mixed
$security = $this->createMock(Security::class);
$security->method('getUser')->willReturn($user);

$lifecycleEventArgs = $this->createMock(LifecycleEventArgs::class);
$lifecycleEventArgs->method('getObject')->willReturn($entity);
$entityManager = $this->createMock(EntityManagerInterface::class);
$lifecycleEventArgs = new PrePersistEventArgs($entity, $entityManager);

$entityBlamableSubscriberTest = new EntityBlamableSubscriber($security);
$entityBlamableSubscriberTest->prePersist($lifecycleEventArgs);
Expand All @@ -81,19 +82,19 @@ public function prePersist_invalidEventArgs_entityNotUpdated(mixed $user, mixed
public function preUpdate_validEventArgs_entityUpdated(): void
{
$user = $this->createMock(User::class);
$security = $this->createMock(Security::class);
$security->method('getUser')->willReturn($user);

$entityManager = $this->createMock(EntityManagerInterface::class);
$entity = $this->createMock(AbstractBlamableEntity::class);
$entity
->expects(static::once())
->method('updated')
->with(static::isInstanceOf(User::class))
;

$security = $this->createMock(Security::class);
$security->method('getUser')->willReturn($user);

$lifecycleEventArgs = $this->createMock(LifecycleEventArgs::class);
$lifecycleEventArgs->method('getObject')->willReturn($entity);
$changeSet = [];
$lifecycleEventArgs = new PreUpdateEventArgs($entity, $entityManager, $changeSet);

$entityBlamableSubscriberTest = new EntityBlamableSubscriber($security);
$entityBlamableSubscriberTest->preUpdate($lifecycleEventArgs);
Expand All @@ -108,8 +109,10 @@ public function preUpdate_invalidEventArgs_entityNotUpdated(mixed $user, mixed $
$security = $this->createMock(Security::class);
$security->method('getUser')->willReturn($user);

$lifecycleEventArgs = $this->createMock(LifecycleEventArgs::class);
$lifecycleEventArgs->method('getObject')->willReturn($entity);
$entityManager = $this->createMock(EntityManagerInterface::class);

$changeSet = [];
$lifecycleEventArgs = new PreUpdateEventArgs($entity, $entityManager, $changeSet);

$entityBlamableSubscriberTest = new EntityBlamableSubscriber($security);
$entityBlamableSubscriberTest->preUpdate($lifecycleEventArgs);
Expand Down
Loading