forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaseTitleTest.php
More file actions
65 lines (50 loc) · 2.32 KB
/
CaseTitleTest.php
File metadata and controls
65 lines (50 loc) · 2.32 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace Tests;
use ProcessMaker\Models\ProcessRequest;
class CaseTitleTest extends TestCase
{
const MUSTACHE_VARIABLE = '{{name}}';
public function testEvaluateCaseTitleWithoutFormatting()
{
$processRequest = new ProcessRequest();
$title = $processRequest->evaluateCaseTitle('Hello, {{name}}!', ['name' => 'World'], false);
$this->assertEquals('Hello, World!', $title);
}
public function testEvaluateCaseTitleWithFormatting()
{
$processRequest = new ProcessRequest();
$title = $processRequest->evaluateCaseTitle('Hello, {{name}}!', ['name' => 'World'], true);
$this->assertEquals('Hello, <b>World</b>!', $title);
}
public function testEvaluateCaseTitleWithCharacterLimit()
{
$processRequest = new ProcessRequest();
$longString = str_repeat('a', 300);
$title = $processRequest->evaluateCaseTitle($longString, [], true);
$this->assertEquals(200, mb_strlen($title));
}
public function testEvaluateCaseTitleWithHtmlTagsNotCountedInCharacterLimit()
{
$processRequest = new ProcessRequest();
$longString = str_repeat('a', 195) . self::MUSTACHE_VARIABLE;
$title = $processRequest->evaluateCaseTitle($longString, ['name' => 'World'], true);
$this->assertEquals(200 + 7, mb_strlen($title)); // 7 is the length of '<b></b>'
$this->assertEquals(str_repeat('a', 195) . '<b>World</b>', $title);
}
public function testEvaluateCaseTitleWithHtmlTagsNotCountedTwoCharactersMoreThanLimit()
{
$processRequest = new ProcessRequest();
$longString = str_repeat('a', 197) . self::MUSTACHE_VARIABLE;
$title = $processRequest->evaluateCaseTitle($longString, ['name' => 'World'], true);
$this->assertEquals(200 + 7, mb_strlen($title)); // 7 is the length of '<b></b>'
$this->assertEquals(str_repeat('a', 197) . '<b>Wor</b>', $title);
}
public function testEvaluateCaseTitleWithoutHtmlTagsThatExceededTheLimit()
{
$processRequest = new ProcessRequest();
$longString = str_repeat('a', 200) . self::MUSTACHE_VARIABLE;
$title = $processRequest->evaluateCaseTitle($longString, ['name' => 'World'], true);
$this->assertEquals(200, mb_strlen($title));
$this->assertEquals(str_repeat('a', 200), $title);
}
}