Update ArrayHelperTest.php

This commit is contained in:
Alex Tselegidis 2023-03-23 08:05:14 +01:00
parent c1fe38d076
commit 2deb952bf1
1 changed files with 7 additions and 6 deletions

View File

@ -6,23 +6,23 @@ use PHPUnit\Framework\TestCase;
require_once __DIR__ . '/../../../application/helpers/array_helper.php';
class TestArrayHelper extends TestCase {
public function test_is_assoc_returns_true_on_associative_array()
class ArrayHelperTest extends TestCase {
public function testIsAssocReturnsTrueOnAssociativeArray()
{
$this->assertTrue(is_assoc(['test' => 'value']));
}
public function test_is_assoc_returns_false_on_indexed_array()
public function testIsAssocReturnsFalseOnIndexedArray()
{
$this->assertFalse(is_assoc(['one', 'two', 'three']));
}
public function test_is_assoc_returns_true_on_mixed_array()
public function testIsAssocReturnsTrueOnMixedArray()
{
$this->assertTrue(is_assoc(['one', 'two', 'three' => 'value']));
}
public function test_array_find_returns_correct_element()
public function testArrayFindReturnsCorrectElement()
{
$arr = [
[
@ -39,7 +39,7 @@ class TestArrayHelper extends TestCase {
$this->assertSame($arr[0], array_find($arr, fn($element) => $element['id'] === 1));
}
public function test_array_fields_returns_stripped_array()
public function testArrayFieldsReturnsStrippedArray()
{
$arr = [
'name' => 'John',
@ -49,6 +49,7 @@ class TestArrayHelper extends TestCase {
$stripped = array_fields($arr, ['name']);
$this->assertArrayHasKey('name', $stripped);
$this->assertArrayNotHasKey('email', $stripped);
}
}