Your IP : 216.73.217.79


Current Path : /var/www/v3.cesa.co.za/tests/Unit/ContentBundle/
Upload File :
Current File : /var/www/v3.cesa.co.za/tests/Unit/ContentBundle/FormCompletedManagerPlainTextJoinTest.php

<?php

declare(strict_types=1);

namespace App\Tests\Unit\ContentBundle;

use App\ContentBundle\Services\FormCompletedManager;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

final class FormCompletedManagerPlainTextJoinTest extends TestCase
{
    private function managerWithoutConstructor(): FormCompletedManager
    {
        $ref = new ReflectionClass(FormCompletedManager::class);

        return $ref->newInstanceWithoutConstructor();
    }

    public function testJoinPlainTextSegmentsWithBoundaryJoinsNonEmptySegments(): void
    {
        $manager = $this->managerWithoutConstructor();

        $out = $manager->joinPlainTextSegmentsWithBoundary(array('first answer', 'second answer'));
        $this->assertSame("first answer\n------------\nsecond answer", $out);
    }

    public function testJoinPlainTextSegmentsWithBoundaryTrimsAndSkipsEmpty(): void
    {
        $manager = $this->managerWithoutConstructor();

        $out = $manager->joinPlainTextSegmentsWithBoundary(array('  a  ', '', '  b  '));
        $this->assertSame("a\n------------\nb", $out);
    }

    public function testJoinPlainTextSegmentsWithBoundaryReturnsEmptyStringWhenNoSegments(): void
    {
        $manager = $this->managerWithoutConstructor();

        $this->assertSame('', $manager->joinPlainTextSegmentsWithBoundary(array()));
        $this->assertSame('', $manager->joinPlainTextSegmentsWithBoundary(array('', '   ')));
    }
}