Some profile tests
This commit is contained in:
parent
98c3afe628
commit
091351b50b
|
@ -54,9 +54,9 @@ docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
|||
|
||||
```console
|
||||
# Create new user (without email verification)
|
||||
$ docker-compose exec php bin/console kbin:user username email@exmple.com password
|
||||
$ docker-compose exec php bin/console kbin:user:create username email@exmple.com password
|
||||
# Grant administrator privileges
|
||||
$ docker-compose exec php bin/console kbin:admin username
|
||||
$ docker-compose exec php bin/console kbin:user:admin username
|
||||
```
|
||||
|
||||
Next, setup your instance https://localhost/admin
|
||||
|
|
7342
clover.xml
Normal file
7342
clover.xml
Normal file
File diff suppressed because it is too large
Load diff
|
@ -8,11 +8,11 @@
|
|||
bootstrap="tests/bootstrap.php"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
<server name="APP_ENV" value="test" force="true" />
|
||||
<server name="SHELL_VERBOSITY" value="-1" />
|
||||
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
|
||||
<server name="SYMFONY_PHPUNIT_VERSION" value="9.4" />
|
||||
<ini name="error_reporting" value="-1"/>
|
||||
<server name="APP_ENV" value="test" force="true"/>
|
||||
<server name="SHELL_VERBOSITY" value="-1"/>
|
||||
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
|
||||
<server name="SYMFONY_PHPUNIT_VERSION" value="9.4"/>
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
|
@ -21,11 +21,14 @@
|
|||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</include>
|
||||
<exclude>
|
||||
<directory suffix=".php">src/DataFixtures</directory>
|
||||
</exclude>
|
||||
</coverage>
|
||||
|
||||
<extensions>
|
||||
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"/>
|
||||
|
|
|
@ -13,7 +13,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
|
||||
class AdminCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'kbin:admin';
|
||||
protected static $defaultName = 'kbin:user:admin';
|
||||
protected static string $defaultDescription = 'This command allows you to grant administrator privileges to the user.';
|
||||
|
||||
public function __construct(private EntityManagerInterface $entityManager, private UserRepository $repository)
|
||||
|
|
|
@ -15,7 +15,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
|
||||
class UserCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'kbin:user';
|
||||
protected static $defaultName = 'kbin:user:create';
|
||||
protected static string $defaultDescription = 'This command allows you to create or remove user account.';
|
||||
|
||||
public function __construct(
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Exception;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mime\Email;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class TestController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/test", name="test")
|
||||
*/
|
||||
public function index(MailerInterface $mailer): Response
|
||||
{
|
||||
$email = (new Email())
|
||||
->from('hello@example.com')
|
||||
->to('lorem@example.com')
|
||||
->subject('Time for Symfony Mailer!')
|
||||
->text('Sending emails is fun again!')
|
||||
->html('<p>See Twig integration for better HTML integration!</p>');
|
||||
|
||||
try {
|
||||
$mailer->send($email);
|
||||
} catch (Exception $e) {
|
||||
dd($e->getMessage());
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'test/index.html.twig',
|
||||
[
|
||||
'controller_name' => 'TestController',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\BadgeRepository;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=BadgeRepository::class)
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class Badge
|
||||
{
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\EntryBadgeRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=EntryBadgeRepository::class)
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class EntryBadge
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* columns={"user_id", "comment_id"}
|
||||
* )
|
||||
* })
|
||||
* @ORM\Entity(repositoryClass="App\Repository\EntryCommentVoteRepository")
|
||||
* @ORM\Entity()
|
||||
* @ORM\AssociationOverrides({
|
||||
* @ORM\AssociationOverride(name="user", inversedBy="entryCommentVotes")
|
||||
* })
|
||||
|
|
|
@ -11,7 +11,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* columns={"user_id", "entry_id"}
|
||||
* )
|
||||
* })
|
||||
* @ORM\Entity(repositoryClass="App\Repository\EntryVoteRepository")
|
||||
* @ORM\Entity()
|
||||
* @ORM\AssociationOverrides({
|
||||
* @ORM\AssociationOverride(name="user", inversedBy="entryVotes")
|
||||
* })
|
||||
|
|
|
@ -7,7 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
/**
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class BanNotification extends Notification
|
||||
class MagazineBanNotification extends Notification
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="MagazineBan")
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Traits\CreatedAtTrait;
|
||||
use App\Repository\UserBlockRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* columns={"user_id", "magazine_id"}
|
||||
* )
|
||||
* })
|
||||
* @ORM\Entity(repositoryClass=UserBlockRepository::class)
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class MagazineBlock
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use App\Entity\Contracts\ContentInterface;
|
|||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\MagazineLogEntryCommentDeleteRepository")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class MagazineLogEntryCommentDeleted extends MagazineLog
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use App\Entity\Contracts\ContentInterface;
|
|||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\MagazineLogEntryDeleteRepository")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class MagazineLogEntryDeleted extends MagazineLog
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use App\Entity\Contracts\ContentInterface;
|
|||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\MagazineLogPostCommentDeleteRepository")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class MagazineLogPostCommentDeleted extends MagazineLog
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use App\Entity\Contracts\ContentInterface;
|
|||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\MagazineLogPostDeleteRepository")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class MagazineLogPostDeleted extends MagazineLog
|
||||
{
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Traits\CreatedAtTrait;
|
||||
use App\Repository\MessageRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=MessageRepository::class)
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class Message
|
||||
{
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\MessageNotificationRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=MessageNotificationRepository::class)
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class MessageNotification extends Notification
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Traits\CreatedAtTrait;
|
||||
use App\Repository\ModeratorRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* columns={"magazine_id", "user_id"}
|
||||
* )
|
||||
* })
|
||||
* @ORM\Entity(repositoryClass=ModeratorRepository::class)
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class Moderator
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* "post_comment_created": "PostCommentCreatedNotification",
|
||||
* "post_comment_deleted": "PostCommentDeletedNotification",
|
||||
* "message": "MessageNotification",
|
||||
* "ban": "BanNotification",
|
||||
* "ban": "MagazineBanNotification",
|
||||
* })
|
||||
*/
|
||||
abstract class Notification
|
||||
|
|
|
@ -11,7 +11,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* columns={"user_id", "comment_id"}
|
||||
* )
|
||||
* })
|
||||
* @ORM\Entity(repositoryClass="App\Repository\PostCommentVoteRepository")
|
||||
* @ORM\Entity()
|
||||
* @ORM\AssociationOverrides({
|
||||
* @ORM\AssociationOverride(name="user", inversedBy="postCommentVotes")
|
||||
* })
|
||||
|
|
|
@ -11,7 +11,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* columns={"user_id", "post_id"}
|
||||
* )
|
||||
* })
|
||||
* @ORM\Entity(repositoryClass="App\Repository\PostVoteRepository")
|
||||
* @ORM\Entity()
|
||||
* @ORM\AssociationOverrides({
|
||||
* @ORM\AssociationOverride(name="user", inversedBy="postVotes")
|
||||
* })
|
||||
|
|
|
@ -8,7 +8,7 @@ use DateTime;
|
|||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\ReportRepository")
|
||||
* @ORM\Entity()
|
||||
* @ORM\InheritanceType("SINGLE_TABLE")
|
||||
* @ORM\DiscriminatorColumn(name="report_type", type="text")
|
||||
* @ORM\DiscriminatorMap({
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\SiteRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=SiteRepository::class)
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class Site
|
||||
{
|
||||
|
|
|
@ -511,6 +511,6 @@ class User implements UserInterface
|
|||
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return false;
|
||||
return in_array('ROLE_ADMIN', $this->getRoles());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Traits\CreatedAtTrait;
|
||||
use App\Repository\UserBlockRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* columns={"blocker_id", "blocked_id"}
|
||||
* )
|
||||
* })
|
||||
* @ORM\Entity(repositoryClass=UserBlockRepository::class)
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class UserBlock
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Traits\CreatedAtTrait;
|
||||
use App\Repository\UserFollowRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* columns={"follower_id", "following_id"}
|
||||
* )
|
||||
* })
|
||||
* @ORM\Entity(repositoryClass=UserFollowRepository::class)
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class UserFollow
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\EventSubscriber\Magazine;
|
||||
|
||||
use App\Event\Magazine\MagazineBanEvent;
|
||||
use App\Message\BanNotificationMessage;
|
||||
use App\Message\MagazineBanNotificationMessage;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
|
||||
|
@ -22,6 +22,6 @@ class MagazineBanSubscriber implements EventSubscriberInterface
|
|||
|
||||
public function onBan(MagazineBanEvent $event): void
|
||||
{
|
||||
$this->bus->dispatch(new BanNotificationMessage($event->ban->getId()));
|
||||
$this->bus->dispatch(new MagazineBanNotificationMessage($event->ban->getId()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Message;
|
||||
|
||||
class BanNotificationMessage
|
||||
class MagazineBanNotificationMessage
|
||||
{
|
||||
public function __construct(public int $banId)
|
||||
{
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace App\MessageHandler;
|
||||
|
||||
use App\Message\BanNotificationMessage;
|
||||
use App\Message\MagazineBanNotificationMessage;
|
||||
use App\Repository\MagazineBanRepository;
|
||||
use App\Service\NotificationManager;
|
||||
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
|
||||
|
||||
class SentBanNotificationHandler implements MessageHandlerInterface
|
||||
class SentMagazineBanNotificationHandler implements MessageHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private MagazineBanRepository $repository,
|
||||
|
@ -15,13 +15,13 @@ class SentBanNotificationHandler implements MessageHandlerInterface
|
|||
) {
|
||||
}
|
||||
|
||||
public function __invoke(BanNotificationMessage $message)
|
||||
public function __invoke(MagazineBanNotificationMessage $message)
|
||||
{
|
||||
$ban = $this->repository->find($message->banId);
|
||||
if (!$ban) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->manager->sendBanNotification($ban);
|
||||
$this->manager->sendMagazineBanNotification($ban);
|
||||
}
|
||||
}
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace App\MessageHandler;
|
||||
|
||||
use App\Entity\PostDeletedNotification;
|
||||
use App\Message\PostCreatedNotificationMessage;
|
||||
use App\Message\PostDeletedNotificationMessage;
|
||||
use App\Repository\PostRepository;
|
||||
use App\Service\NotificationManager;
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Admin;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use function get_class;
|
||||
|
||||
/**
|
||||
* @method Admin|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Admin|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Admin[] findAll()
|
||||
* @method Admin[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class AdminRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Admin::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to upgrade (rehash) the user's password automatically over time.
|
||||
*/
|
||||
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
|
||||
{
|
||||
if (!$user instanceof Admin) {
|
||||
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
|
||||
}
|
||||
|
||||
$user->setPassword($newEncodedPassword);
|
||||
$this->_em->persist($user);
|
||||
$this->_em->flush();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Admin[] Returns an array of Admin objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
{
|
||||
return $this->createQueryBuilder('a')
|
||||
->andWhere('a.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('a.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Admin
|
||||
{
|
||||
return $this->createQueryBuilder('a')
|
||||
->andWhere('a.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Badge;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Badge|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Badge|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Badge[] findAll()
|
||||
* @method Badge[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class BadgeRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Badge::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\BanNotification;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method BanNotification|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method BanNotification|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method BanNotification[] findAll()
|
||||
* @method BanNotification[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class BanNotificationRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, BanNotification::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\EntryCommentVote;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method EntryCommentVote|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method EntryCommentVote|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method EntryCommentVote[] findAll()
|
||||
* @method EntryCommentVote[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class CommentVoteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, EntryCommentVote::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\EntryBadge;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method EntryBadge|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method EntryBadge|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method EntryBadge[] findAll()
|
||||
* @method EntryBadge[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class EntryBadgeRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, EntryBadge::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\EntryCommentCreatedNotification;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method EntryCommentCreatedNotification|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method EntryCommentCreatedNotification|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method EntryCommentCreatedNotification[] findAll()
|
||||
* @method EntryCommentCreatedNotification[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class EntryCommentNotificationRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, EntryCommentCreatedNotification::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\EntryCommentVote;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method EntryCommentVote|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method EntryCommentVote|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method EntryCommentVote[] findAll()
|
||||
* @method EntryCommentVote[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class EntryCommentVoteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, EntryCommentVote::class);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Entry;
|
||||
use App\Entity\EntryCreatedNotification;
|
||||
use App\Entity\Notification;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method EntryCreatedNotification|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method EntryCreatedNotification|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method EntryCreatedNotification[] findAll()
|
||||
* @method EntryCreatedNotification[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class EntryNotificationRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, EntryCreatedNotification::class);
|
||||
}
|
||||
|
||||
public function findNewEntryUnreadNotification(User $user, Entry $entry): ?EntryCreatedNotification
|
||||
{
|
||||
return $this->createQueryBuilder('n')
|
||||
->andWhere('n.user = :user')
|
||||
->andWhere('n.entry = :entry')
|
||||
->andWhere('n.status = :status')
|
||||
->setParameters(
|
||||
[
|
||||
'user' => $user,
|
||||
'entry' => $entry,
|
||||
'status' => Notification::STATUS_NEW,
|
||||
]
|
||||
)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\EntryVote;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method EntryVote|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method EntryVote|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method EntryVote[] findAll()
|
||||
* @method EntryVote[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class EntryVoteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, EntryVote::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\UserFollow;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method UserFollow|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method UserFollow|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method UserFollow[] findAll()
|
||||
* @method UserFollow[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class MagazineBlockRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, UserFollow::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\MagazineLog;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method MagazineLog|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method MagazineLog|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method MagazineLog[] findAll()
|
||||
* @method MagazineLog[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class MagazineLogBanRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, MagazineLog::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\MagazineLog;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method MagazineLog|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method MagazineLog|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method MagazineLog[] findAll()
|
||||
* @method MagazineLog[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class MagazineLogEntryCommentDeleteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, MagazineLog::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\MagazineLog;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method MagazineLog|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method MagazineLog|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method MagazineLog[] findAll()
|
||||
* @method MagazineLog[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class MagazineLogEntryDeleteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, MagazineLog::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\MagazineLog;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method MagazineLog|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method MagazineLog|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method MagazineLog[] findAll()
|
||||
* @method MagazineLog[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class MagazineLogPostCommentDeleteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, MagazineLog::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\MagazineLog;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method MagazineLog|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method MagazineLog|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method MagazineLog[] findAll()
|
||||
* @method MagazineLog[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class MagazineLogPostDeleteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, MagazineLog::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\MessageNotification;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method MessageNotification|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method MessageNotification|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method MessageNotification[] findAll()
|
||||
* @method MessageNotification[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class MessageNotificationRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, MessageNotification::class);
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Message;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Message|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Message|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Message|null findOneByName(string $name)
|
||||
* @method Message[] findAll()
|
||||
* @method Message[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class MessageRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Message::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Moderator;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Moderator|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Moderator|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Moderator[] findAll()
|
||||
* @method Moderator[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ModeratorRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Moderator::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PostComment;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method PostComment|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method PostComment|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method PostComment[] findAll()
|
||||
* @method PostComment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PostCommentNotificationRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PostComment::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PostCommentVote;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method PostCommentVote|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method PostCommentVote|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method PostCommentVote[] findAll()
|
||||
* @method PostCommentVote[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PostCommentVoteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PostCommentVote::class);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Notification;
|
||||
use App\Entity\Post;
|
||||
use App\Entity\PostCreatedNotification;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method PostCreatedNotification|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method PostCreatedNotification|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method PostCreatedNotification[] findAll()
|
||||
* @method PostCreatedNotification[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PostNotificationRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PostCreatedNotification::class);
|
||||
}
|
||||
|
||||
public function findNewEntryUnreadNotification(User $user, Post $post): ?PostCreatedNotification
|
||||
{
|
||||
return $this->createQueryBuilder('n')
|
||||
->andWhere('n.user = :user')
|
||||
->andWhere('n.post = :post')
|
||||
->andWhere('n.status = :status')
|
||||
->setParameters(
|
||||
[
|
||||
'user' => $user,
|
||||
'post' => $post,
|
||||
'status' => Notification::STATUS_NEW,
|
||||
]
|
||||
)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PostVote;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method PostVote|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method PostVote|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method PostVote[] findAll()
|
||||
* @method PostVote[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PostVoteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PostVote::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Report;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Report|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Report|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Report[] findAll()
|
||||
* @method Report[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ReportRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Report::class);
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Site;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Site|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Site|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Site[] findAll()
|
||||
* @method Site[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class SiteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Site::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Site[] Returns an array of Site objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
{
|
||||
return $this->createQueryBuilder('s')
|
||||
->andWhere('s.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('s.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Site
|
||||
{
|
||||
return $this->createQueryBuilder('s')
|
||||
->andWhere('s.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\UserFollow;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method UserFollow|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method UserFollow|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method UserFollow[] findAll()
|
||||
* @method UserFollow[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class UserBlockRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, UserFollow::class);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\UserFollow;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method UserFollow|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method UserFollow|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method UserFollow[] findAll()
|
||||
* @method UserFollow[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class UserFollowRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, UserFollow::class);
|
||||
}
|
||||
}
|
|
@ -69,6 +69,11 @@ class EntryCommentManager implements ContentManager
|
|||
$this->dispatcher->dispatch(new EntryCommentDeletedEvent($comment, $user));
|
||||
}
|
||||
|
||||
private function isTrashed(User $user, EntryComment $comment): bool
|
||||
{
|
||||
return !$comment->isAuthor($user);
|
||||
}
|
||||
|
||||
public function purge(EntryComment $comment): void
|
||||
{
|
||||
$this->dispatcher->dispatch(new EntryCommentBeforePurgeEvent($comment));
|
||||
|
@ -86,9 +91,4 @@ class EntryCommentManager implements ContentManager
|
|||
{
|
||||
return $this->factory->createDto($comment);
|
||||
}
|
||||
|
||||
private function isTrashed(User $user, EntryComment $comment): bool
|
||||
{
|
||||
return !$comment->isAuthor($user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace App\Service\Notification;
|
||||
|
||||
use App\Entity\BanNotification;
|
||||
use App\Entity\MagazineBan;
|
||||
use App\Entity\MagazineBanNotification;
|
||||
use App\Repository\MagazineBanRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class BanNotificationManager
|
||||
class MagazineBanNotificationManager
|
||||
{
|
||||
use NotificationTrait;
|
||||
|
||||
|
@ -19,7 +19,7 @@ class BanNotificationManager
|
|||
|
||||
public function send(MagazineBan $ban): void
|
||||
{
|
||||
$notification = new BanNotification($ban->user, $ban);
|
||||
$notification = new MagazineBanNotification($ban->user, $ban);
|
||||
|
||||
$this->entityManager->persist($notification);
|
||||
$this->entityManager->flush();
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\BanNotification;
|
||||
use App\Entity\Entry;
|
||||
use App\Entity\EntryComment;
|
||||
use App\Entity\MagazineBan;
|
||||
use App\Entity\MagazineBanNotification;
|
||||
use App\Entity\Message;
|
||||
use App\Entity\MessageNotification;
|
||||
use App\Entity\Notification;
|
||||
|
@ -76,9 +76,9 @@ class NotificationManager
|
|||
$this->messageNotificationManager->send($message, $sender);
|
||||
}
|
||||
|
||||
public function sendBanNotification(MagazineBan $ban)
|
||||
public function sendMagazineBanNotification(MagazineBan $ban)
|
||||
{
|
||||
$notification = new BanNotification($ban->user, $ban);
|
||||
$notification = new MagazineBanNotification($ban->user, $ban);
|
||||
|
||||
$this->entityManager->persist($notification);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -70,6 +70,11 @@ class PostCommentManager implements ContentManager
|
|||
$this->dispatcher->dispatch(new PostCommentDeletedEvent($comment, $user));
|
||||
}
|
||||
|
||||
private function isTrashed(User $user, PostComment $comment): bool
|
||||
{
|
||||
return !$comment->isAuthor($user);
|
||||
}
|
||||
|
||||
public function purge(PostComment $comment): void
|
||||
{
|
||||
$this->dispatcher->dispatch(new PostCommentBeforePurgeEvent($comment));
|
||||
|
@ -87,9 +92,4 @@ class PostCommentManager implements ContentManager
|
|||
{
|
||||
return $this->factory->createDto($comment);
|
||||
}
|
||||
|
||||
private function isTrashed(User $user, PostComment $comment): bool
|
||||
{
|
||||
return !$comment->isAuthor($user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,11 @@ class PostManager implements ContentManager
|
|||
$this->dispatcher->dispatch(new PostDeletedEvent($post, $user));
|
||||
}
|
||||
|
||||
private function isTrashed(User $user, Post $post): bool
|
||||
{
|
||||
return !$post->isAuthor($user);
|
||||
}
|
||||
|
||||
public function purge(Post $post): void
|
||||
{
|
||||
$this->dispatcher->dispatch(new PostBeforePurgeEvent($post));
|
||||
|
@ -85,9 +90,4 @@ class PostManager implements ContentManager
|
|||
{
|
||||
return $this->factory->createDto($post);
|
||||
}
|
||||
|
||||
private function isTrashed(User $user, Post $post): bool
|
||||
{
|
||||
return !$post->isAuthor($user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<form action="{{ path('user_profile_notifications_read') }}" method="POST" class="me-2">
|
||||
<input type="hidden" name="token" value="{{ csrf_token('read_notifications') }}">
|
||||
<button class="btn btn-sm btn-primary" type="submit">
|
||||
<span>Odczytaj wszystkie</span>
|
||||
Odczytaj wszystkie
|
||||
</button>
|
||||
</form>
|
||||
<form action="{{ path('user_profile_notifications_clear') }}" method="POST">
|
||||
|
@ -76,7 +76,7 @@
|
|||
{% endblock post_created_notification %}
|
||||
|
||||
{% block post_deleted_notification %}
|
||||
{% include 'user/profile/notification/_post_deleted_post_notification.html.twig' %}
|
||||
{% include 'user/profile/notification/_post_deleted_notification.html.twig' %}
|
||||
{% endblock post_deleted_notification %}
|
||||
|
||||
{% block post_comment_created_notification %}
|
||||
|
|
38
tests/Command/AdminCommandTest.php
Normal file
38
tests/Command/AdminCommandTest.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Command;
|
||||
|
||||
use App\DTO\RegisterUserDto;
|
||||
use App\Repository\UserRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class AdminCommandTest extends KernelTestCase
|
||||
{
|
||||
private Command $command;
|
||||
private ?UserRepository $repository;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$application = new Application(self::bootKernel());
|
||||
|
||||
$this->command = $application->find('kbin:user:admin');
|
||||
$this->repository = self::$container->get(UserRepository::class);
|
||||
}
|
||||
|
||||
public function testCreateUser()
|
||||
{
|
||||
self::$container->get('App\Service\UserManager')
|
||||
->create((new RegisterUserDto())->create('actor', 'contact@example.com', 'secret'), false);
|
||||
|
||||
$this->assertFalse($this->repository->findOneByUsername('actor')->isAdmin());
|
||||
|
||||
$tester = new CommandTester($this->command);
|
||||
$tester->execute(['username' => 'actor']);
|
||||
|
||||
$this->assertStringContainsString('Administrator privileges has been granted.', $tester->getDisplay());
|
||||
$this->assertTrue($this->repository->findOneByUsername('actor')->isAdmin());
|
||||
}
|
||||
}
|
39
tests/Command/UserCommandTest.php
Normal file
39
tests/Command/UserCommandTest.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Command;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Repository\UserRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class UserCommandTest extends KernelTestCase
|
||||
{
|
||||
private Command $command;
|
||||
private ?UserRepository $repository;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$application = new Application(self::bootKernel());
|
||||
|
||||
$this->command = $application->find('kbin:user:create');
|
||||
$this->repository = self::$container->get(UserRepository::class);
|
||||
}
|
||||
|
||||
public function testCreateUser()
|
||||
{
|
||||
$tester = new CommandTester($this->command);
|
||||
$tester->execute(
|
||||
[
|
||||
'username' => 'actor',
|
||||
'email' => 'contact@example.com',
|
||||
'password' => 'secret',
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('A user has been created.', $tester->getDisplay());
|
||||
$this->assertInstanceOf(User::class, $this->repository->findOneByUsername('actor'));;
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@ class MessageControllerTest extends WebTestCase
|
|||
|
||||
$client->loginUser($this->getUserByUsername('testUser1'));
|
||||
|
||||
$crawler = $client->request('GET', '/profil/wiadomosci');
|
||||
$crawler = $client->request('GET', '/profil/wiadomosci');
|
||||
|
||||
$this->assertSelectorTextContains('.kbin-profile-threads-page', '0 odpowiedzi w wątku z /u/testUser - Testowa wiadomość.');
|
||||
|
@ -74,6 +75,7 @@ class MessageControllerTest extends WebTestCase
|
|||
// Read reply
|
||||
$client->loginUser($this->getUserByUsername('testUser'));
|
||||
|
||||
$crawler = $client->request('GET', '/profil/wiadomosci');
|
||||
$crawler = $client->request('GET', '/profil/wiadomosci');
|
||||
|
||||
$this->assertSelectorTextContains('.kbin-profile-threads-page', '1 odpowiedzi w wątku z /u/testUser1 - Testowa wiadomość.');
|
||||
|
|
|
@ -17,22 +17,7 @@ class ModlogControllerTest extends WebTestCase
|
|||
$client = $this->createClient();
|
||||
$client->loginUser($this->getUserByUsername('owner'));
|
||||
|
||||
$owner = $this->getUserByUsername('owner');
|
||||
$magazine = $this->getMagazineByName('polityka', $owner);
|
||||
|
||||
$actor = $this->getUserByUsername('actor');
|
||||
|
||||
$entry = $this->getEntryByTitle('test', null, 'test', $magazine, $actor);
|
||||
$comment = $this->createEntryComment('test', $entry, $actor);
|
||||
(self::$container->get(EntryManager::class))->delete($owner, $entry);
|
||||
(self::$container->get(EntryCommentManager::class))->delete($owner, $comment);
|
||||
|
||||
$post = $this->createPost('test', $magazine, $actor);
|
||||
$comment = $this->createPostComment('test', $post, $actor);
|
||||
(self::$container->get(PostManager::class))->delete($owner, $post);
|
||||
(self::$container->get(PostCommentManager::class))->delete($owner, $comment);
|
||||
|
||||
(self::$container->get(MagazineManager::class))->ban($magazine, $actor, $owner, (new MagazineBanDto())->create('test', new \DateTime('+1 day')));
|
||||
$this->loadNotificationsFixture();
|
||||
|
||||
$crawler = $client->request('GET', '/modlog');
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Service\MagazineManager;
|
||||
use App\Tests\WebTestCase;
|
||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
|
||||
|
@ -114,4 +115,72 @@ class ProfileControllerTest extends WebTestCase
|
|||
|
||||
$this->assertSelectorTextContains('.kbn-login-btn', 'Profil');
|
||||
}
|
||||
|
||||
public function testUserReceiveNotifications()
|
||||
{
|
||||
$client = $this->createClient();
|
||||
$client->loginUser($this->getUserByUsername('owner'));
|
||||
|
||||
(self::$container->get(MagazineManager::class))->subscribe($this->getMagazineByName('polityka'), $this->getUserByUsername('owner'));
|
||||
(self::$container->get(MagazineManager::class))->subscribe($this->getMagazineByName('polityka'), $this->getUserByUsername('actor'));
|
||||
|
||||
$this->loadNotificationsFixture();
|
||||
|
||||
$client->loginUser($this->getUserByUsername('owner'));
|
||||
$crawler = $client->request('GET', '/profil/notyfikacje');
|
||||
$this->assertCount(4, $crawler->filter('.table-responsive tr'));
|
||||
|
||||
$client->loginUser($this->getUserByUsername('actor'));
|
||||
$crawler = $client->request('GET', '/profil/notyfikacje');
|
||||
$this->assertCount(4, $crawler->filter('.table-responsive tr'));
|
||||
}
|
||||
|
||||
public function testUserCanReadAllNotifications()
|
||||
{
|
||||
$client = $this->createClient();
|
||||
$client->loginUser($this->getUserByUsername('owner'));
|
||||
|
||||
(self::$container->get(MagazineManager::class))->subscribe($this->getMagazineByName('polityka'), $this->getUserByUsername('owner'));
|
||||
(self::$container->get(MagazineManager::class))->subscribe($this->getMagazineByName('polityka'), $this->getUserByUsername('actor'));
|
||||
|
||||
$this->loadNotificationsFixture();
|
||||
|
||||
$client->loginUser($this->getUserByUsername('owner'));
|
||||
$crawler = $client->request('GET', '/profil/notyfikacje');
|
||||
$crawler = $client->request('GET', '/profil/notyfikacje');
|
||||
|
||||
$this->assertCount(8, $crawler->filter('.table-responsive td'));
|
||||
$this->assertCount(0, $crawler->filter('.table-responsive td.opacity-50'));
|
||||
|
||||
$client->submit($crawler->selectButton('Odczytaj wszystkie')->form());
|
||||
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
$this->assertCount(8, $crawler->filter('.table-responsive td'));
|
||||
$this->assertCount(4, $crawler->filter('.table-responsive td.opacity-50'));
|
||||
}
|
||||
|
||||
public function testUserCanDeleteAllNotifications()
|
||||
{
|
||||
$client = $this->createClient();
|
||||
$client->loginUser($this->getUserByUsername('owner'));
|
||||
|
||||
(self::$container->get(MagazineManager::class))->subscribe($this->getMagazineByName('polityka'), $this->getUserByUsername('owner'));
|
||||
(self::$container->get(MagazineManager::class))->subscribe($this->getMagazineByName('polityka'), $this->getUserByUsername('actor'));
|
||||
|
||||
$this->loadNotificationsFixture();
|
||||
|
||||
$client->loginUser($this->getUserByUsername('owner'));
|
||||
$crawler = $client->request('GET', '/profil/notyfikacje');
|
||||
$crawler = $client->request('GET', '/profil/notyfikacje');
|
||||
|
||||
$this->assertCount(8, $crawler->filter('.table-responsive td'));
|
||||
$this->assertCount(0, $crawler->filter('.table-responsive td.opacity-50'));
|
||||
|
||||
$client->submit($crawler->selectButton('Wyczyść')->form());
|
||||
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
$this->assertCount(0, $crawler->filter('.table-responsive td'));
|
||||
}
|
||||
}
|
||||
|
|
26
tests/Utils/SluggerTest.php
Normal file
26
tests/Utils/SluggerTest.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Command;
|
||||
|
||||
use App\Utils\Slugger;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
class SluggerTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*/
|
||||
public function testCamelCase(string $input, string $output)
|
||||
{
|
||||
$this->assertEquals($output, (new Slugger())->camelCase($input));
|
||||
}
|
||||
|
||||
public function provider(): array
|
||||
{
|
||||
return [
|
||||
['Lorem ipsum', 'loremIpsum'],
|
||||
['LOremIpsum', 'lOremIpsum'],
|
||||
['LORemIpsum', 'lORemIpsum'],
|
||||
];
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ namespace App\Tests;
|
|||
|
||||
use App\DTO\EntryCommentDto;
|
||||
use App\DTO\EntryDto;
|
||||
use App\DTO\MagazineBanDto;
|
||||
use App\DTO\MagazineDto;
|
||||
use App\DTO\PostCommentDto;
|
||||
use App\DTO\PostDto;
|
||||
|
@ -233,4 +234,24 @@ abstract class WebTestCase extends BaseWebTestCase
|
|||
|
||||
return $magazine;
|
||||
}
|
||||
|
||||
protected function loadNotificationsFixture()
|
||||
{
|
||||
$owner = $this->getUserByUsername('owner');
|
||||
$magazine = $this->getMagazineByName('polityka', $owner);
|
||||
|
||||
$actor = $this->getUserByUsername('actor');
|
||||
|
||||
$entry = $this->getEntryByTitle('test', null, 'test', $magazine, $actor);
|
||||
$comment = $this->createEntryComment('test', $entry, $actor);
|
||||
(self::$container->get(EntryManager::class))->delete($owner, $entry);
|
||||
(self::$container->get(EntryCommentManager::class))->delete($owner, $comment);
|
||||
|
||||
$post = $this->createPost('test', $magazine, $actor);
|
||||
$comment = $this->createPostComment('test', $post, $actor);
|
||||
(self::$container->get(PostManager::class))->delete($owner, $post);
|
||||
(self::$container->get(PostCommentManager::class))->delete($owner, $comment);
|
||||
|
||||
(self::$container->get(MagazineManager::class))->ban($magazine, $actor, $owner, (new MagazineBanDto())->create('test', new \DateTime('+1 day')));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue