<?php

declare(strict_types=1);

/*
 * Chill is a software for social workers
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Chill\TicketBundle\Tests\Action\Comment\Handler;

use Chill\TicketBundle\Action\Comment\Handler\UpdateCommentContentCommandHandler;
use Chill\TicketBundle\Action\Comment\UpdateCommentContentCommand;
use Chill\TicketBundle\Entity\Comment;
use Chill\TicketBundle\Entity\Ticket;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/**
 * @internal
 *
 * @coversNothing
 */
class UpdateCommentContentCommandHandlerTest extends TestCase
{
    use ProphecyTrait;

    public function testUpdateCommentContent(): void
    {
        $handler = $this->buildCommand();

        $ticket = new Ticket();
        $comment = new Comment('initial content', $ticket);
        $command = new UpdateCommentContentCommand(content: 'updated content');

        $handler->handle($comment, $command);

        self::assertEquals('updated content', $comment->getContent());
    }

    private function buildCommand(): UpdateCommentContentCommandHandler
    {
        $entityManager = $this->prophesize(EntityManagerInterface::class);

        return new UpdateCommentContentCommandHandler($entityManager->reveal());
    }
}
