Skip to content

Commit 39ab69e

Browse files
fix string test structure
1 parent 9c27262 commit 39ab69e

File tree

1 file changed

+36
-40
lines changed

1 file changed

+36
-40
lines changed

tests/Strings/StringsTest.php

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?php
22

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-
83
use PHPUnit\Framework\TestCase;
94

105
require_once __DIR__ . '/../../vendor/autoload.php';
@@ -24,73 +19,74 @@ class StringsTest extends TestCase
2419
{
2520
public function testIsPalindrome()
2621
{
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
3228
}
3329

3430
public function testCountSentences()
3531
{
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?'));
3935
}
4036

4137
public function testReverseString()
4238
{
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'));
4642
}
4743

4844
public function testReverseWords()
4945
{
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'));
5349
}
5450

5551
public function testIsAnagram()
5652
{
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
6258
}
6359

6460
public function testMaxCharacter()
6561
{
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(" "));
6965
}
7066

7167
public function testCountVowels()
7268
{
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"));
7672

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"));
8076
}
8177

8278
public function testCountConsonants()
8379
{
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"));
8783
}
8884

8985
public function testFindDistance()
9086
{
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"));
9591
}
9692
}

0 commit comments

Comments
 (0)