File size: 2,256 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

namespace Mautic\PluginBundle\Tests\Entity;

use Mautic\PluginBundle\Entity\Plugin;

class PluginTest extends \PHPUnit\Framework\TestCase
{
    public function testEmptyDescription(): void
    {
        $plugin = new Plugin();
        $this->assertNull($plugin->getDescription());
        $this->assertNull($plugin->getPrimaryDescription());
        $this->assertNull($plugin->getSecondaryDescription());
        $this->assertFalse($plugin->hasSecondaryDescription());
    }

    public function testSimpleDescription(): void
    {
        $description = 'This is the best plugin in the whole galaxy';
        $plugin      = new Plugin();
        $plugin->setDescription($description);
        $this->assertEquals($description, $plugin->getDescription());
        $this->assertEquals($description, $plugin->getPrimaryDescription());
        $this->assertNull($plugin->getSecondaryDescription());
        $this->assertFalse($plugin->hasSecondaryDescription());
    }

    public function testSecondaryDescriptionWithUnixLineEnding(): void
    {
        $description = "This is the best plugin in the whole galaxy\n---\nLearn more about it <a href=\"#\">here</a>";
        $plugin      = new Plugin();
        $plugin->setDescription($description);
        $this->assertEquals($description, $plugin->getDescription());
        $this->assertEquals('This is the best plugin in the whole galaxy', $plugin->getPrimaryDescription());
        $this->assertEquals('Learn more about it <a href="#">here</a>', $plugin->getSecondaryDescription());
        $this->assertTrue($plugin->hasSecondaryDescription());
    }

    public function testSecondaryDescriptionWithWinLineEnding(): void
    {
        $description = "This is the best plugin in the whole galaxy\n\r---\n\rLearn more about it <a href=\"#\">here</a>";
        $plugin      = new Plugin();
        $plugin->setDescription($description);
        $this->assertEquals($description, $plugin->getDescription());
        $this->assertEquals('This is the best plugin in the whole galaxy', $plugin->getPrimaryDescription());
        $this->assertEquals('Learn more about it <a href="#">here</a>', $plugin->getSecondaryDescription());
        $this->assertTrue($plugin->hasSecondaryDescription());
    }
}