-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
37 lines (27 loc) · 1.06 KB
/
test.php
File metadata and controls
37 lines (27 loc) · 1.06 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
<?php
require_once __DIR__ . '/vendor/autoload.php';
use function TryPhp\{stripControlCharacters, stripColorCharacters};
$shouldBeRemoved = "\a\0\b\v\f\r\e";
$toBeTested = stripControlCharacters($shouldBeRemoved);
if ($toBeTested !== '') {
trigger_error('test failed', E_USER_ERROR);
}
$shouldBeReplaced = "\nSome\tThings\t";
$toBeTested = trim(stripControlCharacters($shouldBeReplaced));
if ($toBeTested !== 'Some Things') {
trigger_error('test failed', E_USER_ERROR);
}
$shouldBeReplaced = " ";
$toBeTested = stripControlCharacters($shouldBeReplaced);
if ($toBeTested !== ' ') {
trigger_error('test failed', E_USER_ERROR);
}
$shouldBeRemoved ="\e[34mSome String\e[0m";
$toBeTested = stripColorCharacters($shouldBeRemoved);
if ($toBeTested !== 'Some String') {
trigger_error('test failed', E_USER_ERROR);
}
$shouldBeSimplified = trim(stripControlCharacters(stripColorCharacters("\t\n\e[34mSome String\e[0m\n\e[34mSome String\e[0m\n\e[34mSome String\e[0m")));
if ($shouldBeSimplified !== 'Some String Some String Some String') {
trigger_error('test failed', E_USER_ERROR);
}