mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-26 16:42:27 +03:00
Update ArrayHelperTest.php
This commit is contained in:
parent
c1fe38d076
commit
2deb952bf1
1 changed files with 7 additions and 6 deletions
|
@ -6,23 +6,23 @@ use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../application/helpers/array_helper.php';
|
require_once __DIR__ . '/../../../application/helpers/array_helper.php';
|
||||||
|
|
||||||
class TestArrayHelper extends TestCase {
|
class ArrayHelperTest extends TestCase {
|
||||||
public function test_is_assoc_returns_true_on_associative_array()
|
public function testIsAssocReturnsTrueOnAssociativeArray()
|
||||||
{
|
{
|
||||||
$this->assertTrue(is_assoc(['test' => 'value']));
|
$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']));
|
$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']));
|
$this->assertTrue(is_assoc(['one', 'two', 'three' => 'value']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_array_find_returns_correct_element()
|
public function testArrayFindReturnsCorrectElement()
|
||||||
{
|
{
|
||||||
$arr = [
|
$arr = [
|
||||||
[
|
[
|
||||||
|
@ -39,7 +39,7 @@ class TestArrayHelper extends TestCase {
|
||||||
$this->assertSame($arr[0], array_find($arr, fn($element) => $element['id'] === 1));
|
$this->assertSame($arr[0], array_find($arr, fn($element) => $element['id'] === 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_array_fields_returns_stripped_array()
|
public function testArrayFieldsReturnsStrippedArray()
|
||||||
{
|
{
|
||||||
$arr = [
|
$arr = [
|
||||||
'name' => 'John',
|
'name' => 'John',
|
||||||
|
@ -49,6 +49,7 @@ class TestArrayHelper extends TestCase {
|
||||||
$stripped = array_fields($arr, ['name']);
|
$stripped = array_fields($arr, ['name']);
|
||||||
|
|
||||||
$this->assertArrayHasKey('name', $stripped);
|
$this->assertArrayHasKey('name', $stripped);
|
||||||
|
|
||||||
$this->assertArrayNotHasKey('email', $stripped);
|
$this->assertArrayNotHasKey('email', $stripped);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue