Skip to content

Commit ff87b60

Browse files
committed
adding new test
1 parent 36b16e6 commit ff87b60

7 files changed

Lines changed: 48 additions & 2 deletions

File tree

php-unit/app/Examples/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public function equals(self $other): bool
2121

2222
public function ensureIsValidEmail(string $email): mixed
2323
{
24-
24+
//
2525
}
2626
}

php-unit/app/helpers.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
if (! function_exists('arrayIterable')) {
4+
function arrayIterable(): iterable {
5+
return [1,2,3,4,5];
6+
}
7+
}

php-unit/composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
{
2+
"autoload": {
3+
"psr-4": {
4+
"App\\": "app"
5+
},
6+
"files": [
7+
"app/helpers.php"
8+
]
9+
},
210
"autoload-dev": {
311
"psr-4": {
4-
"App\\": "app",
512
"Tests\\": "tests"
613
}
714
},

php-unit/tests/ClassTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,10 @@ public function testIfInstanceOf()
6565
// Success if class instance of parent class
6666
$this->assertInstanceOf(Exception::class, new RedisException);
6767
}
68+
69+
public function testIfIsObject()
70+
{
71+
// Failure if is not object
72+
$this->assertIsObject(new User("novalramdhani@gmail.com"));
73+
}
6874
}

php-unit/tests/MiscellaneousTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,16 @@ public function testIfIsCallable()
3030

3131
$this->assertIsCallable($func);
3232
}
33+
34+
public function testIfIsIterable()
35+
{
36+
// Failure if is not iterable
37+
$this->assertIsIterable(arrayIterable());
38+
}
39+
40+
public function testIfIsScalar()
41+
{
42+
// Test if is not scalar type like (object, iterable, resource etc)
43+
$this->assertIsScalar(true);
44+
}
3345
}

php-unit/tests/NumberTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,10 @@ public function testIfIsIntegerNumber()
3636
// Failure if is not integer
3737
$this->assertIsInt(100);
3838
}
39+
40+
public function testIfIsNumeric()
41+
{
42+
// Failure if is not numeric number
43+
$this->assertIsNumeric(1000);
44+
}
3945
}

php-unit/tests/StringTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,12 @@ public function testIfStringEqualsWithIgnoreCase()
5858

5959
$this->assertEqualsIgnoringCase('I love ruby', $string);
6060
}
61+
62+
public function testIfIsString()
63+
{
64+
// Failure if is not string type
65+
$string = "Laravel Framework";
66+
67+
$this->assertIsString($string);
68+
}
6169
}

0 commit comments

Comments
 (0)