1
1
<?php
2
2
3
- use function PHPUnit \Framework \assertEquals ;
4
- use function PHPUnit \Framework \assertFalse ;
5
- use function PHPUnit \Framework \assertNotEquals ;
6
- use function PHPUnit \Framework \assertTrue ;
7
-
8
3
use PHPUnit \Framework \TestCase ;
9
4
10
5
require_once __DIR__ . '/../../vendor/autoload.php ' ;
@@ -24,73 +19,74 @@ class StringsTest extends TestCase
24
19
{
25
20
public function testIsPalindrome ()
26
21
{
27
- assertTrue (isPalindrome ('MaDam ' )); // true
28
- assertFalse (isPalindrome ('ThisIsTest ' )); // false
29
- assertFalse (isPalindrome ('' )); // false
30
- assertTrue (isPalindrome ('Sator Arepo Tenet Opera Rotas ' )); // true
31
- assertFalse (isPalindrome ('Sator Arepo Tenet Opera Rotas ' , false )); // false since we are doing case-sensitive check
22
+ $ this ->assertTrue (isPalindrome ('MaDam ' )); // true
23
+ $ this ->assertFalse (isPalindrome ('ThisIsTest ' )); // false
24
+ $ this ->assertFalse (isPalindrome ('' )); // false
25
+ $ this ->assertTrue (isPalindrome ('Sator Arepo Tenet Opera Rotas ' )); // true
26
+ $ this ->assertFalse (isPalindrome ('Sator Arepo Tenet Opera Rotas ' , false )); // false since we are doing
27
+ // case-sensitive check
32
28
}
33
29
34
30
public function testCountSentences ()
35
31
{
36
- assertEquals (countSentences ('Hi! Hello world. ' ), 2 );
37
- assertEquals (countSentences ('i am testing. test.... ' ), 2 );
38
- assertEquals (countSentences ('How are you? ' ), 1 );
32
+ $ this -> assertEquals (2 , countSentences ('Hi! Hello world. ' ));
33
+ $ this -> assertEquals (2 , countSentences ('i am testing. test.... ' ));
34
+ $ this -> assertEquals (1 , countSentences ('How are you? ' ));
39
35
}
40
36
41
37
public function testReverseString ()
42
38
{
43
- assertEquals ('txet emos si sihT ' , reverseString ('This is some text ' ));
44
- assertEquals ('mADaM ' , reverseString ('MaDAm ' ));
45
- assertNotEquals ('MaDAm ' , reverseString ('MaDAm ' ));
39
+ $ this -> assertEquals ('txet emos si sihT ' , reverseString ('This is some text ' ));
40
+ $ this -> assertEquals ('mADaM ' , reverseString ('MaDAm ' ));
41
+ $ this -> assertNotEquals ('MaDAm ' , reverseString ('MaDAm ' ));
46
42
}
47
43
48
44
public function testReverseWords ()
49
45
{
50
- assertEquals ('Fun is Coding PHP ' , reverseWords ('PHP Coding is Fun ' ));
51
- assertEquals ('OneWord ' , reverseWords ('OneWord ' ));
52
- assertEquals ('Text different some is This ' , reverseWords ('This is some different Text ' ));
46
+ $ this -> assertEquals ('Fun is Coding PHP ' , reverseWords ('PHP Coding is Fun ' ));
47
+ $ this -> assertEquals ('OneWord ' , reverseWords ('OneWord ' ));
48
+ $ this -> assertEquals ('Text different some is This ' , reverseWords ('This is some different Text ' ));
53
49
}
54
50
55
51
public function testIsAnagram ()
56
52
{
57
- assertTrue (isAnagram ("php " , "PHP " )); // By default it's case-insensitive
58
- assertFalse (isAnagram ("php " , "PHP " , false )); // Make case-sensitive check
59
- assertTrue (isAnagram ("php is fun " , "pin hpf us " ));
60
- assertFalse (isAnagram ("Hello " , " Hello " )); //Extra space character
61
- assertTrue (isAnagram ("ScRamble " , "SRlmcaeb " , false )); // Check with a mixture of upper and lower case
53
+ $ this -> assertTrue (isAnagram ("php " , "PHP " )); // By default it's case-insensitive
54
+ $ this -> assertFalse (isAnagram ("php " , "PHP " , false )); // Make case-sensitive check
55
+ $ this -> assertTrue (isAnagram ("php is fun " , "pin hpf us " ));
56
+ $ this -> assertFalse (isAnagram ("Hello " , " Hello " )); //Extra space character
57
+ $ this -> assertTrue (isAnagram ("ScRamble " , "SRlmcaeb " , false )); // Check with a mixture of upper and lower case
62
58
}
63
59
64
60
public function testMaxCharacter ()
65
61
{
66
- assertEquals (maxCharacter ("this is test for max character repetition " ), ' t ' );
67
- assertEquals (maxCharacter ("This is Test for max characTer repetition " ), ' t ' );
68
- assertEquals (maxCharacter (" " ), ' ' );
62
+ $ this -> assertEquals (' t ' , maxCharacter ("this is test for max character repetition " ));
63
+ $ this -> assertEquals (' t ' , maxCharacter ("This is Test for max characTer repetition " ));
64
+ $ this -> assertEquals (' ' , maxCharacter (" " ));
69
65
}
70
66
71
67
public function testCountVowels ()
72
68
{
73
- assertEquals (countVowelsSimple ("This is a string with 7 vowels " ), 7 );
74
- assertEquals (countVowelsSimple ("hello world " ), 3 );
75
- assertEquals (countVowelsRegex ("Just A list of somE aaaaaaaaaa " ), 16 );
69
+ $ this -> assertEquals (7 , countVowelsSimple ("This is a string with 7 vowels " ));
70
+ $ this -> assertEquals (3 , countVowelsSimple ("hello world " ));
71
+ $ this -> assertEquals (16 , countVowelsRegex ("Just A list of somE aaaaaaaaaa " ));
76
72
77
- assertEquals (countVowelsRegex ("This is a string with 7 vowels " ), 7 );
78
- assertEquals (countVowelsRegex ("hello world " ), 3 );
79
- assertEquals (countVowelsRegex ("Just A list of somE aaaaaaaaaa " ), 16 );
73
+ $ this -> assertEquals (7 , countVowelsRegex ("This is a string with 7 vowels " ));
74
+ $ this -> assertEquals (3 , countVowelsRegex ("hello world " ));
75
+ $ this -> assertEquals (16 , countVowelsRegex ("Just A list of somE aaaaaaaaaa " ));
80
76
}
81
77
82
78
public function testCountConsonants ()
83
79
{
84
- assertEquals (countConsonants ("This is a string with 19 consonants " ), 19 );
85
- assertEquals (countConsonants ("hello world " ), 7 );
86
- assertEquals (countConsonants ("Just A list of somE aaaaaaaaaa " ), 9 );
80
+ $ this -> assertEquals (19 , countConsonants ("This is a string with 19 consonants " ));
81
+ $ this -> assertEquals (7 , countConsonants ("hello world " ));
82
+ $ this -> assertEquals (9 , countConsonants ("Just A list of somE aaaaaaaaaa " ));
87
83
}
88
84
89
85
public function testFindDistance ()
90
86
{
91
- assertEquals (findDistance ("hello " , "hallo " ), 1 );
92
- assertEquals (findDistance ("hallo " , "hello " ), 1 );
93
- assertEquals (findDistance ("sunday " , "sunday " ), 0 );
94
- assertEquals (findDistance ("saturday " , "sunday " ), 3 );
87
+ $ this -> assertEquals (1 , findDistance ("hello " , "hallo " ));
88
+ $ this -> assertEquals (1 , findDistance ("hallo " , "hello " ));
89
+ $ this -> assertEquals (0 , findDistance ("sunday " , "sunday " ));
90
+ $ this -> assertEquals (3 , findDistance ("saturday " , "sunday " ));
95
91
}
96
92
}
0 commit comments